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-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';
|
|
|
|
useScreens();
|
|
|
|
|
2018-08-03 21:59:12 +00:00
|
|
|
const data = [
|
|
|
|
{ component: SimpleStack, title: 'Simple', routeName: 'SimpleStack' },
|
2018-09-24 19:11:34 +00:00
|
|
|
{
|
|
|
|
component: TransparentStack,
|
|
|
|
title: 'Transparent',
|
|
|
|
routeName: 'TransparentStack',
|
|
|
|
},
|
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}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|