diff --git a/assets/splash-with-logo.png b/assets/splash-with-logo.png new file mode 100644 index 0000000000..d012d724c2 Binary files /dev/null and b/assets/splash-with-logo.png differ diff --git a/assets/splash.png b/assets/splash.png index d012d724c2..603f1f3791 100644 Binary files a/assets/splash.png and b/assets/splash.png differ diff --git a/src/App.native.tsx b/src/App.native.tsx index 993e8c037e..b67b7c1501 100644 --- a/src/App.native.tsx +++ b/src/App.native.tsx @@ -55,7 +55,7 @@ function InnerApp() { }, [resumeSession]) return ( - + diff --git a/src/Splash.tsx b/src/Splash.tsx index 1aaced850c..57c5c83154 100644 --- a/src/Splash.tsx +++ b/src/Splash.tsx @@ -1,8 +1,6 @@ import React, {useCallback, useEffect} from 'react' -import {View, Image, StyleSheet} from 'react-native' +import {View, StyleSheet} from 'react-native' import * as SplashScreen from 'expo-splash-screen' -// @ts-ignore -import splashImagePointer from '../assets/icon-android-foreground.png' import LinearGradient from 'react-native-linear-gradient' import Animated, { interpolate, @@ -10,10 +8,10 @@ import Animated, { useAnimatedStyle, useSharedValue, withTiming, + Easing, } from 'react-native-reanimated' import MaskedView from '@react-native-masked-view/masked-view' - -const splashImageUri = Image.resolveAssetSource(splashImagePointer).uri +import {Logo} from '#/view/icons/Logo' type Props = { isReady: boolean @@ -22,34 +20,18 @@ type Props = { SplashScreen.preventAutoHideAsync().catch(() => {}) export function Splash(props: React.PropsWithChildren) { - const progress = useSharedValue(0) + const fadeAnimationProgress = useSharedValue(0) + const scaleAnimationProgress = useSharedValue(0) const [isAnimationComplete, setIsAnimationComplete] = React.useState(false) - const onFinish = useCallback(() => { - SplashScreen.hideAsync().catch(() => {}) - setIsAnimationComplete(true) - }, []) - - const onLoadEnd = React.useCallback(() => { - SplashScreen.hideAsync().catch(() => {}) - }, []) - - useEffect(() => { - if (props.isReady) { - progress.value = withTiming(1, {duration: 1000}, () => { - runOnJS(onFinish)() - }) - } - }, [onFinish, progress, props.isReady]) - - const imageScale = useAnimatedStyle(() => { + const logoScaleAnimation = useAnimatedStyle(() => { return { transform: [ { scale: interpolate( - progress.value, - [0, 0.2, 1], - [1, 0.8, 100], + scaleAnimationProgress.value, + [0, 0.2, 0.22, 1], + [1, 0.8, 0.8, 200], 'clamp', ), }, @@ -57,72 +39,104 @@ export function Splash(props: React.PropsWithChildren) { } }) - const appScale = useAnimatedStyle(() => { + const logoFadeInAnimation = useAnimatedStyle(() => { + return { + opacity: interpolate( + fadeAnimationProgress.value, + [0, 0.5, 1], + [0, 1, 1], + 'clamp', + ), + } + }) + + const appScaleAnimation = useAnimatedStyle(() => { return { transform: [ { - scale: interpolate(progress.value, [0, 1], [1.1, 1]), + scale: interpolate( + scaleAnimationProgress.value, + [0, 0.22, 1], + [1.05, 1.05, 1], + ), }, ], } }) - const opacityScale = useAnimatedStyle(() => { + // const opacityScale = { opacity: 1 } + const appFadeInAnimation = useAnimatedStyle(() => { return { - opacity: interpolate(progress.value, [0, 0.15, 0.3], [0, 0, 1], 'clamp'), + opacity: interpolate( + scaleAnimationProgress.value, + [0, 0.22, 1], + [0, 0, 1], + 'clamp', + ), } }) + const onFinish = useCallback(() => setIsAnimationComplete(true), []) + + useEffect(() => { + // hide on mount + SplashScreen.hideAsync().catch(() => {}) + + if (props.isReady) { + fadeAnimationProgress.value = withTiming( + 1, + {duration: 800, easing: Easing.inOut(Easing.cubic)}, + () => { + scaleAnimationProgress.value = withTiming( + 1, + {duration: 1000, easing: Easing.inOut(Easing.cubic)}, + () => { + runOnJS(onFinish)() + }, + ) + }, + ) + } + }, [onFinish, fadeAnimationProgress, scaleAnimationProgress, props.isReady]) + return ( - {isAnimationComplete ? null : ( + {!isAnimationComplete && ( )} + - - + + + }> - + {!isAnimationComplete && ( + + )} + + {props.children} ) } - -import Svg, {SvgProps, Path} from 'react-native-svg' -const Logo = (props: SvgProps) => ( - - - -) diff --git a/src/view/icons/Logo.tsx b/src/view/icons/Logo.tsx index b7a281d3d1..5d78a2adc7 100644 --- a/src/view/icons/Logo.tsx +++ b/src/view/icons/Logo.tsx @@ -10,12 +10,20 @@ import Svg, { import {colors} from '#/lib/styles' +const ratio = 106 / 120 + export function Logo({fill, ...rest}: {fill?: PathProps['fill']} & SvgProps) { const gradient = fill === 'sky' const _fill = gradient ? 'url(#sky)' : fill || colors.blue3 - const size = rest.width || 32 + // @ts-ignore it's fiiiiine + const size = parseInt(rest.width || 32) return ( - + {gradient && (