forked from czy0729/Bangumi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
executable file
·59 lines (53 loc) · 1.86 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
/*
* @Author: czy0729
* @Date: 2019-03-30 19:25:19
* @Last Modified by: czy0729
* @Last Modified time: 2024-08-03 04:32:36
*/
import React, { Suspense, useEffect } from 'react'
import { LogBox } from 'react-native'
import { GestureHandlerRootView } from 'react-native-gesture-handler'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import { enableScreens } from 'react-native-screens'
import Provider from '@ant-design/react-native/lib/provider'
import { DeepLink, DEV } from '@components'
import { HoldMenuProvider } from '@components/@/react-native-hold-menu'
import { AppCommon } from '@_'
import { _ } from '@stores'
import { useCachedResources, useOrientation } from '@utils/hooks'
import Stacks from '@src/navigations/native-stacks'
import theme from '@styles/theme'
LogBox.ignoreAllLogs(true)
// iOS 侧载情况下, App 切出或者休眠后返回, 滑动退后会卡死, 暂不使用这个优化
// if (IOS_IPA) enableScreens(false)
enableScreens(false)
export default function App() {
// 加载图标等资源
const loadingResult = useCachedResources()
// 获取水平状态, 只有平板允许横屏, 手机锁竖屏
const orientation = useOrientation()
useEffect(() => {
_.toggleOrientation(orientation)
}, [orientation])
if (!loadingResult) return null
const isLoadingComplete = loadingResult >= 3
return (
<GestureHandlerRootView style={_.container.flex}>
<SafeAreaProvider style={_.container.flex}>
{/* @ts-ignore */}
<Provider theme={theme}>
<HoldMenuProvider>
<Stacks isLoadingComplete={isLoadingComplete} />
</HoldMenuProvider>
{isLoadingComplete && (
<Suspense>
<AppCommon />
<DeepLink />
<DEV />
</Suspense>
)}
</Provider>
</SafeAreaProvider>
</GestureHandlerRootView>
)
}