bsky-app/src/App.native.tsx

49 lines
1.3 KiB
TypeScript
Raw Normal View History

import 'react-native-url-polyfill/auto'
2022-06-09 20:03:25 +02:00
import React, {useState, useEffect} from 'react'
import {RootSiblingParent} from 'react-native-root-siblings'
import {GestureHandlerRootView} from 'react-native-gesture-handler'
2022-11-05 20:52:44 +01:00
import SplashScreen from 'react-native-splash-screen'
2022-11-16 21:05:21 +01:00
import {SafeAreaProvider} from 'react-native-safe-area-context'
2022-06-16 00:40:18 +02:00
import {whenWebCrypto} from './platform/polyfills.native'
2022-07-19 23:04:45 +02:00
import * as view from './view/index'
import {RootStoreModel, setupState, RootStoreProvider} from './state'
import {MobileShell} from './view/shell/mobile'
2022-06-09 20:03:25 +02:00
function App() {
const [rootStore, setRootStore] = useState<RootStoreModel | undefined>(
undefined,
)
2022-06-09 20:03:25 +02:00
// init
useEffect(() => {
2022-07-19 23:04:45 +02:00
whenWebCrypto
.then(() => {
view.setup()
return setupState()
})
2022-11-05 20:52:44 +01:00
.then(store => {
setRootStore(store)
SplashScreen.hide()
})
2022-06-09 20:03:25 +02:00
}, [])
// show nothing prior to init
if (!rootStore) {
return null
}
return (
<GestureHandlerRootView style={{flex: 1}}>
<RootSiblingParent>
<RootStoreProvider value={rootStore}>
2022-11-16 21:05:21 +01:00
<SafeAreaProvider>
<MobileShell />
</SafeAreaProvider>
</RootStoreProvider>
</RootSiblingParent>
</GestureHandlerRootView>
2022-06-09 20:03:25 +02:00
)
}
export default App