-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
46 lines (41 loc) · 1.31 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
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import Splash from './src/components/Splash/Splash';
import AuthScreen from './src/components/Login';
export default class App extends React.Component {
constructor(props){
super(props)
this.state = {
isLoggedIn: false, // Is the user authenticated?
isLoading: false, // Is the user loggingIn/signinUp?
isAppReady: false // Has the app completed the login animation?
}
}
_simulateLogin = (username, password) => {
this.setState({ isLoading: true })
setTimeout(() => this.setState({ isLoggedIn: true, isLoading: false }), 1000)
}
_simulateSignup = (username, password, fullName) => {
this.setState({ isLoading: true })
setTimeout(() => this.setState({ isLoggedIn: true, isLoading: false }), 1000)
}
render() {
if (this.state.isAppReady) {
return (
<Splash
logout={() => this.setState({ isLoggedIn: false, isAppReady: false })}
/>
)
} else {
return (
<AuthScreen
login={this._simulateLogin}
signup={this._simulateSignup}
isLoggedIn={this.state.isLoggedIn}
isLoading={this.state.isLoading}
onLoginAnimationCompleted={() => this.setState({ isAppReady: true })}
/>
)
}
}
}