This commit is contained in:
Hailey
2024-12-01 15:47:12 -08:00
parent 5f4a0f2881
commit 3d87a27404
3 changed files with 54 additions and 107 deletions
-1
View File
@@ -80,7 +80,6 @@
"@radix-ui/react-focus-guards": "^1.1.1", "@radix-ui/react-focus-guards": "^1.1.1",
"@radix-ui/react-focus-scope": "^1.1.0", "@radix-ui/react-focus-scope": "^1.1.0",
"@react-native-async-storage/async-storage": "1.23.1", "@react-native-async-storage/async-storage": "1.23.1",
"@react-native-masked-view/masked-view": "0.3.0",
"@react-native-menu/menu": "^1.1.0", "@react-native-menu/menu": "^1.1.0",
"@react-native-picker/picker": "2.6.1", "@react-native-picker/picker": "2.6.1",
"@react-navigation/bottom-tabs": "^6.5.20", "@react-navigation/bottom-tabs": "^6.5.20",
+54 -101
View File
@@ -18,9 +18,7 @@ import {useSafeAreaInsets} from 'react-native-safe-area-context'
import Svg, {Path, SvgProps} from 'react-native-svg' import Svg, {Path, SvgProps} from 'react-native-svg'
import {Image} from 'expo-image' import {Image} from 'expo-image'
import * as SplashScreen from 'expo-splash-screen' import * as SplashScreen from 'expo-splash-screen'
import MaskedView from '@react-native-masked-view/masked-view'
import {isAndroid} from '#/platform/detection'
import {Logotype} from '#/view/icons/Logotype' import {Logotype} from '#/view/icons/Logotype'
// @ts-ignore // @ts-ignore
import splashImagePointer from '../assets/splash.png' import splashImagePointer from '../assets/splash.png'
@@ -53,8 +51,6 @@ type Props = {
isReady: boolean isReady: boolean
} }
const AnimatedLogo = Animated.createAnimatedComponent(Logo)
export function Splash(props: React.PropsWithChildren<Props>) { export function Splash(props: React.PropsWithChildren<Props>) {
'use no memo' 'use no memo'
const insets = useSafeAreaInsets() const insets = useSafeAreaInsets()
@@ -81,40 +77,40 @@ export function Splash(props: React.PropsWithChildren<Props>) {
return { return {
transform: [ transform: [
{ {
scale: interpolate(intro.get(), [0, 1], [0.8, 1], 'clamp'), scale: interpolate(intro.value, [0, 1], [0.8, 1], 'clamp'),
}, },
{ {
scale: interpolate( scale: interpolate(
outroLogo.get(), outroLogo.value,
[0, 0.08, 1], [0, 0.08, 1],
[1, 0.8, 500], [1, 0.8, 500],
'clamp', 'clamp',
), ),
}, },
], ],
opacity: interpolate(intro.get(), [0, 1], [0, 1], 'clamp'), opacity: interpolate(intro.value, [0, 1], [0, 1], 'clamp'),
} }
}) })
const bottomLogoAnimation = useAnimatedStyle(() => { const bottomLogoAnimation = useAnimatedStyle(() => {
return { return {
opacity: interpolate(intro.get(), [0, 1], [0, 1], 'clamp'), opacity: interpolate(intro.value, [0, 1], [0, 1], 'clamp'),
} }
}) })
const reducedLogoAnimation = useAnimatedStyle(() => { const reducedLogoAnimation = useAnimatedStyle(() => {
return { return {
transform: [ transform: [
{ {
scale: interpolate(intro.get(), [0, 1], [0.8, 1], 'clamp'), scale: interpolate(intro.value, [0, 1], [0.8, 1], 'clamp'),
}, },
], ],
opacity: interpolate(intro.get(), [0, 1], [0, 1], 'clamp'), opacity: interpolate(intro.value, [0, 1], [0, 1], 'clamp'),
} }
}) })
const logoWrapperAnimation = useAnimatedStyle(() => { const logoWrapperAnimation = useAnimatedStyle(() => {
return { return {
opacity: interpolate( opacity: interpolate(
outroAppOpacity.get(), outroAppOpacity.value,
[0, 0.1, 0.2, 1], [0, 0.1, 0.2, 1],
[1, 1, 0, 0], [1, 1, 0, 0],
'clamp', 'clamp',
@@ -126,11 +122,11 @@ export function Splash(props: React.PropsWithChildren<Props>) {
return { return {
transform: [ transform: [
{ {
scale: interpolate(outroApp.get(), [0, 1], [1.1, 1], 'clamp'), scale: interpolate(outroApp.value, [0, 1], [1.1, 1], 'clamp'),
}, },
], ],
opacity: interpolate( opacity: interpolate(
outroAppOpacity.get(), outroAppOpacity.value,
[0, 0.1, 0.2, 1], [0, 0.1, 0.2, 1],
[0, 0, 1, 1], [0, 0, 1, 1],
'clamp', 'clamp',
@@ -146,37 +142,29 @@ export function Splash(props: React.PropsWithChildren<Props>) {
if (isReady) { if (isReady) {
SplashScreen.hideAsync() SplashScreen.hideAsync()
.then(() => { .then(() => {
intro.set(() => intro.value = withTiming(
withTiming( 1,
1, {duration: 400, easing: Easing.out(Easing.cubic)},
{duration: 400, easing: Easing.out(Easing.cubic)}, async () => {
async () => { // set these values to check animation at specific point
// set these values to check animation at specific point // outroLogo.value = 0.1
// outroLogo.set(0.1) // outroApp.value = 0.1
// outroApp.set(0.1) outroLogo.value = withTiming(
outroLogo.set(() => 1,
withTiming( {duration: 1200, easing: Easing.in(Easing.cubic)},
1, () => {
{duration: 1200, easing: Easing.in(Easing.cubic)}, runOnJS(onFinish)()
() => { },
runOnJS(onFinish)() )
}, outroApp.value = withTiming(1, {
), duration: 1200,
) easing: Easing.inOut(Easing.cubic),
outroApp.set(() => })
withTiming(1, { outroAppOpacity.value = withTiming(1, {
duration: 1200, duration: 1200,
easing: Easing.inOut(Easing.cubic), easing: Easing.in(Easing.cubic),
}), })
) },
outroAppOpacity.set(() =>
withTiming(1, {
duration: 1200,
easing: Easing.in(Easing.cubic),
}),
)
},
),
) )
}) })
.catch(() => {}) .catch(() => {})
@@ -221,66 +209,31 @@ export function Splash(props: React.PropsWithChildren<Props>) {
</View> </View>
)} )}
{isReady && {isReady && (
(isAndroid || reduceMotion === true ? ( <>
// Use a simple fade on older versions of android (work around a bug) <Animated.View style={[{flex: 1}, appAnimation]}>
<> {props.children}
<Animated.View style={[{flex: 1}, appAnimation]}> </Animated.View>
{props.children}
</Animated.View>
{!isAnimationComplete && ( {!isAnimationComplete && (
<Animated.View <Animated.View
style={[ style={[
StyleSheet.absoluteFillObject, StyleSheet.absoluteFillObject,
logoWrapperAnimation, logoWrapperAnimation,
{ {
flex: 1, flex: 1,
justifyContent: 'center', justifyContent: 'center',
alignItems: 'center', alignItems: 'center',
transform: [{translateY: -(insets.top / 2)}, {scale: 0.1}], // scale from 1000px to 100px transform: [{translateY: -(insets.top / 2)}, {scale: 0.1}], // scale from 1000px to 100px
}, },
]}> ]}>
<AnimatedLogo <Animated.View style={[logoAnimations]}>
fill={logoBg} <Logo fill={logoBg} />
style={[{opacity: 0}, logoAnimations]}
/>
</Animated.View> </Animated.View>
)}
</>
) : (
<MaskedView
style={[StyleSheet.absoluteFillObject]}
maskElement={
<Animated.View
style={[
{
// Transparent background because mask is based off alpha channel.
backgroundColor: 'transparent',
flex: 1,
justifyContent: 'center',
alignItems: 'center',
transform: [{translateY: -(insets.top / 2)}, {scale: 0.1}], // scale from 1000px to 100px
},
]}>
<AnimatedLogo fill={logoBg} style={[logoAnimations]} />
</Animated.View>
}>
{!isAnimationComplete && (
<View
style={[
StyleSheet.absoluteFillObject,
{
backgroundColor: logoBg,
},
]}
/>
)}
<Animated.View style={[{flex: 1}, appAnimation]}>
{props.children}
</Animated.View> </Animated.View>
</MaskedView> )}
))} </>
)}
</View> </View>
) )
} }
-5
View File
@@ -5655,11 +5655,6 @@
prompts "^2.4.2" prompts "^2.4.2"
semver "^7.5.2" semver "^7.5.2"
"@react-native-masked-view/masked-view@0.3.0":
version "0.3.0"
resolved "https://registry.yarnpkg.com/@react-native-masked-view/masked-view/-/masked-view-0.3.0.tgz#bd29fae18d148a685331910a3c7b766ce87eafcc"
integrity sha512-qLyoObcjzrkpNcoJjXquUePXfL1dXjHtuv+yX0zZ0Q4kG5yvVqd620+tSh7WbRoHkjpXhFBfLwvGhcWB2I0Lpw==
"@react-native-menu/menu@^1.1.0": "@react-native-menu/menu@^1.1.0":
version "1.1.0" version "1.1.0"
resolved "https://registry.yarnpkg.com/@react-native-menu/menu/-/menu-1.1.0.tgz#e89c0850f7e5aa4c671c44a9c10edafadb23c35a" resolved "https://registry.yarnpkg.com/@react-native-menu/menu/-/menu-1.1.0.tgz#e89c0850f7e5aa4c671c44a9c10edafadb23c35a"