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

feat: Menu component #485

Merged
merged 22 commits into from
Mar 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2f2c8ce
feat: Menu component
iyadthayyil Aug 8, 2018
558500d
feat: Menu component
iyadthayyil Aug 8, 2018
eff98cd
fix: fixed flow errors
iyadthayyil Aug 8, 2018
3a6e7b6
fix: import path which was broke during rebase
waquidvp Feb 17, 2019
e0c1adc
fix: moved example to new 'Examples' directory
waquidvp Feb 17, 2019
226a73b
fix: remove unneeded AnimatedSurface
waquidvp Feb 17, 2019
e93581b
feat: initial attempt at creating ts typings
waquidvp Feb 17, 2019
7107764
fix: import order to be in alphabetical order
waquidvp Feb 18, 2019
0d23148
fix: moved docs markup to be above the class definition
waquidvp Feb 18, 2019
cb5459a
fix: update docs wording for more clarity
waquidvp Feb 18, 2019
dd97efc
docs: more fixes to use the correct wording for clarity
waquidvp Feb 18, 2019
7e7d0a8
fix: add some constants to make values more clear
waquidvp Feb 19, 2019
52582e8
fix: use consts for disabled colors
waquidvp Feb 19, 2019
42e79ec
fix: change prop name from button to anchor
waquidvp Feb 20, 2019
19bf0ba
fix: use any instead of mixed in type definition
waquidvp Feb 20, 2019
6c7f932
fix: use the correct types in the definitions
waquidvp Feb 21, 2019
c448c7c
fix: use simpler turnery operation so 'right' or 'left' won't be empty
waquidvp Feb 21, 2019
5ac0fad
docs: added comments for more clarity on origin of constants
waquidvp Feb 21, 2019
b7456b9
use portal
satya164 Mar 2, 2019
1e13446
fix: add status bar padding to top
waquidvp Mar 6, 2019
6ea16bb
refactor: remove inner view
waquidvp Mar 10, 2019
9adb5d0
fix: add status bar height for all cases
waquidvp Mar 10, 2019
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
Binary file added docs/assets/screenshots/menu-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/screenshots/menu-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions example/src/ExampleList.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import FABExample from './Examples/FABExample';
import IconButtonExample from './Examples/IconButtonExample';
import ListAccordionExample from './Examples/ListAccordionExample';
import ListSectionExample from './Examples/ListSectionExample';
import MenuExample from './Examples/MenuExample';
import ProgressBarExample from './Examples/ProgressBarExample';
import RadioButtonExample from './Examples/RadioButtonExample';
import RadioButtonGroupExample from './Examples/RadioButtonGroupExample';
Expand Down Expand Up @@ -56,6 +57,7 @@ export const examples = {
iconButton: IconButtonExample,
listAccordion: ListAccordionExample,
listSection: ListSectionExample,
menu: MenuExample,
progressbar: ProgressBarExample,
radio: RadioButtonExample,
radioGroup: RadioButtonGroupExample,
Expand Down
119 changes: 119 additions & 0 deletions example/src/Examples/MenuExample.js
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);
Loading