mirror of
https://github.com/status-im/react-navigation.git
synced 2025-02-25 01:28:16 +00:00
126 lines
2.9 KiB
JavaScript
126 lines
2.9 KiB
JavaScript
/**
|
|
* @flow
|
|
*/
|
|
|
|
import React from 'react';
|
|
import { Button, ScrollView, StatusBar } from 'react-native';
|
|
import { SafeAreaView, StackNavigator, TabNavigator } from 'react-navigation';
|
|
|
|
import Ionicons from 'react-native-vector-icons/Ionicons';
|
|
import SampleText from './SampleText';
|
|
|
|
const MyNavScreen = ({ navigation, banner }) => (
|
|
<ScrollView>
|
|
<SafeAreaView forceInset={{ horizontal: 'always' }}>
|
|
<SampleText>{banner}</SampleText>
|
|
<Button
|
|
onPress={() => navigation.navigate('Profile', { name: 'Jordan' })}
|
|
title="Open profile screen"
|
|
/>
|
|
<Button
|
|
onPress={() => navigation.navigate('NotifSettings')}
|
|
title="Open notifications screen"
|
|
/>
|
|
<Button
|
|
onPress={() => navigation.navigate('SettingsTab')}
|
|
title="Go to settings tab"
|
|
/>
|
|
<Button onPress={() => navigation.goBack(null)} title="Go back" />
|
|
</SafeAreaView>
|
|
|
|
<StatusBar barStyle="default" />
|
|
</ScrollView>
|
|
);
|
|
|
|
const MyHomeScreen = ({ navigation }) => (
|
|
<MyNavScreen banner="Home Screen" navigation={navigation} />
|
|
);
|
|
|
|
const MyProfileScreen = ({ navigation }) => (
|
|
<MyNavScreen
|
|
banner={`${navigation.state.params.name}s Profile`}
|
|
navigation={navigation}
|
|
/>
|
|
);
|
|
|
|
const MyNotificationsSettingsScreen = ({ navigation }) => (
|
|
<MyNavScreen banner="Notifications Screen" navigation={navigation} />
|
|
);
|
|
|
|
const MySettingsScreen = ({ navigation }) => (
|
|
<MyNavScreen banner="Settings Screen" navigation={navigation} />
|
|
);
|
|
|
|
const MainTab = StackNavigator({
|
|
Home: {
|
|
screen: MyHomeScreen,
|
|
path: '/',
|
|
navigationOptions: {
|
|
title: 'Welcome',
|
|
},
|
|
},
|
|
Profile: {
|
|
screen: MyProfileScreen,
|
|
path: '/people/:name',
|
|
navigationOptions: ({ navigation }) => ({
|
|
title: `${navigation.state.params.name}'s Profile!`,
|
|
}),
|
|
},
|
|
});
|
|
|
|
const SettingsTab = StackNavigator({
|
|
Settings: {
|
|
screen: MySettingsScreen,
|
|
path: '/',
|
|
navigationOptions: () => ({
|
|
title: 'Settings',
|
|
}),
|
|
},
|
|
NotifSettings: {
|
|
screen: MyNotificationsSettingsScreen,
|
|
navigationOptions: {
|
|
title: 'Notifications',
|
|
},
|
|
},
|
|
});
|
|
|
|
const StacksInTabs = TabNavigator(
|
|
{
|
|
MainTab: {
|
|
screen: MainTab,
|
|
path: '/',
|
|
navigationOptions: {
|
|
tabBarLabel: 'Home',
|
|
tabBarIcon: ({ tintColor, focused }) => (
|
|
<Ionicons
|
|
name={focused ? 'ios-home' : 'ios-home-outline'}
|
|
size={26}
|
|
style={{ color: tintColor }}
|
|
/>
|
|
),
|
|
},
|
|
},
|
|
SettingsTab: {
|
|
screen: SettingsTab,
|
|
path: '/settings',
|
|
navigationOptions: {
|
|
tabBarLabel: 'Settings',
|
|
tabBarIcon: ({ tintColor, focused }) => (
|
|
<Ionicons
|
|
name={focused ? 'ios-settings' : 'ios-settings-outline'}
|
|
size={26}
|
|
style={{ color: tintColor }}
|
|
/>
|
|
),
|
|
},
|
|
},
|
|
},
|
|
{
|
|
tabBarPosition: 'bottom',
|
|
animationEnabled: false,
|
|
swipeEnabled: false,
|
|
}
|
|
);
|
|
|
|
export default StacksInTabs;
|