forked from czy0729/Bangumi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.android.tsx
executable file
·81 lines (71 loc) · 2.09 KB
/
App.android.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* @Author: czy0729
* @Date: 2019-03-30 19:25:19
* @Last Modified by: czy0729
* @Last Modified time: 2022-08-30 21:48:31
*/
import '@utils/thirdParty/stable-sort'
import 'react-native-gesture-handler'
import React, { useEffect } from 'react'
import { LogBox } from 'react-native'
import { enableScreens } from 'react-native-screens'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import Provider from '@ant-design/react-native/lib/provider'
import Stacks from '@src/navigations'
import { DEV, NavigationContainer, DeepLink, BackAndroid } from '@components'
import { AppCommon } from '@_'
import { _ } from '@stores'
import {
useCachedResources,
useKeepAwake,
useOrientation,
useMount,
useErrorHandlerAndroid,
useGlobalMount,
useDimensions
} from '@utils/hooks'
import { androidKeyboardAdjust } from '@utils/ui'
import { WSA } from '@constants'
import theme from '@styles/theme'
LogBox.ignoreAllLogs(true)
export default function App() {
// 加载图标等资源
const isLoadingComplete = useCachedResources()
// 开发环境保持常亮状态
useKeepAwake()
// 全局致命错误捕捉
useErrorHandlerAndroid()
// 获取水平状态, 只有平板允许横屏, 手机锁竖屏
const orientation = useOrientation()
useEffect(() => {
_.toggleOrientation(orientation)
}, [orientation])
// 键盘模式设置为不调整画面大小, 需要动态改变的在页面内自行设置
useMount(() => {
enableScreens(false)
androidKeyboardAdjust('setAdjustPan')
})
// App启动稳定后统一做的操作
useGlobalMount()
// WSA 子系统窗口是可以随意改变大小的
const { window } = useDimensions()
useEffect(() => {
requestAnimationFrame(() => {
if (WSA) _.updateLayout()
})
}, [window])
if (!isLoadingComplete) return null
return (
<SafeAreaProvider style={_.container.flex}>
<Provider theme={theme}>
<NavigationContainer>
<Stacks />
</NavigationContainer>
<AppCommon />
<BackAndroid />
<DeepLink />
<DEV />
</Provider>
</SafeAreaProvider>
)
}