2017-01-26 11:49:39 -08:00
|
|
|
/**
|
|
|
|
* @flow
|
|
|
|
*/
|
|
|
|
|
|
|
|
import React from 'react';
|
2017-05-14 12:14:12 -07:00
|
|
|
import { Button, ScrollView, Text } from 'react-native';
|
|
|
|
import { StackNavigator } from 'react-navigation';
|
2017-01-26 11:49:39 -08:00
|
|
|
import SampleText from './SampleText';
|
|
|
|
|
|
|
|
const MyNavScreen = ({ navigation, banner }) => (
|
|
|
|
<ScrollView>
|
|
|
|
<SampleText>{banner}</SampleText>
|
|
|
|
<Button
|
|
|
|
onPress={() => navigation.navigate('Profile', { name: 'Jane' })}
|
|
|
|
title="Go to a profile screen"
|
|
|
|
/>
|
|
|
|
<Button
|
|
|
|
onPress={() => navigation.navigate('HeaderTest')}
|
|
|
|
title="Go to a header toggle screen"
|
|
|
|
/>
|
2017-05-14 12:14:12 -07:00
|
|
|
{navigation.state.routeName === 'HeaderTest' &&
|
|
|
|
<Button
|
|
|
|
title="Toggle Header"
|
|
|
|
onPress={() =>
|
|
|
|
navigation.setParams({
|
|
|
|
headerVisible: !navigation.state.params ||
|
|
|
|
!navigation.state.params.headerVisible,
|
|
|
|
})}
|
|
|
|
/>}
|
|
|
|
<Button onPress={() => navigation.goBack(null)} title="Go back" />
|
2017-01-26 11:49:39 -08:00
|
|
|
</ScrollView>
|
|
|
|
);
|
|
|
|
|
|
|
|
const MyHomeScreen = ({ navigation }) => (
|
2017-05-14 12:14:12 -07:00
|
|
|
<MyNavScreen banner="Home Screen" navigation={navigation} />
|
2017-01-26 11:49:39 -08:00
|
|
|
);
|
|
|
|
MyHomeScreen.navigationOptions = {
|
|
|
|
title: 'Welcome',
|
|
|
|
};
|
|
|
|
|
|
|
|
const MyProfileScreen = ({ navigation }) => (
|
|
|
|
<MyNavScreen
|
|
|
|
banner={`${navigation.state.params.name}'s Profile`}
|
|
|
|
navigation={navigation}
|
|
|
|
/>
|
|
|
|
);
|
2017-04-13 00:49:08 +02:00
|
|
|
MyProfileScreen.navigationOptions = ({ navigation }) => ({
|
|
|
|
title: `${navigation.state.params.name}'s Profile!`,
|
|
|
|
});
|
2017-01-26 11:49:39 -08:00
|
|
|
|
2017-05-14 12:14:12 -07:00
|
|
|
const ProfileNavigator = StackNavigator(
|
|
|
|
{
|
|
|
|
Home: {
|
|
|
|
screen: MyHomeScreen,
|
|
|
|
},
|
|
|
|
Profile: {
|
|
|
|
path: 'people/:name',
|
|
|
|
screen: MyProfileScreen,
|
|
|
|
},
|
2017-04-13 18:28:47 +02:00
|
|
|
},
|
2017-05-14 12:14:12 -07:00
|
|
|
{
|
|
|
|
navigationOptions: {
|
|
|
|
header: null,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|
2017-04-13 18:28:47 +02:00
|
|
|
|
2017-01-26 11:49:39 -08:00
|
|
|
const MyHeaderTestScreen = ({ navigation }) => (
|
2017-05-14 12:14:12 -07:00
|
|
|
<MyNavScreen banner={`Full screen view`} navigation={navigation} />
|
2017-01-26 11:49:39 -08:00
|
|
|
);
|
2017-04-28 12:58:13 +02:00
|
|
|
MyHeaderTestScreen.navigationOptions = ({ navigation }) => {
|
2017-05-14 12:14:12 -07:00
|
|
|
const headerVisible =
|
|
|
|
navigation.state.params && navigation.state.params.headerVisible;
|
2017-04-13 00:49:08 +02:00
|
|
|
return {
|
2017-04-28 12:58:13 +02:00
|
|
|
header: headerVisible ? undefined : null,
|
2017-01-26 11:49:39 -08:00
|
|
|
title: 'Now you see me',
|
2017-04-13 00:49:08 +02:00
|
|
|
};
|
2017-01-26 11:49:39 -08:00
|
|
|
};
|
|
|
|
|
2017-05-14 12:14:12 -07:00
|
|
|
const ModalStack = StackNavigator(
|
|
|
|
{
|
|
|
|
Home: {
|
|
|
|
screen: MyHomeScreen,
|
|
|
|
},
|
|
|
|
ProfileNavigator: {
|
|
|
|
screen: ProfileNavigator,
|
|
|
|
},
|
|
|
|
HeaderTest: { screen: MyHeaderTestScreen },
|
2017-01-26 11:49:39 -08:00
|
|
|
},
|
2017-05-14 12:14:12 -07:00
|
|
|
{
|
|
|
|
mode: 'modal',
|
|
|
|
}
|
|
|
|
);
|
2017-01-26 11:49:39 -08:00
|
|
|
|
|
|
|
export default ModalStack;
|