Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions src/Expensify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,7 @@ function Expensify() {
Navigation.setIsNavigationReady();
}, []);

const [splashHideHasBeenCalled, setSplashHideHasBeenCalled] = useState(false);
const onSplashHide = useCallback(() => {
setSplashHideHasBeenCalled(true);
setSplashScreenState(CONST.BOOT_SPLASH_STATE.HIDDEN);
endSpan(CONST.TELEMETRY.SPAN_OD_ND_TRANSITION);
endSpan(CONST.TELEMETRY.SPAN_APP_STARTUP);
Expand Down Expand Up @@ -294,12 +292,7 @@ function Expensify() {
initialUrl={initialUrl}
/>
)}
{!splashHideHasBeenCalled && (
<SplashScreenHider
shouldHideSplash={shouldHideSplash}
onHide={onSplashHide}
/>
)}
{shouldHideSplash && <SplashScreenHider onHide={onSplashHide} />}
</>
);
}
Expand Down
17 changes: 6 additions & 11 deletions src/components/SplashScreenHider/index.native.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {useEffect, useEffectEvent, useRef} from 'react';
import {useCallback, useRef} from 'react';
import type {ViewStyle} from 'react-native';
import {StyleSheet} from 'react-native';
import Reanimated, {Easing, useAnimatedStyle, useSharedValue, withTiming} from 'react-native-reanimated';
Expand All @@ -9,7 +9,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import BootSplash from '@libs/BootSplash';
import type {SplashScreenHiderProps, SplashScreenHiderReturnType} from './types';

function SplashScreenHider({shouldHideSplash, onHide}: SplashScreenHiderProps): SplashScreenHiderReturnType {
function SplashScreenHider({onHide = () => {}}: SplashScreenHiderProps): SplashScreenHiderReturnType {
const styles = useThemeStyles();
const logoSizeRatio = BootSplash.logoSizeRatio || 1;

Expand All @@ -24,7 +24,8 @@ function SplashScreenHider({shouldHideSplash, onHide}: SplashScreenHiderProps):
}));

const hideHasBeenCalled = useRef(false);
const hide = useEffectEvent(() => {

const hide = useCallback(() => {
// hide can only be called once
if (hideHasBeenCalled.current) {
return;
Expand All @@ -51,19 +52,13 @@ function SplashScreenHider({shouldHideSplash, onHide}: SplashScreenHiderProps):
),
);
});
});

useEffect(() => {
if (!shouldHideSplash) {
return;
}
hide();
}, [shouldHideSplash]);
}, [opacity, scale, onHide]);

return (
<Reanimated.View style={[StyleSheet.absoluteFill, styles.splashScreenHider, opacityStyle]}>
<Reanimated.View style={scaleStyle}>
<ImageSVG
onLoadEnd={hide}
contentFit="fill"
style={{width: 100 * logoSizeRatio, height: 100 * logoSizeRatio}}
src={Logo}
Expand Down
14 changes: 4 additions & 10 deletions src/components/SplashScreenHider/index.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import {useEffect, useEffectEvent} from 'react';
import {useEffect} from 'react';
import BootSplash from '@libs/BootSplash';
import type {SplashScreenHiderProps, SplashScreenHiderReturnType} from './types';

function SplashScreenHider({shouldHideSplash, onHide}: SplashScreenHiderProps): SplashScreenHiderReturnType {
const hide = useEffectEvent(() => {
BootSplash.hide().then(() => onHide());
});
function SplashScreenHider({onHide = () => {}}: SplashScreenHiderProps): SplashScreenHiderReturnType {
useEffect(() => {
if (!shouldHideSplash) {
return;
}
hide();
}, [shouldHideSplash]);
BootSplash.hide().then(() => onHide());
}, [onHide]);

return null;
}
Expand Down
3 changes: 0 additions & 3 deletions src/components/SplashScreenHider/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import type {ReactNode} from 'react';

type SplashScreenHiderProps = {
/** Whether the splash screen should be hidden */
shouldHideSplash: boolean;

/** Splash screen has been hidden */
onHide: () => void;
};
Expand Down
Loading