-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
170 lines (159 loc) · 3.65 KB
/
App.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/
import React, {Component, YellowBox} from 'react';
import {Platform, StyleSheet, Text, View, Button, Image, CameraRoll} from 'react-native';
import {TabBarBottom, createStackNavigator, TabNavigator} from 'react-navigation';
import Home from "./screens/home";
import Me from "./screens/me";
import Diary from "./screens/diary";
import Chat from "./screens/chat";
import Plan from "./screens/plan";
import Login from "./screens/login";
import Register from "./screens/register";
import ImageBrowser from "./screens/imageBrowser";
import About from "./screens/about"
const HomeTab = createStackNavigator(
{
HomeTab: {
screen: Home,
navigationOptions: {
header: null
}
}
}
)
const MeTab = createStackNavigator(
{
MeTab: {
screen: Me,
navigationOptions: {
header: null
}
},
About: {
screen: About
}
}
)
const DiaryTab = createStackNavigator(
{
DiaryTab: {
screen: Diary,
navigationOptions: {
header: null
}
},
ImageBrowser: {
screen: ImageBrowser
}
},
{
initialRouteName: "DiaryTab",
}
)
const ChatTab = createStackNavigator(
{
ChatTab: {
screen: Chat,
navigationOptions: {
header: null
}
}
}
)
const PlanTab = createStackNavigator(
{
PlanTab: {
screen: Plan,
navigationOptions: {
header: null
}
}
}
)
const LoginTab = createStackNavigator(
{
Login: {
screen: Login,
navigationOptions: {
header: null
}
},
Register: {
screen: Register
}
},
{
initialRouteName: "Login",
}
)
const RootTab = TabNavigator (
{
Discover: HomeTab,
Plan: PlanTab,
Diary: DiaryTab,
Chat: ChatTab,
Me: MeTab,
},
{
initialRouteName: "Discover",
navigationOptions: ({ navigation }) => {
const { routeName, routes } = navigation.state;
let params = routes && routes[1] && routes[1].params;
switch(routeName) {
case "Discover":
var icon = require('./res/icons/Discover.png')
break;
case "Plan":
var icon =require('./res/icons/Plan.png')
break;
case "Diary":
var icon = require('./res/icons/Diary.png')
break;
case "Chat":
var icon =require('./res/icons/Chat.png')
break;
case "Me":
var icon = require('./res/icons/Me.png')
}
return {
tabBarIcon: ({ focused, tintColor }) => {
return ( <Image
style={{width: '100%',
height: 30,
tintColor: tintColor}}
source={icon}
resizeMode="contain"
/> )
},
tabBarVisible:
params && params.hideTabBar != null ? !params.hideTabBar : true,
swipeEnabled:
params && params.hideTabBar != null ? !params.hideTabBar : true
};
},
tabBarComponent: TabBarBottom,
tabBarPosition: "bottom",
animationEnabled: true,
swipeEnabled: true
}
)
export default class App extends React.Component {
constructor(props, context) {
super(props, context);
this.state = {loggedIn: false};
this.login = this.login.bind(this);
this.logout = this.logout.bind(this);
}
login = () => {this.setState({loggedIn: true})}
logout = () => {this.setState({loggedIn: false})}
render() {
console.disableYellowBox = true;
return (this.state.loggedIn ? <RootTab /> : <LoginTab screenProps={this.login}/> );
}
}