-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
59 lines (56 loc) · 1.91 KB
/
App.tsx
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
import 'react-native-gesture-handler';
import {StyleSheet, View} from 'react-native';
import LoginWebView from "./src/screens/LoginWebView";
import React, {useEffect} from "react";
import {SafeAreaProvider, SafeAreaView} from 'react-native-safe-area-context';
import AppNavigation from "./src/routes";
import {NavigationContainer} from "@react-navigation/native";
import {useSnapshot} from "valtio/react";
import {appStore} from "./src/store/appStore";
import WebViewManager from "./src/components/WebViewManager";
import {RootSiblingParent} from 'react-native-root-siblings';
import Splash from "./src/components/Splash";
import UpdateModal from "./src/components/UpdateModal";
import {checkUpdate} from "./src/utils";
const App: React.FC = () => {
const {webViewShow, webViewReady, updateProps} = useSnapshot(appStore)
useEffect(()=>{
checkUpdate().then(res => {
if(res.hasUpdate){
appStore.showUpdateModal(res.data, `${res.data.version}更新`)
}
})
},[])
return (
<RootSiblingParent>
<SafeAreaProvider>
<NavigationContainer>
<SafeAreaView style={styles.container}>
<UpdateModal message={updateProps.message} title={updateProps.title} visible={updateProps.visible} close={appStore.closeUpdateModal}/>
<View style={styles.hide}>
<WebViewManager/>
</View>
<View style={[styles.container, webViewShow ? styles.show : styles.hide]}>
<LoginWebView/>
</View>
<View style={[styles.container, webViewShow ? styles.hide : styles.show]}>
{webViewReady ? <AppNavigation/> : <Splash/>}
</View>
</SafeAreaView>
</NavigationContainer>
</SafeAreaProvider>
</RootSiblingParent>
);
}
const styles = StyleSheet.create({
container: {
flex: 1
},
hide: {
display: "none"
},
show: {
display: "flex"
}
});
export default App;