123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- /**
- * @flow
- */
- import React from 'react';
- import { ScrollView, StatusBar } from 'react-native';
- import {
- SafeAreaView,
- createStackNavigator,
- createBottomTabNavigator,
- } from 'react-navigation';
- import Ionicons from 'react-native-vector-icons/Ionicons';
- import SampleText from './SampleText';
- import { Button } from './commonComponents/ButtonWithMargin';
- 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 TabNav = createBottomTabNavigator(
- {
- MainTab: {
- screen: MyHomeScreen,
- path: '/',
- navigationOptions: {
- title: 'Welcome',
- tabBarLabel: 'Home',
- tabBarIcon: ({ tintColor, focused }) => (
- <Ionicons
- name={focused ? 'ios-home' : 'ios-home-outline'}
- size={26}
- style={{ color: tintColor }}
- />
- ),
- },
- },
- SettingsTab: {
- screen: MySettingsScreen,
- path: '/settings',
- navigationOptions: {
- title: 'Settings',
- tabBarIcon: ({ tintColor, focused }) => (
- <Ionicons
- name={focused ? 'ios-settings' : 'ios-settings-outline'}
- size={26}
- style={{ color: tintColor }}
- />
- ),
- },
- },
- },
- {
- tabBarPosition: 'bottom',
- animationEnabled: false,
- swipeEnabled: false,
- }
- );
- TabNav.navigationOptions = ({ navigation }) => {
- let { routeName } = navigation.state.routes[navigation.state.index];
- let title;
- if (routeName === 'SettingsTab') {
- title = 'Settings';
- } else if (routeName === 'MainTab') {
- title = 'Home';
- }
- return {
- title,
- };
- };
- const StacksOverTabs = createStackNavigator({
- Root: {
- screen: TabNav,
- },
- NotifSettings: {
- screen: MyNotificationsSettingsScreen,
- navigationOptions: {
- title: 'Notifications',
- },
- },
- Profile: {
- screen: MyProfileScreen,
- path: '/people/:name',
- navigationOptions: ({ navigation }) => ({
- title: `${navigation.state.params.name}'s Profile!`,
- }),
- },
- });
- export default StacksOverTabs;
|