2018-08-03 21:59:12 +00:00
|
|
|
import React from 'react';
|
|
|
|
import Expo from 'expo';
|
|
|
|
import { FlatList } from 'react-native';
|
|
|
|
import { createSwitchNavigator } from 'react-navigation';
|
|
|
|
import { createStackNavigator } from 'react-navigation-stack';
|
|
|
|
import { ListSection, Divider } from 'react-native-paper';
|
2018-09-14 10:48:59 +00:00
|
|
|
|
2018-08-03 21:59:12 +00:00
|
|
|
import SimpleStack from './src/SimpleStack';
|
2018-09-24 19:11:34 +00:00
|
|
|
import TransparentStack from './src/TransparentStack';
|
2018-09-24 23:51:55 +00:00
|
|
|
import ModalStack from './src/ModalStack';
|
2018-09-25 00:53:22 +00:00
|
|
|
import GestureInteraction from './src/GestureInteraction';
|
2018-08-03 21:59:12 +00:00
|
|
|
|
2018-09-14 10:48:59 +00:00
|
|
|
// Comment the following two lines to stop using react-native-screens
|
|
|
|
import { useScreens } from 'react-native-screens';
|
2018-09-26 00:00:19 +00:00
|
|
|
// useScreens();
|
2018-09-14 10:48:59 +00:00
|
|
|
|
2018-08-03 21:59:12 +00:00
|
|
|
const data = [
|
|
|
|
{ component: SimpleStack, title: 'Simple', routeName: 'SimpleStack' },
|
2018-09-24 23:51:55 +00:00
|
|
|
{ component: ModalStack, title: 'Modal', routeName: 'ModalStack' },
|
2018-09-24 19:11:34 +00:00
|
|
|
{
|
|
|
|
component: TransparentStack,
|
|
|
|
title: 'Transparent',
|
|
|
|
routeName: 'TransparentStack',
|
|
|
|
},
|
2018-09-25 00:53:22 +00:00
|
|
|
{ component: GestureInteraction, title: 'Gesture Interaction', routeName: 'GestureInteraction' },
|
2018-08-03 21:59:12 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
class Home extends React.Component {
|
|
|
|
static navigationOptions = {
|
|
|
|
title: 'Examples',
|
|
|
|
};
|
|
|
|
|
|
|
|
_renderItem = ({ item }) => (
|
|
|
|
<ListSection.Item
|
|
|
|
title={item.title}
|
|
|
|
onPress={() => this.props.navigation.navigate(item.routeName)}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
_keyExtractor = item => item.routeName;
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<FlatList
|
|
|
|
ItemSeparatorComponent={Divider}
|
|
|
|
renderItem={this._renderItem}
|
|
|
|
keyExtractor={this._keyExtractor}
|
|
|
|
data={data}
|
2018-09-24 23:51:55 +00:00
|
|
|
style={{ backgroundColor: '#fff' }}
|
2018-08-03 21:59:12 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const App = createSwitchNavigator({
|
|
|
|
Home: createStackNavigator({ Home }),
|
|
|
|
...data.reduce((acc, it) => {
|
|
|
|
acc[it.routeName] = {
|
|
|
|
screen: it.component,
|
|
|
|
navigationOptions: {
|
|
|
|
title: it.title,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
return acc;
|
|
|
|
}, {}),
|
|
|
|
});
|
|
|
|
|
|
|
|
Expo.registerRootComponent(App);
|