Don't use mask for android at all (#2445)

* Don't use mask for android at all

* Remove old Android check
zio/stable
Eric Bailey 2024-01-08 14:09:30 -06:00 committed by GitHub
parent 15f3c679aa
commit da575a6379
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 33 additions and 7 deletions

View File

@ -2,7 +2,6 @@ import React, {useCallback, useEffect} from 'react'
import {View, StyleSheet, Image as RNImage} from 'react-native' import {View, StyleSheet, Image as RNImage} from 'react-native'
import * as SplashScreen from 'expo-splash-screen' import * as SplashScreen from 'expo-splash-screen'
import {Image} from 'expo-image' import {Image} from 'expo-image'
import {platformApiLevel} from 'expo-device'
import Animated, { import Animated, {
interpolate, interpolate,
runOnJS, runOnJS,
@ -15,6 +14,8 @@ import MaskedView from '@react-native-masked-view/masked-view'
import {useSafeAreaInsets} from 'react-native-safe-area-context' 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 {isAndroid} from '#/platform/detection'
// @ts-ignore // @ts-ignore
import splashImagePointer from '../assets/splash.png' import splashImagePointer from '../assets/splash.png'
const splashImageUri = RNImage.resolveAssetSource(splashImagePointer).uri const splashImageUri = RNImage.resolveAssetSource(splashImagePointer).uri
@ -54,7 +55,7 @@ export function Splash(props: React.PropsWithChildren<Props>) {
const [isLayoutReady, setIsLayoutReady] = React.useState(false) const [isLayoutReady, setIsLayoutReady] = React.useState(false)
const isReady = props.isReady && isImageLoaded && isLayoutReady const isReady = props.isReady && isImageLoaded && isLayoutReady
const logoAnimations = useAnimatedStyle(() => { const logoAnimation = useAnimatedStyle(() => {
return { return {
transform: [ transform: [
{ {
@ -64,7 +65,7 @@ export function Splash(props: React.PropsWithChildren<Props>) {
scale: interpolate( scale: interpolate(
outroLogo.value, outroLogo.value,
[0, 0.08, 1], [0, 0.08, 1],
[1, 0.8, 400], [1, 0.8, 500],
'clamp', 'clamp',
), ),
}, },
@ -72,6 +73,16 @@ export function Splash(props: React.PropsWithChildren<Props>) {
opacity: interpolate(intro.value, [0, 1], [0, 1], 'clamp'), opacity: interpolate(intro.value, [0, 1], [0, 1], 'clamp'),
} }
}) })
const logoWrapperAnimation = useAnimatedStyle(() => {
return {
opacity: interpolate(
outroAppOpacity.value,
[0, 0.1, 0.2, 1],
[1, 1, 0, 0],
'clamp',
),
}
})
const appAnimation = useAnimatedStyle(() => { const appAnimation = useAnimatedStyle(() => {
return { return {
@ -82,7 +93,7 @@ export function Splash(props: React.PropsWithChildren<Props>) {
], ],
opacity: interpolate( opacity: interpolate(
outroAppOpacity.value, outroAppOpacity.value,
[0, 0.08, 0.15, 1], [0, 0.1, 0.2, 1],
[0, 0, 1, 1], [0, 0, 1, 1],
'clamp', 'clamp',
), ),
@ -137,16 +148,31 @@ export function Splash(props: React.PropsWithChildren<Props>) {
/> />
)} )}
{platformApiLevel && platformApiLevel <= 25 ? ( {isAndroid ? (
// Use a simple fade on older versions of android (work around a bug) // Use a simple fade on older versions of android (work around a bug)
<> <>
<Animated.View style={[{flex: 1}, appAnimation]}> <Animated.View style={[{flex: 1}, appAnimation]}>
{props.children} {props.children}
</Animated.View> </Animated.View>
{!isAnimationComplete && (
<Animated.View
style={[
StyleSheet.absoluteFillObject,
logoWrapperAnimation,
{
flex: 1,
justifyContent: 'center',
alignItems: 'center',
transform: [{translateY: -(insets.top / 2)}, {scale: 0.1}], // scale from 1000px to 100px
},
]}>
<AnimatedLogo style={[{opacity: 0}, logoAnimation]} />
</Animated.View>
)}
</> </>
) : ( ) : (
<MaskedView <MaskedView
androidRenderingMode="software"
style={[StyleSheet.absoluteFillObject]} style={[StyleSheet.absoluteFillObject]}
maskElement={ maskElement={
<Animated.View <Animated.View
@ -160,7 +186,7 @@ export function Splash(props: React.PropsWithChildren<Props>) {
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 style={[logoAnimations]} /> <AnimatedLogo style={[logoAnimation]} />
</Animated.View> </Animated.View>
}> }>
{!isAnimationComplete && ( {!isAnimationComplete && (