diff --git a/assets/images/home-background--mobile-new.svg b/assets/images/home-background--ios.svg similarity index 100% rename from assets/images/home-background--mobile-new.svg rename to assets/images/home-background--ios.svg diff --git a/src/pages/signin/SignInPageLayout/BackgroundImage/index.ios.tsx b/src/pages/signin/SignInPageLayout/BackgroundImage/index.ios.tsx index fc28dc08fb15..86ccdfd74ff5 100644 --- a/src/pages/signin/SignInPageLayout/BackgroundImage/index.ios.tsx +++ b/src/pages/signin/SignInPageLayout/BackgroundImage/index.ios.tsx @@ -1,10 +1,9 @@ import {Image} from 'expo-image'; -import React, {useEffect, useMemo, useState} from 'react'; -import {InteractionManager} from 'react-native'; +import React, {useEffect, useState} from 'react'; import type {ImageSourcePropType} from 'react-native'; +import {InteractionManager} from 'react-native'; import Reanimated, {Easing, useAnimatedStyle, useSharedValue, withTiming} from 'react-native-reanimated'; -import DesktopBackgroundImage from '@assets/images/home-background--desktop.svg'; -import MobileBackgroundImage from '@assets/images/home-background--mobile-new.svg'; +import MobileBackgroundImage from '@assets/images/home-background--ios.svg'; import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; import {isAnonymousUser} from '@libs/actions/Session'; @@ -12,10 +11,9 @@ import CONST from '@src/CONST'; import {useSplashScreenStateContext} from '@src/SplashScreenStateContext'; import type BackgroundImageProps from './types'; -function BackgroundImage({width, transitionDuration, isSmallScreen = false}: BackgroundImageProps) { +function BackgroundImage({width, transitionDuration}: BackgroundImageProps) { const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); - const src = useMemo(() => (isSmallScreen ? MobileBackgroundImage : DesktopBackgroundImage), [isSmallScreen]); const [isInteractionComplete, setIsInteractionComplete] = useState(false); const isAnonymous = isAnonymousUser(); @@ -56,7 +54,7 @@ function BackgroundImage({width, transitionDuration, isSmallScreen = false}: Bac return ( setOpacityAnimation()} style={[styles.signInBackground, StyleUtils.getWidthStyle(width)]} transition={transitionDuration} diff --git a/src/pages/signin/SignInPageLayout/BackgroundImage/index.tsx b/src/pages/signin/SignInPageLayout/BackgroundImage/index.tsx index 46acaf5061a4..35de4837654e 100644 --- a/src/pages/signin/SignInPageLayout/BackgroundImage/index.tsx +++ b/src/pages/signin/SignInPageLayout/BackgroundImage/index.tsx @@ -1,17 +1,33 @@ -import React, {useEffect, useState} from 'react'; +import React, {lazy, Suspense, useEffect, useMemo, useState} from 'react'; import {InteractionManager} from 'react-native'; import Animated, {FadeIn} from 'react-native-reanimated'; -import DesktopBackgroundImage from '@assets/images/home-background--desktop.svg'; -import MobileBackgroundImage from '@assets/images/home-background--mobile.svg'; import useThemeStyles from '@hooks/useThemeStyles'; import {isAnonymousUser} from '@libs/actions/Session'; import type BackgroundImageProps from './types'; +const BackgroundMobile = lazy(() => + import('@assets/images/home-background--mobile.svg').catch(() => ({ + default: () => null, + })), +); +const BackgroundDesktop = lazy(() => + import('@assets/images/home-background--desktop.svg').catch(() => ({ + default: () => null, + })), +); + function BackgroundImage({width, transitionDuration, isSmallScreen = false}: BackgroundImageProps) { const styles = useThemeStyles(); const [isInteractionComplete, setIsInteractionComplete] = useState(false); const isAnonymous = isAnonymousUser(); + const BackgroundComponent = useMemo(() => { + if (isSmallScreen) { + return BackgroundMobile; + } + return BackgroundDesktop; + }, [isSmallScreen]); + useEffect(() => { if (!isAnonymous) { return; @@ -31,30 +47,15 @@ function BackgroundImage({width, transitionDuration, isSmallScreen = false}: Bac return; } - if (isSmallScreen) { - return ( + return ( + - + - ); - } - - return ( - - - + ); }