-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
117fe47
commit 0c5371a
Showing
9 changed files
with
588 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/* @flow */ | ||
|
||
import * as React from 'react'; | ||
import { View, StyleSheet, Platform } from 'react-native'; | ||
import { | ||
Menu, | ||
Appbar, | ||
Divider, | ||
Button, | ||
withTheme, | ||
type Theme, | ||
} from 'react-native-paper'; | ||
|
||
type State = { | ||
visible1: boolean, | ||
visible2: boolean, | ||
}; | ||
|
||
type Props = { | ||
theme: Theme, | ||
navigation: any, | ||
}; | ||
|
||
const MORE_ICON = Platform.OS === 'ios' ? 'more-horiz' : 'more-vert'; | ||
|
||
class MenuExample extends React.Component<Props, State> { | ||
static navigationOptions = { | ||
header: null, | ||
}; | ||
|
||
state = { | ||
visible1: false, | ||
visible2: false, | ||
}; | ||
|
||
static title = 'Menu'; | ||
|
||
_openMenu1 = () => this.setState({ visible1: true }); | ||
_openMenu2 = () => this.setState({ visible2: true }); | ||
|
||
_closeMenu1 = () => this.setState({ visible1: false }); | ||
_closeMenu2 = () => this.setState({ visible2: false }); | ||
|
||
render() { | ||
const { | ||
theme: { | ||
colors: { background }, | ||
}, | ||
} = this.props; | ||
|
||
return ( | ||
<View style={styles.screen}> | ||
<Appbar.Header> | ||
<Appbar.BackAction onPress={() => this.props.navigation.goBack()} /> | ||
<Appbar.Content title="Menu" /> | ||
<Menu | ||
visible={this.state.visible1} | ||
onDismiss={this._closeMenu1} | ||
anchor={ | ||
<Appbar.Action | ||
icon={MORE_ICON} | ||
color="white" | ||
onPress={this._openMenu1} | ||
/> | ||
} | ||
> | ||
<Menu.Item onPress={() => {}} title="Undo" /> | ||
<Menu.Item onPress={() => {}} title="Redo" /> | ||
<Divider /> | ||
<Menu.Item onPress={() => {}} title="Cut" disabled /> | ||
<Menu.Item onPress={() => {}} title="Copy" disabled /> | ||
<Menu.Item onPress={() => {}} title="Paste" /> | ||
</Menu> | ||
</Appbar.Header> | ||
<View style={[styles.container, { backgroundColor: background }]}> | ||
<Menu | ||
visible={this.state.visible2} | ||
onDismiss={this._closeMenu2} | ||
anchor={ | ||
<Button mode="outlined" onPress={this._openMenu2}> | ||
Menu with icons | ||
</Button> | ||
} | ||
> | ||
<Menu.Item icon="undo" onPress={() => {}} title="Undo" /> | ||
<Menu.Item icon="redo" onPress={() => {}} title="Redo" /> | ||
<Divider /> | ||
<Menu.Item | ||
icon="content-cut" | ||
onPress={() => {}} | ||
title="Cut" | ||
disabled | ||
/> | ||
<Menu.Item | ||
icon="content-copy" | ||
onPress={() => {}} | ||
title="Copy" | ||
disabled | ||
/> | ||
<Menu.Item icon="content-paste" onPress={() => {}} title="Paste" /> | ||
</Menu> | ||
</View> | ||
</View> | ||
); | ||
} | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
screen: { | ||
flex: 1, | ||
}, | ||
container: { | ||
flex: 1, | ||
alignItems: 'center', | ||
paddingTop: 48, | ||
}, | ||
}); | ||
|
||
export default withTheme(MenuExample); |
Oops, something went wrong.