add example with menu inside the flatlist

This commit is contained in:
Stanislav Miklik 2018-07-17 16:55:38 +02:00
parent d171f462e6
commit 5757cfdbc8
2 changed files with 45 additions and 0 deletions

View File

@ -14,6 +14,7 @@ import TouchableExample from './TouchableExample';
import MenuMethodsExample from './MenuMethodsExample'; import MenuMethodsExample from './MenuMethodsExample';
import CloseOnBackExample from './CloseOnBackExample'; import CloseOnBackExample from './CloseOnBackExample';
import FlatListExample from './FlatListExample'; import FlatListExample from './FlatListExample';
import InFlatListExample from './InFlatListExample';
import PopoverExample from './PopoverExample'; import PopoverExample from './PopoverExample';
const demos = [ const demos = [
@ -30,6 +31,7 @@ const demos = [
// { Component: NavigatorExample, name: 'Example with react-native-router-flux' }, // { Component: NavigatorExample, name: 'Example with react-native-router-flux' },
{ Component: CloseOnBackExample, name: 'Close on back button press example' }, { Component: CloseOnBackExample, name: 'Close on back button press example' },
{ Component: FlatListExample, name: 'Using FlatList' }, { Component: FlatListExample, name: 'Using FlatList' },
{ Component: InFlatListExample, name: 'Menu in FlatList' },
{ Component: PopoverExample, name: 'Popover renderer' }, { Component: PopoverExample, name: 'Popover renderer' },
]; ];

View File

@ -0,0 +1,43 @@
import React, { Component } from 'react';
import { FlatList, Alert, StyleSheet } from 'react-native';
import {
MenuProvider,
Menu,
MenuTrigger,
MenuOptions,
MenuOption,
} from 'react-native-popup-menu';
const data = new Array(100)
.fill(0)
.map((a, i) => ({ key: '' + i, value: 'item' + i }));
export default class App extends Component {
render() {
return (
<MenuProvider style={styles.container}>
<FlatList
data={data}
renderItem={({ item }) => (
<Menu onSelect={value => Alert.alert(value)}>
<MenuTrigger text={'Select option ' + item.value} />
<MenuOptions>
<MenuOption value="A" text="A" />
<MenuOption value="B" text="B" />
<MenuOption value="C" text="C" />
</MenuOptions>
</Menu>
)}
style={{ height: 200 }}
/>
</MenuProvider>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
paddingTop: 20,
},
});