123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- /**
- * @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 MainTab = createStackNavigator({
- Home: {
- screen: MyHomeScreen,
- path: '/',
- navigationOptions: {
- title: 'Welcome',
- },
- },
- Profile: {
- screen: MyProfileScreen,
- path: '/people/:name',
- navigationOptions: ({ navigation }) => ({
- title: `${navigation.state.params.name}'s Profile!`,
- }),
- },
- });
- const SettingsTab = createStackNavigator({
- Settings: {
- screen: MySettingsScreen,
- path: '/',
- navigationOptions: () => ({
- title: 'Settings',
- }),
- },
- NotifSettings: {
- screen: MyNotificationsSettingsScreen,
- navigationOptions: {
- title: 'Notifications',
- },
- },
- });
- const StacksInTabs = createBottomTabNavigator(
- {
- 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 }}
- />
- ),
- },
- },
- },
- {
- tabBarOptions: {
- showLabel: false,
- },
- }
- );
- export default StacksInTabs;
|