2017-01-26 11:49:39 -08:00
|
|
|
/* @flow */
|
|
|
|
|
|
|
|
import React from 'react';
|
2017-10-17 16:24:56 -07:00
|
|
|
import { ScreenOrientation } from 'expo';
|
|
|
|
|
|
|
|
ScreenOrientation.allow(ScreenOrientation.Orientation.ALL);
|
2017-01-26 11:49:39 -08:00
|
|
|
|
|
|
|
import {
|
|
|
|
Platform,
|
|
|
|
ScrollView,
|
|
|
|
StyleSheet,
|
|
|
|
TouchableOpacity,
|
|
|
|
Text,
|
|
|
|
View,
|
|
|
|
} from 'react-native';
|
2017-10-31 11:33:40 -07:00
|
|
|
import { SafeAreaView, StackNavigator } from 'react-navigation';
|
2017-01-26 11:49:39 -08:00
|
|
|
|
|
|
|
import Banner from './Banner';
|
|
|
|
import CustomTabs from './CustomTabs';
|
2017-09-07 04:41:41 +04:00
|
|
|
import CustomTransitioner from './CustomTransitioner';
|
2017-01-26 11:49:39 -08:00
|
|
|
import Drawer from './Drawer';
|
2017-04-06 12:25:38 -04:00
|
|
|
import TabsInDrawer from './TabsInDrawer';
|
2017-01-26 11:49:39 -08:00
|
|
|
import ModalStack from './ModalStack';
|
|
|
|
import StacksInTabs from './StacksInTabs';
|
2017-04-06 12:24:35 -04:00
|
|
|
import StacksOverTabs from './StacksOverTabs';
|
2017-01-26 11:49:39 -08:00
|
|
|
import SimpleStack from './SimpleStack';
|
|
|
|
import SimpleTabs from './SimpleTabs';
|
2017-11-20 16:16:43 -07:00
|
|
|
import TabAnimations from './TabAnimations';
|
2017-01-26 11:49:39 -08:00
|
|
|
|
|
|
|
const ExampleRoutes = {
|
|
|
|
SimpleStack: {
|
|
|
|
name: 'Stack Example',
|
|
|
|
description: 'A card stack',
|
|
|
|
screen: SimpleStack,
|
|
|
|
},
|
|
|
|
SimpleTabs: {
|
|
|
|
name: 'Tabs Example',
|
|
|
|
description: 'Tabs following platform conventions',
|
|
|
|
screen: SimpleTabs,
|
|
|
|
},
|
|
|
|
Drawer: {
|
|
|
|
name: 'Drawer Example',
|
|
|
|
description: 'Android-style drawer navigation',
|
|
|
|
screen: Drawer,
|
|
|
|
},
|
2017-04-06 12:25:38 -04:00
|
|
|
TabsInDrawer: {
|
|
|
|
name: 'Drawer + Tabs Example',
|
|
|
|
description: 'A drawer combined with tabs',
|
|
|
|
screen: TabsInDrawer,
|
|
|
|
},
|
2017-01-26 11:49:39 -08:00
|
|
|
CustomTabs: {
|
|
|
|
name: 'Custom Tabs',
|
|
|
|
description: 'Custom tabs with tab router',
|
|
|
|
screen: CustomTabs,
|
|
|
|
},
|
2017-09-07 04:41:41 +04:00
|
|
|
CustomTransitioner: {
|
|
|
|
name: 'Custom Transitioner',
|
|
|
|
description: 'Custom transitioner with stack router',
|
|
|
|
screen: CustomTransitioner,
|
|
|
|
},
|
2017-01-26 11:49:39 -08:00
|
|
|
ModalStack: {
|
2017-10-31 11:33:40 -07:00
|
|
|
name:
|
|
|
|
Platform.OS === 'ios'
|
|
|
|
? 'Modal Stack Example'
|
|
|
|
: 'Stack with Dynamic Header',
|
|
|
|
description:
|
|
|
|
Platform.OS === 'ios'
|
|
|
|
? 'Stack navigation with modals'
|
|
|
|
: 'Dynamically showing and hiding the header',
|
2017-01-26 11:49:39 -08:00
|
|
|
screen: ModalStack,
|
|
|
|
},
|
|
|
|
StacksInTabs: {
|
|
|
|
name: 'Stacks in Tabs',
|
|
|
|
description: 'Nested stack navigation in tabs',
|
|
|
|
screen: StacksInTabs,
|
|
|
|
},
|
2017-04-06 12:24:35 -04:00
|
|
|
StacksOverTabs: {
|
|
|
|
name: 'Stacks over Tabs',
|
|
|
|
description: 'Nested stack navigation that pushes on top of tabs',
|
|
|
|
screen: StacksOverTabs,
|
|
|
|
},
|
2017-01-26 11:49:39 -08:00
|
|
|
LinkStack: {
|
|
|
|
name: 'Link in Stack',
|
|
|
|
description: 'Deep linking into a route in stack',
|
|
|
|
screen: SimpleStack,
|
|
|
|
path: 'people/Jordan',
|
|
|
|
},
|
|
|
|
LinkTabs: {
|
|
|
|
name: 'Link to Settings Tab',
|
|
|
|
description: 'Deep linking into a route in tab',
|
|
|
|
screen: SimpleTabs,
|
|
|
|
path: 'settings',
|
|
|
|
},
|
2017-11-20 16:16:43 -07:00
|
|
|
TabAnimations: {
|
|
|
|
name: 'Animated Tabs Example',
|
|
|
|
description: 'Tab transitions have custom animations',
|
|
|
|
screen: TabAnimations,
|
|
|
|
},
|
2017-01-26 11:49:39 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
const MainScreen = ({ navigation }) => (
|
2017-10-31 11:33:40 -07:00
|
|
|
<ScrollView style={{ flex: 1 }} contentInsetAdjustmentBehavior="automatic">
|
2017-01-26 11:49:39 -08:00
|
|
|
<Banner />
|
2017-05-14 12:14:12 -07:00
|
|
|
{Object.keys(ExampleRoutes).map((routeName: string) => (
|
2017-01-26 11:49:39 -08:00
|
|
|
<TouchableOpacity
|
|
|
|
key={routeName}
|
|
|
|
onPress={() => {
|
|
|
|
const { path, params, screen } = ExampleRoutes[routeName];
|
|
|
|
const { router } = screen;
|
|
|
|
const action = path && router.getActionForPathAndParams(path, params);
|
|
|
|
navigation.navigate(routeName, {}, action);
|
|
|
|
}}
|
|
|
|
>
|
2017-10-31 11:33:40 -07:00
|
|
|
<SafeAreaView
|
|
|
|
style={styles.itemContainer}
|
|
|
|
forceInset={{ vertical: 'never' }}
|
|
|
|
>
|
|
|
|
<View style={styles.item}>
|
|
|
|
<Text style={styles.title}>{ExampleRoutes[routeName].name}</Text>
|
|
|
|
<Text style={styles.description}>
|
|
|
|
{ExampleRoutes[routeName].description}
|
|
|
|
</Text>
|
|
|
|
</View>
|
|
|
|
</SafeAreaView>
|
2017-01-26 11:49:39 -08:00
|
|
|
</TouchableOpacity>
|
2017-05-14 12:14:12 -07:00
|
|
|
))}
|
2017-01-26 11:49:39 -08:00
|
|
|
</ScrollView>
|
|
|
|
);
|
|
|
|
|
2017-05-14 12:14:12 -07:00
|
|
|
const AppNavigator = StackNavigator(
|
|
|
|
{
|
|
|
|
...ExampleRoutes,
|
|
|
|
Index: {
|
|
|
|
screen: MainScreen,
|
|
|
|
},
|
2017-01-26 11:49:39 -08:00
|
|
|
},
|
2017-05-14 12:14:12 -07:00
|
|
|
{
|
|
|
|
initialRouteName: 'Index',
|
|
|
|
headerMode: 'none',
|
2017-01-26 11:49:39 -08:00
|
|
|
|
2017-05-14 12:14:12 -07:00
|
|
|
/*
|
2017-01-26 11:49:39 -08:00
|
|
|
* Use modal on iOS because the card mode comes from the right,
|
|
|
|
* which conflicts with the drawer example gesture
|
|
|
|
*/
|
2017-05-14 12:14:12 -07:00
|
|
|
mode: Platform.OS === 'ios' ? 'modal' : 'card',
|
|
|
|
}
|
|
|
|
);
|
2017-01-26 11:49:39 -08:00
|
|
|
|
|
|
|
export default () => <AppNavigator />;
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
item: {
|
|
|
|
paddingHorizontal: 16,
|
|
|
|
paddingVertical: 12,
|
2017-10-31 11:33:40 -07:00
|
|
|
},
|
|
|
|
itemContainer: {
|
|
|
|
backgroundColor: '#fff',
|
2017-01-26 11:49:39 -08:00
|
|
|
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
|
|
borderBottomColor: '#ddd',
|
|
|
|
},
|
|
|
|
image: {
|
|
|
|
width: 120,
|
|
|
|
height: 120,
|
|
|
|
alignSelf: 'center',
|
|
|
|
marginBottom: 20,
|
|
|
|
resizeMode: 'contain',
|
|
|
|
},
|
|
|
|
title: {
|
|
|
|
fontSize: 16,
|
|
|
|
fontWeight: 'bold',
|
|
|
|
color: '#444',
|
|
|
|
},
|
|
|
|
description: {
|
|
|
|
fontSize: 13,
|
|
|
|
color: '#999',
|
|
|
|
},
|
|
|
|
});
|