mirror of
https://github.com/status-im/react-navigation.git
synced 2025-02-25 01:28:16 +00:00
* Initial commit * Remove HybridExample (#985) * Remove HybridExample * Remove last mention of HelloHybrid * Remove console log * Fix flow and example * Fix routers api docs * Keep options in single place * chore * Fix styling * Organise miscs * Better flow type for screen options * Flow test website and add more types to options * navigationOptions instead of prevOptions makes more sense * Fixes * Fix up docs * Fix * Update route decl * Provide error when removed API is used * Remove lock * Add validators * Make StacksOverTabs config valid again * Do not return * Fix redbox
128 lines
2.7 KiB
JavaScript
128 lines
2.7 KiB
JavaScript
/**
|
|
* @flow
|
|
*/
|
|
|
|
import React from 'react';
|
|
import {
|
|
Button,
|
|
ScrollView,
|
|
} from 'react-native';
|
|
import {
|
|
StackNavigator,
|
|
TabNavigator,
|
|
} from 'react-navigation';
|
|
|
|
import Ionicons from 'react-native-vector-icons/Ionicons';
|
|
import SampleText from './SampleText';
|
|
|
|
const MyNavScreen = ({ navigation, banner }) => (
|
|
<ScrollView>
|
|
<SampleText>{banner}</SampleText>
|
|
<Button
|
|
onPress={() => navigation.navigate('Profile', { name: 'Jordan' })}
|
|
title="Go to a profile screen"
|
|
/>
|
|
<Button
|
|
onPress={() => navigation.navigate('NotifSettings')}
|
|
title="Go to notification settings"
|
|
/>
|
|
<Button
|
|
onPress={() => navigation.navigate('SettingsTab')}
|
|
title="Go to settings"
|
|
/>
|
|
<Button
|
|
onPress={() => navigation.goBack(null)}
|
|
title="Go back"
|
|
/>
|
|
</ScrollView>
|
|
);
|
|
|
|
const MyHomeScreen = ({ navigation }) => (
|
|
<MyNavScreen
|
|
banner="Home Screen"
|
|
navigation={navigation}
|
|
/>
|
|
);
|
|
|
|
const MyProfileScreen = ({ navigation }) => (
|
|
<MyNavScreen
|
|
banner={`${navigation.state.params.name}s Profile`}
|
|
navigation={navigation}
|
|
/>
|
|
);
|
|
MyProfileScreen.navigationOptions = ({ navigation }) => {
|
|
title: `${navigation.state.params.name}'s Profile!`
|
|
};
|
|
|
|
const MyNotificationsSettingsScreen = ({ navigation }) => (
|
|
<MyNavScreen
|
|
banner="Notification Settings"
|
|
navigation={navigation}
|
|
/>
|
|
);
|
|
|
|
const MySettingsScreen = ({ navigation }) => (
|
|
<MyNavScreen
|
|
banner="Settings"
|
|
navigation={navigation}
|
|
/>
|
|
);
|
|
|
|
const TabNav = TabNavigator({
|
|
MainTab: {
|
|
screen: MyHomeScreen,
|
|
path: '/',
|
|
navigationOptions: {
|
|
tabBarLabel: 'Home',
|
|
tabBarIcon: ({ tintColor, focused }) => (
|
|
<Ionicons
|
|
name={focused ? 'ios-home' : 'ios-home-outline'}
|
|
size={26}
|
|
style={{ color: tintColor }}
|
|
/>
|
|
),
|
|
},
|
|
},
|
|
SettingsTab: {
|
|
screen: MySettingsScreen,
|
|
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,
|
|
});
|
|
|
|
const StacksOverTabs = StackNavigator({
|
|
Root: {
|
|
screen: TabNav,
|
|
},
|
|
NotifSettings: {
|
|
screen: MyNotificationsSettingsScreen,
|
|
navigationOptions: {
|
|
title: 'Notification Settings',
|
|
},
|
|
},
|
|
Profile: {
|
|
screen: MyProfileScreen,
|
|
path: '/people/:name',
|
|
navigationOptions: ({ navigation }) => {
|
|
title: `${navigation.state.params.name}'s Profile!`
|
|
},
|
|
},
|
|
}, {
|
|
headerMode: 'none',
|
|
});
|
|
|
|
export default StacksOverTabs;
|