Skip to content

Commit

Permalink
Merge pull request #30439 from VickyStash/ts-migration/splashScreenHi…
Browse files Browse the repository at this point in the history
…der-component

[TS migration] Migrate 'SplashScreenHider' component to TypeScript
  • Loading branch information
arosiclair authored Oct 31, 2023
2 parents ec49bca + d150295 commit 48daec8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 46 deletions.
28 changes: 0 additions & 28 deletions src/components/SplashScreenHider/index.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,33 +1,22 @@
import PropTypes from 'prop-types';
import {useCallback, useRef} from 'react';
import {StyleSheet} from 'react-native';
import {StyleSheet, ViewStyle} from 'react-native';
import Reanimated, {Easing, runOnJS, useAnimatedStyle, useSharedValue, withTiming} from 'react-native-reanimated';
import Logo from '@assets/images/new-expensify-dark.svg';
import BootSplash from '@libs/BootSplash';
import styles from '@styles/styles';
import type SplashScreenHiderProps from './types';

const propTypes = {
/** Splash screen has been hidden */
onHide: PropTypes.func,
};

const defaultProps = {
onHide: () => {},
};

function SplashScreenHider(props) {
const {onHide} = props;

function SplashScreenHider({onHide = () => {}}: SplashScreenHiderProps) {
const logoSizeRatio = BootSplash.logoSizeRatio || 1;
const navigationBarHeight = BootSplash.navigationBarHeight || 0;

const opacity = useSharedValue(1);
const scale = useSharedValue(1);

const opacityStyle = useAnimatedStyle(() => ({
const opacityStyle = useAnimatedStyle<ViewStyle>(() => ({
opacity: opacity.value,
}));
const scaleStyle = useAnimatedStyle(() => ({
const scaleStyle = useAnimatedStyle<ViewStyle>(() => ({
transform: [{scale: scale.value}],
}));

Expand Down Expand Up @@ -83,7 +72,5 @@ function SplashScreenHider(props) {
}

SplashScreenHider.displayName = 'SplashScreenHider';
SplashScreenHider.propTypes = propTypes;
SplashScreenHider.defaultProps = defaultProps;

export default SplashScreenHider;
15 changes: 15 additions & 0 deletions src/components/SplashScreenHider/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {useEffect} from 'react';
import BootSplash from '@libs/BootSplash';
import type SplashScreenHiderProps from './types';

function SplashScreenHider({onHide = () => {}}: SplashScreenHiderProps) {
useEffect(() => {
BootSplash.hide().then(() => onHide());
}, [onHide]);

return null;
}

SplashScreenHider.displayName = 'SplashScreenHider';

export default SplashScreenHider;
6 changes: 6 additions & 0 deletions src/components/SplashScreenHider/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type SplashScreenHiderProps = {
/** Splash screen has been hidden */
onHide: () => void;
};

export default SplashScreenHiderProps;

0 comments on commit 48daec8

Please sign in to comment.