This repository has been archived by the owner on Aug 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
135 lines (125 loc) · 3.26 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
import React from "react";
import { StatusBar } from "react-native";
import { StyleProvider, Root } from "native-base";
import getTheme from "./src/native-base-theme/components";
import material from "./src/native-base-theme/variables/material";
import {
createStackNavigator,
createAppContainer,
createSwitchNavigator
} from "react-navigation";
import { Asset } from "expo-asset";
import { AppLoading } from "expo";
import { LinearGradient } from "expo-linear-gradient";
import { Provider } from "react-redux";
import store from "./src/store";
import PatientListScreen from "./src/screens/PatientList";
import PrescriptionListScreen from "./src/screens/Prescription";
import InterventionScreen from "./src/screens/Intervention";
import AuthLoadingScreen from "./src/screens/AuthLoadingScreen";
import SignInScreen from "./src/screens/SignIn";
import NavigationService from "./src/services/NavigationService";
import theme from "./src/native-base-theme/variables/material";
const AppStack = createStackNavigator(
{
PatientListScreen: {
screen: PatientListScreen,
navigationOptions: {
header: null
}
},
PrescriptionListScreen: PrescriptionListScreen,
InterventionScreen: InterventionScreen
},
{
initialRouteName: "PatientListScreen",
defaultNavigationOptions: {
headerBackground: (
<LinearGradient
colors={[theme.brandGradientStart, theme.brandGradientEnd]}
style={{
position: "absolute",
left: 0,
right: 0,
top: 0,
bottom: 0
}}
start={[0, 0]}
end={[1, 0]}
/>
),
headerTintColor: theme.brandPrimary
}
}
);
const AuthStack = createStackNavigator({
SignIn: {
screen: SignInScreen,
navigationOptions: {
header: null
}
}
});
const AppContainer = createAppContainer(
createSwitchNavigator(
{
AuthLoading: AuthLoadingScreen,
App: AppStack,
Auth: AuthStack
},
{
initialRouteName: "AuthLoading"
}
)
);
function cacheImages(images) {
return images.map(image => {
if (typeof image === "string") {
return Image.prefetch(image);
} else {
return Asset.fromModule(image).downloadAsync();
}
});
}
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {
isReady: false
};
}
async _loadAssetsAsync() {
const imageAssets = cacheImages([
require("./assets/logo_stacked_white.png"),
require("./assets/logo_transparent.png")
]);
await Promise.all([...imageAssets]);
}
render() {
if (!this.state.isReady) {
return (
<AppLoading
startAsync={this._loadAssetsAsync}
onFinish={() => this.setState({ isReady: true })}
onError={console.warn}
/>
);
}
return (
<>
<StatusBar barStyle="dark-content" />
<Provider store={store}>
<StyleProvider style={getTheme(material)}>
<Root>
<AppContainer
ref={navigatorRef => {
NavigationService.setTopLevelNavigator(navigatorRef);
}}
/>
</Root>
</StyleProvider>
</Provider>
</>
);
}
}