Add splashiness
This commit is contained in:
+3
-3
@@ -34,6 +34,7 @@ import {
|
|||||||
} from 'state/session'
|
} from 'state/session'
|
||||||
import {Provider as UnreadNotifsProvider} from 'state/queries/notifications/unread'
|
import {Provider as UnreadNotifsProvider} from 'state/queries/notifications/unread'
|
||||||
import * as persisted from '#/state/persisted'
|
import * as persisted from '#/state/persisted'
|
||||||
|
import {Splash} from '#/Splash'
|
||||||
|
|
||||||
SplashScreen.preventAutoHideAsync()
|
SplashScreen.preventAutoHideAsync()
|
||||||
|
|
||||||
@@ -53,10 +54,8 @@ function InnerApp() {
|
|||||||
resumeSession(account)
|
resumeSession(account)
|
||||||
}, [resumeSession])
|
}, [resumeSession])
|
||||||
|
|
||||||
// wait for session to resume
|
|
||||||
if (isInitialLoad) return null
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<Splash isReady={isInitialLoad}>
|
||||||
<React.Fragment
|
<React.Fragment
|
||||||
// Resets the entire tree below when it changes:
|
// Resets the entire tree below when it changes:
|
||||||
key={currentAccount?.did}>
|
key={currentAccount?.did}>
|
||||||
@@ -74,6 +73,7 @@ function InnerApp() {
|
|||||||
</UnreadNotifsProvider>
|
</UnreadNotifsProvider>
|
||||||
</LoggedOutViewProvider>
|
</LoggedOutViewProvider>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
|
</Splash>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import * as React from 'react'
|
import * as React from 'react'
|
||||||
import {StyleSheet} from 'react-native'
|
import {StyleSheet} from 'react-native'
|
||||||
import * as SplashScreen from 'expo-splash-screen'
|
|
||||||
import {
|
import {
|
||||||
NavigationContainer,
|
NavigationContainer,
|
||||||
createNavigationContainerRef,
|
createNavigationContainerRef,
|
||||||
@@ -489,7 +488,6 @@ function RoutesContainer({children}: React.PropsWithChildren<{}>) {
|
|||||||
linking={LINKING}
|
linking={LINKING}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
onReady={() => {
|
onReady={() => {
|
||||||
SplashScreen.hideAsync()
|
|
||||||
logModuleInitTime()
|
logModuleInitTime()
|
||||||
onReady()
|
onReady()
|
||||||
}}>
|
}}>
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import {View, Image, StyleSheet, Animated, Easing} from 'react-native'
|
||||||
|
import Constants from 'expo-constants'
|
||||||
|
import * as SplashScreen from 'expo-splash-screen'
|
||||||
|
// @ts-ignore
|
||||||
|
import splashImagePointer from '../assets/splash.png'
|
||||||
|
|
||||||
|
const splashImageUri = Image.resolveAssetSource(splashImagePointer).uri
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
isReady: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
SplashScreen.preventAutoHideAsync().catch(() => {})
|
||||||
|
|
||||||
|
export function Splash(props: React.PropsWithChildren<Props>) {
|
||||||
|
const animation = React.useMemo(() => new Animated.Value(1), [])
|
||||||
|
const [isAnimationComplete, setIsAnimationComplete] = React.useState(false)
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (props.isReady) {
|
||||||
|
Animated.timing(animation, {
|
||||||
|
toValue: 1.5,
|
||||||
|
duration: 500,
|
||||||
|
useNativeDriver: true,
|
||||||
|
easing: Easing.cubic,
|
||||||
|
}).start(() => setIsAnimationComplete(true))
|
||||||
|
}
|
||||||
|
}, [animation, props.isReady, setIsAnimationComplete])
|
||||||
|
|
||||||
|
const onLoadEnd = React.useCallback(() => {
|
||||||
|
SplashScreen.hideAsync().catch(() => {})
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View>
|
||||||
|
{props.children}
|
||||||
|
|
||||||
|
{!isAnimationComplete && (
|
||||||
|
<View style={[StyleSheet.absoluteFillObject]}>
|
||||||
|
<Animated.Image
|
||||||
|
onLoadEnd={onLoadEnd}
|
||||||
|
style={[
|
||||||
|
{
|
||||||
|
width: '100%',
|
||||||
|
height: '100%',
|
||||||
|
resizeMode: Constants.expoConfig?.splash?.resizeMode || 'cover',
|
||||||
|
transform: [
|
||||||
|
{
|
||||||
|
scale: animation,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
source={{uri: splashImageUri}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user