-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
86 lines (73 loc) · 2.18 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
import * as React from 'react';
import {View} from 'react-native';
import { AppLoading } from 'expo';
import { Container, Text } from 'native-base';
import * as Font from 'expo-font';
import { Ionicons } from '@expo/vector-icons';
import SignIn from './src/SignIn';
import Dashboard from './src/Dashboard';
import Globals from './src/Globals'
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
const Stack = createStackNavigator();
export const AuthContext = React.createContext({dude: "light"});
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {
isReady: false,
token: null,
loggedIn: false,
newUser: false
};
}
async componentDidMount() {
console.disableYellowBox = true;
await Font.loadAsync({
Roboto: require('native-base/Fonts/Roboto.ttf'),
Roboto_medium: require('native-base/Fonts/Roboto_medium.ttf'),
...Ionicons.font,
});
this.setState({ isReady: true });
}
handleLogin = (authorizationToken) => {
this.state.token = authorizationToken;
this.flipLogin(true);
console.log(authorizationToken)
}
handleSignup = (authorizationToken) => {
this.state.token = authorizationToken;
this.flipRegister(true);
this.flipLogin(true);
}
flipLogin = (x) => {
this.setState({loggedIn : x});
}
flipRegister = (x) => {
this.setState({newUser : x});
}
render(){
return (
<View style={styles.container}>
<NavigationContainer>
<Stack.Navigator screenOptions={{
headerShown: false
}}>
{this.state.token == null ? (
<Stack.Screen name="SignIn" component={SignIn} initialParams={{authenticate : this.handleLogin, register: this.handleSignup}}/>)
:
(
<Stack.Screen name="Dashboard" component={Dashboard} initialParams={{token : this.state.token, logout: this.handleLogin}}/>
)
}
</Stack.Navigator>
</NavigationContainer>
</View>
);
}
}
const styles = {
container: {
flex: 1
},
};