Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flyout updates #2442

Merged
merged 6 commits into from
May 16, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion vnext/ReactUWP/Views/FlyoutViewManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,46 @@ struct json_type_traits<winrt::FlyoutPlacementMode>
{
placement = winrt::FlyoutPlacementMode::Right;
}
else
else if (json == "top-edge-aligned-left")
{
placement = winrt::FlyoutPlacementMode::TopEdgeAlignedLeft;
}
else if (json == "top-edge-aligned-right")
{
placement = winrt::FlyoutPlacementMode::TopEdgeAlignedRight;
}
else if (json == "bottom-edge-aligned-left")
{
placement = winrt::FlyoutPlacementMode::BottomEdgeAlignedLeft;
}
else if (json == "bottom-edge-aligned-right")
{
placement = winrt::FlyoutPlacementMode::BottomEdgeAlignedRight;
}
else if (json == "left-edge-aligned-top")
{
placement = winrt::FlyoutPlacementMode::LeftEdgeAlignedTop;
}
else if (json == "right-edge-aligned-top")
{
placement = winrt::FlyoutPlacementMode::RightEdgeAlignedTop;
}
else if (json == "left-bottom")
{
placement = winrt::FlyoutPlacementMode::LeftEdgeAlignedBottom;
}
else if (json == "right-edge-aligned-bottom")
{
placement = winrt::FlyoutPlacementMode::RightEdgeAlignedBottom;
}
else if (json == "full")
{
placement = winrt::FlyoutPlacementMode::Full;
}
else
{
placement = winrt::FlyoutPlacementMode::Top;
}

return placement;
}
Expand Down
18 changes: 17 additions & 1 deletion vnext/src/Libraries/Components/Flyout/FlyoutProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,26 @@
// Licensed under the MIT License.
import { ViewProps } from 'react-native';

export enum Placement {
ahimberg marked this conversation as resolved.
Show resolved Hide resolved
top = 'top',
bottom = 'bottom',
left = 'left',
right = 'right',
full = 'full',
topLeft = 'top-edge-aligned-left',
topRight = 'top-edge-aligned-right',
bottomLeft = 'bottom-edge-aligned-left',
bottomRight = 'bottom-edge-aligned-right',
leftTop = 'left-edge-aligned-top',
rightTop = 'right-edge-aligned-top',
leftBottom = 'left-edge-aligned-bottom',
rightBottom = 'right-edge-aligned-bottom'
}

export interface IFlyoutProps extends ViewProps {
isLightDismissEnabled?: boolean;
isOpen?: boolean;
onDismiss?: (isOpen: boolean) => void;
placement?: 'top' | 'bottom' | 'left' | 'right' | 'full';
placement?: Placement;
target?: React.ReactNode;
}
12 changes: 5 additions & 7 deletions vnext/src/RNTester/FlyoutExample.uwp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
import React = require('react');
import { Button, Text, TextInput, View } from 'react-native';
import { CheckBox, Flyout, Picker } from '../../src/index.uwp';
import { Placement } from '../../src/Libraries/Components/Flyout/FlyoutProps';

interface IFlyoutExampleState {
isFlyoutVisible: boolean;
buttonTitle: string;
isLightDismissEnabled: boolean;
popupCheckBoxState: boolean;
placementOptions: 'top' | 'bottom' | 'left' | 'right' | 'full';
placementOptions: Placement;
}

class FlyoutExample extends React.Component<{}, IFlyoutExampleState> {
Expand All @@ -25,7 +26,7 @@ class FlyoutExample extends React.Component<{}, IFlyoutExampleState> {
buttonTitle: 'Open Flyout',
isLightDismissEnabled: true,
popupCheckBoxState: true,
placementOptions: 'top',
placementOptions: Placement.top,
};

public constructor(props: any) {
Expand All @@ -34,18 +35,15 @@ class FlyoutExample extends React.Component<{}, IFlyoutExampleState> {
}

public render() {
let placementValues = (Object as any)["values"](Placement) as string[];
return (
<View>
<View style={ { flexDirection: 'row', paddingTop: 20 } }>
<Text style={ { padding: 10 } }>Placement Options: </Text>
<Picker
style={ { width: 200, height: 35 } } selectedValue={ this.state.placementOptions }
onValueChange={ value => this.setState({ placementOptions: value }) }>
<Picker.Item label='top' value='top' />
<Picker.Item label='bottom' value='bottom' />
<Picker.Item label='left' value='left' />
<Picker.Item label='right' value='right' />
<Picker.Item label='full' value='full' />
{ placementValues.map(item => <Picker.Item key={item} label={item} value={item} /> ) }
</Picker>
</View>
<View style={ { justifyContent: 'center', padding: 20, width: 200 } }>
Expand Down