Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TS migration] Migrate 'SplashScreenHider' component to TypeScript #30439

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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 {useCallback, useRef} from 'react';
import PropTypes from 'prop-types';
import {StyleSheet} from 'react-native';
import {StyleSheet, ViewStyle} from 'react-native';
import Reanimated, {useSharedValue, withTiming, Easing, useAnimatedStyle, runOnJS} from 'react-native-reanimated';
import BootSplash from '../../libs/BootSplash';
import Logo from '../../../assets/images/new-expensify-dark.svg';
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;
Loading