-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp_Stack_Drawer_tabNavigation.js
118 lines (106 loc) · 3.01 KB
/
App_Stack_Drawer_tabNavigation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import React, { Component } from 'react';
import { Text, View, StyleSheet, SafeAreaView, Button, StatusBar, Platform } from 'react-native';
import { createStackNavigator, createAppContainer, createDrawerNavigator, createBottomTabNavigator } from 'react-navigation';
// import { Ionicons as Icon } from '@expo/vector-icons';
const isAndroid = Platform.OS === 'android';
class Screen1 extends React.Component {
render() {
return (
<SafeAreaView style={[styles.container, { backgroundColor: '#6a51ae' }]}>
<StatusBar
barStyle="light-content"
backgroundColor="#6a51ae"
/>
<Text style={[styles.paragraph, { color: '#fff' }]}>
Light Screen
</Text>
<Button
title="Next screen"
onPress={() => this.props.navigation.navigate('Screen2')}
color={isAndroid ? "blue" : "#fff"}
/>
</SafeAreaView>
);
}
}
class Screen2 extends React.Component {
render() {
return (
<SafeAreaView style={[styles.container, { backgroundColor: '#ecf0f1' }]}>
<StatusBar
barStyle="dark-content"
backgroundColor="#ecf0f1"
/>
<Text style={styles.paragraph}>
Dark Screen
</Text>
<Button
title="Next screen"
onPress={() => this.props.navigation.navigate('Screen1')}
/>
</SafeAreaView>
);
}
}
// const AppContainer = createAppContainer(createStackNavigator({
// Screen1: {
// screen: Screen1,
// },
// Screen2: {
// screen: Screen2,
// },
// }, {
// headerMode: 'none',
// }));
// Uncomment this area and comment out the other navigators to see a drawer example
const AppContainer = createAppContainer(createDrawerNavigator({
Screen1: {
screen: Screen1,
},
Screen2: {
screen: Screen2,
},
}));
// Uncomment this area and comment out the other navigators to see a tab example
//
// const AppContainer = createAppContainer(createBottomTabNavigator({
// Screen1: {
// screen: Screen1,
// navigationOptions: {
// tabBarOnPress: ({ previousScene, scene, jumpToIndex }) => {
// // TODO: This doesn't handle the initial render because the second screen renders last. What to do?
// StatusBar.setBarStyle('light-content');
// isAndroid && StatusBar.setBackgroundColor('#6a51ae');
// jumpToIndex(scene.index);
// },
// },
// },
// Screen2: {
// screen: Screen2,
// navigationOptions: {
// tabBarOnPress: ({ previousScene, scene, jumpToIndex }) => {
// StatusBar.setBarStyle('dark-content');
// isAndroid && StatusBar.setBackgroundColor('#ecf0f1');
// jumpToIndex(scene.index);
// },
// },
// },
// }));
export default class App extends Component {
render() {
return (
<AppContainer />
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center'
},
paragraph: {
fontSize: 18,
fontWeight: 'bold',
},
})