Merge branch 'haileyok-fix/android-splash-hackfix' into main

zio/stable
Paul Frazee 2024-01-02 11:57:43 -08:00
commit e460b304fc
1 changed files with 46 additions and 27 deletions

View File

@ -2,6 +2,7 @@ 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,
@ -136,12 +137,27 @@ export function Splash(props: React.PropsWithChildren<Props>) {
/> />
)} )}
{platformApiLevel && platformApiLevel <= 25 ? (
// Use a simple fade on older versions of android (work around a bug)
<>
{!isAnimationComplete && (
<View
style={[
StyleSheet.absoluteFillObject,
{backgroundColor: 'white'},
]}
/>
)}
<Animated.View style={[{flex: 1}, appAnimation]}>
{props.children}
</Animated.View>
</>
) : (
<MaskedView <MaskedView
style={[StyleSheet.absoluteFillObject]} style={[StyleSheet.absoluteFillObject]}
maskElement={ maskElement={
<Animated.View <Animated.View
style={[ style={[
StyleSheet.absoluteFillObject,
{ {
// Transparent background because mask is based off alpha channel. // Transparent background because mask is based off alpha channel.
backgroundColor: 'transparent', backgroundColor: 'transparent',
@ -156,14 +172,17 @@ export function Splash(props: React.PropsWithChildren<Props>) {
}> }>
{!isAnimationComplete && ( {!isAnimationComplete && (
<View <View
style={[StyleSheet.absoluteFillObject, {backgroundColor: 'white'}]} style={[
StyleSheet.absoluteFillObject,
{backgroundColor: 'white'},
]}
/> />
)} )}
<Animated.View style={[{flex: 1}, appAnimation]}> <Animated.View style={[{flex: 1}, appAnimation]}>
{props.children} {props.children}
</Animated.View> </Animated.View>
</MaskedView> </MaskedView>
)}
</View> </View>
) )
} }