Files

49 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

2016-05-31 10:02:02 +02:00
import React from 'react';
import { Text } from 'react-native';
import Menu, {
2017-12-19 11:08:34 +01:00
MenuProvider,
2016-05-31 10:02:02 +02:00
MenuOptions,
MenuOption,
2016-06-15 12:08:13 +02:00
MenuTrigger,
renderers,
2016-05-31 10:02:02 +02:00
} from 'react-native-popup-menu';
2017-05-23 23:05:52 +02:00
import Icon from 'react-native-vector-icons/FontAwesome';
2016-05-31 10:02:02 +02:00
const CheckedOption = (props) => (
2017-12-04 14:55:37 +01:00
<MenuOption
value={props.value}
text={(props.checked ? '\u2713 ' : '') + props.text}
/>
2016-05-31 10:02:02 +02:00
)
2017-12-04 14:55:37 +01:00
const IconOption = ({iconName, text, value}) => (
<MenuOption value={value}>
2017-05-23 23:05:52 +02:00
<Text>
<Icon name={iconName} />
{' ' + text}
</Text>
</MenuOption>
)
2016-11-18 14:13:51 +01:00
/* You can set default renderer for all menus just once in your application: */
//Menu.setDefaultRenderer(renderers.NotAnimatedContextMenu);
2016-06-15 12:08:13 +02:00
2016-05-31 10:02:02 +02:00
const ExtensionExample = () => (
2017-12-19 11:08:34 +01:00
<MenuProvider style={{flexDirection: 'column', padding: 30}}>
2016-05-31 10:02:02 +02:00
<Text>Extensible hello world!</Text>
2016-11-18 14:13:51 +01:00
<Menu
onSelect={value => alert(`Selected number: ${value}`)}
renderer={renderers.NotAnimatedContextMenu}
>
2016-05-31 10:02:02 +02:00
<MenuTrigger text='Select option' />
<MenuOptions>
2016-11-23 13:33:54 +01:00
<CheckedOption value={1} text='One' />
<CheckedOption checked value={2} text='Two' />
2017-05-23 23:05:52 +02:00
<IconOption value={3} iconName='rocket' text='Three' />
2016-05-31 10:02:02 +02:00
</MenuOptions>
</Menu>
2017-12-19 11:08:34 +01:00
</MenuProvider>
2016-05-31 10:02:02 +02:00
);
export default ExtensionExample;