From 1e229194ba74fa684b4dc96bb3458652dde8e8f9 Mon Sep 17 00:00:00 2001 From: Viktoryia Kliushun Date: Thu, 26 Oct 2023 15:09:29 +0200 Subject: [PATCH 1/2] [TS migration] Migrate 'SplashScreenHider' component --- src/components/SplashScreenHider/index.js | 28 ------------------- .../{index.native.js => index.native.tsx} | 23 ++++----------- src/components/SplashScreenHider/index.tsx | 15 ++++++++++ src/components/SplashScreenHider/types.ts | 6 ++++ 4 files changed, 26 insertions(+), 46 deletions(-) delete mode 100644 src/components/SplashScreenHider/index.js rename src/components/SplashScreenHider/{index.native.js => index.native.tsx} (81%) create mode 100644 src/components/SplashScreenHider/index.tsx create mode 100644 src/components/SplashScreenHider/types.ts diff --git a/src/components/SplashScreenHider/index.js b/src/components/SplashScreenHider/index.js deleted file mode 100644 index a3f3647ede81f..0000000000000 --- a/src/components/SplashScreenHider/index.js +++ /dev/null @@ -1,28 +0,0 @@ -import {useEffect} from 'react'; -import PropTypes from 'prop-types'; -import BootSplash from '../../libs/BootSplash'; - -const propTypes = { - /** Splash screen has been hidden */ - onHide: PropTypes.func, -}; - -const defaultProps = { - onHide: () => {}, -}; - -function SplashScreenHider(props) { - const {onHide} = props; - - useEffect(() => { - BootSplash.hide().then(() => onHide()); - }, [onHide]); - - return null; -} - -SplashScreenHider.displayName = 'SplashScreenHider'; -SplashScreenHider.propTypes = propTypes; -SplashScreenHider.defaultProps = defaultProps; - -export default SplashScreenHider; diff --git a/src/components/SplashScreenHider/index.native.js b/src/components/SplashScreenHider/index.native.tsx similarity index 81% rename from src/components/SplashScreenHider/index.native.js rename to src/components/SplashScreenHider/index.native.tsx index dbfac3331484a..20279222a5101 100644 --- a/src/components/SplashScreenHider/index.native.js +++ b/src/components/SplashScreenHider/index.native.tsx @@ -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(() => ({ opacity: opacity.value, })); - const scaleStyle = useAnimatedStyle(() => ({ + const scaleStyle = useAnimatedStyle(() => ({ transform: [{scale: scale.value}], })); @@ -83,7 +72,5 @@ function SplashScreenHider(props) { } SplashScreenHider.displayName = 'SplashScreenHider'; -SplashScreenHider.propTypes = propTypes; -SplashScreenHider.defaultProps = defaultProps; export default SplashScreenHider; diff --git a/src/components/SplashScreenHider/index.tsx b/src/components/SplashScreenHider/index.tsx new file mode 100644 index 0000000000000..f60d93ed1b6fb --- /dev/null +++ b/src/components/SplashScreenHider/index.tsx @@ -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; diff --git a/src/components/SplashScreenHider/types.ts b/src/components/SplashScreenHider/types.ts new file mode 100644 index 0000000000000..4ea25da93290b --- /dev/null +++ b/src/components/SplashScreenHider/types.ts @@ -0,0 +1,6 @@ +type SplashScreenHiderProps = { + /** Splash screen has been hidden */ + onHide: () => void; +}; + +export default SplashScreenHiderProps; From d1502955a8a479409ca67d48203c60e0927c4729 Mon Sep 17 00:00:00 2001 From: Viktoryia Kliushun Date: Mon, 30 Oct 2023 08:03:46 +0100 Subject: [PATCH 2/2] Run linter after merging main --- src/components/SplashScreenHider/index.native.tsx | 8 ++++---- src/components/SplashScreenHider/index.tsx | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/SplashScreenHider/index.native.tsx b/src/components/SplashScreenHider/index.native.tsx index 20279222a5101..8c8fa2a4013fa 100644 --- a/src/components/SplashScreenHider/index.native.tsx +++ b/src/components/SplashScreenHider/index.native.tsx @@ -1,9 +1,9 @@ import {useCallback, useRef} from 'react'; 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 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'; function SplashScreenHider({onHide = () => {}}: SplashScreenHiderProps) { diff --git a/src/components/SplashScreenHider/index.tsx b/src/components/SplashScreenHider/index.tsx index f60d93ed1b6fb..d3f5c52c1e3e2 100644 --- a/src/components/SplashScreenHider/index.tsx +++ b/src/components/SplashScreenHider/index.tsx @@ -1,5 +1,5 @@ import {useEffect} from 'react'; -import BootSplash from '../../libs/BootSplash'; +import BootSplash from '@libs/BootSplash'; import type SplashScreenHiderProps from './types'; function SplashScreenHider({onHide = () => {}}: SplashScreenHiderProps) {