-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
76 lines (67 loc) · 1.75 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
// import modules
import React from "react";
import { StyleSheet, Text, View, AsyncStorage, Platform } from "react-native";
// import components
import Register from './components/Register';
if (Platform.OS === 'ios') {Authenticated = require('./components/Authenticated').default} else {}
if (Platform.OS === 'android') {AuthenticatedAndroid = require('./components/AuthenticatedAndroid').default} else {}
// exported class
export default class App extends React.Component {
// constructor
constructor(props) {
super(props);
this.state = {
uuid: null
};
}
// component will component
componentWillMount = () => {
this.fetchStore()
}
// helper function to load uuid from local storage
fetchStore = async () => {
try {
const value = await AsyncStorage.getItem('@CompanyStore:uuid');
if (value && value.length > 0){
this.setState({uuid:value})
}
} catch (err) {
console.error(err)
}
}
// render view ---------------------------------------------------------
render () {
// uuid screen
if (this.state.uuid === null) {
return (
<View style={styles.container} >
<Register function={this.fetchStore.bind(this)}/>
</View>
)
}
// authenticated user screen ios
else if (Platform.OS === 'ios') {
return (
<View style={styles.container}>
<Authenticated uuid={this.state.uuid}/>
</View>
)
}
// authenticated user screen ios
else {
return (
<View style={styles.container}>
<AuthenticatedAndroid uuid={this.state.uuid}/>
</View>
)}
}
}
// styles
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fd7b28",
alignItems: "center",
justifyContent: "center"
}
})