-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
158 lines (127 loc) · 3.73 KB
/
App.js
File metadata and controls
158 lines (127 loc) · 3.73 KB
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
import React from 'react';
// IMPORT REACT NATIVE
import { StyleSheet,Text, TextInput, Button } from 'react-native';
// IMPORT COMPOMENT
import LoginComponent from './src/components/login/LoginComponent';
// IMPORT LIBRARY
import {createAppContainer} from 'react-navigation';
import {createMaterialBottomTabNavigator} from 'react-navigation-material-bottom-tabs';
// IMPORT TAB NAVIGATOR
import * as TabNavigatorRender from './src/navigator/TabNavigator';
// IMPORT COLORS
import * as COLORS from './src/constants/Colors';
// IMPORT PARAMETER
import * as PARAMETER from './src/constants/Parameter';
// IMPORT REDUX
import {Provider} from 'react-redux';
import store from './src/store';
// IMPORT PUSH NOTIFICATION
import { registerForPushNotificationsAsync } from './src/services/Notification';
import * as Notifications from 'expo-notifications';
// IMPORT EXPO FONT
import * as Font from 'expo-font';
// GLOBAL PROPS
import {
setCustomTextInput,
setCustomText
} from 'react-native-global-props';
export default class App extends React.Component {
state = {
navigator: null,
selectedTabnavigator: null,
loading: false,
user: {},
tokenNotification: ''
}
async componentDidMount() {
await Font.loadAsync({
'quick-sand': require('./src/assets/fonts/Quicksand.ttf'),
'quick-sand-bold': require('./src/assets/fonts/Quicksand-Bold.ttf')
});
let token = await registerForPushNotificationsAsync()
this.setState({tokenNotification: token})
Notifications.addNotificationReceivedListener(this.handleNotifications)
}
handleNotifications = (notification)=> {
// console.log(notification)
// alert(JSON.stringify(notification))
}
// LOGIN
login = (user) => {
// this.setState({
// user: user,
// loading: true
// })
console.log(user)
this.setState({
navigator: user.role,
selectedTabnavigator: user.role
})
}
// Navigator
Navigator() {
const NavigatorStudent = createAppContainer(createMaterialBottomTabNavigator(
TabNavigatorRender.STUDENT,
{
initialRouteName: 'Home',
activeColor: COLORS.MAIN_PRIMARY,
inactiveColor: COLORS.LIGHT_HIGHT,
barStyle: { backgroundColor: COLORS.LIGHT },
defaultNavigationOptions: {
headerTitleStyle: {
fontFamily: PARAMETER.FONT_BOLD_MAIN,
color: COLORS.LIGHT
},
}
}
))
// return <NavigatorStudent />
const NavigatorTeacher = createAppContainer(createMaterialBottomTabNavigator(
TabNavigatorRender.TEACHER,
{
initialRouteName: 'Home',
activeColor: COLORS.MAIN_PRIMARY,
inactiveColor: COLORS.LIGHT_HIGHT,
barStyle: { backgroundColor: COLORS.LIGHT },
}
))
// return <NavigatorTeacher />
if (this.state.selectedTabnavigator == PARAMETER.STUDENT_ROLE){
return <NavigatorStudent />
}
return <NavigatorTeacher />
}
render () {
if (this.state.navigator == null) {
return (
<Provider store = {store}>
<LoginComponent
loading = {this.state.loading}
tokenNotification={this.state.tokenNotification}
loginFunction = { this.login }
/>
{/* <Button
title="SEND NOTI"
onPress={()=>{this.sendPushNotification(this.state.tokenNotification)}}
>
</Button>
<TextInput value={ this.state.tokenNotification } /> */}
</Provider>
)
}
return (
<Provider store = {store}>
{ this.Navigator() }
</Provider>
)
}
}
const styles = StyleSheet.create({
ProviderApp: {
},
button: {
flex: 1,
justifyContent: 'center',
alignItems: 'center'
}
});