Skip to content

Commit

Permalink
Flyout updates (#2442)
Browse files Browse the repository at this point in the history
* Adding more placement options for the Flyout component

* Simplifying placement enum usage

* simplifying placement enum usage..again

* Clariftying the flyout placement options and setting default to 'top'

* Converting placement string enum to string literal type.
  • Loading branch information
KAnder425 authored and ahimberg committed May 16, 2019
1 parent 0d2f2cc commit 55068fd
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 8 deletions.
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
16 changes: 15 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,24 @@
// Licensed under the MIT License.
import { ViewProps } from 'react-native';

export type Placement = 'top'
| 'bottom'
| 'left'
| 'right'
| 'full'
| 'top-edge-aligned-left'
| 'top-edge-aligned-right'
| 'bottom-edge-aligned-left'
| 'bottom-edge-aligned-right'
| 'left-edge-aligned-top'
| 'right-edge-aligned-top'
| 'left-edge-aligned-bottom'
| '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;
}
25 changes: 19 additions & 6 deletions vnext/src/RNTester/FlyoutExample.uwp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,32 @@
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;
}

let placementValues: string[] = [
'top',
'bottom',
'left',
'right',
'full',
'top-edge-aligned-left',
'top-edge-aligned-right',
'bottom-edge-aligned-left',
'bottom-edge-aligned-right',
'left-edge-aligned-top',
'right-edge-aligned-top',
'left-edge-aligned-bottom',
'right-edge-aligned-bottom'
]

class FlyoutExample extends React.Component<{}, IFlyoutExampleState> {

// tslint:disable-next-line:no-any
Expand All @@ -41,11 +58,7 @@ class FlyoutExample extends React.Component<{}, IFlyoutExampleState> {
<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

0 comments on commit 55068fd

Please sign in to comment.