Skip to content

Commit

Permalink
Merge pull request #35215 from wildan-m/wildan/fix/33916-delay-backgr…
Browse files Browse the repository at this point in the history
…ound-add-transition

Rectify the background delay issue by incorporating a transition
  • Loading branch information
arosiclair committed Feb 2, 2024
2 parents 150e171 + 28cfe38 commit a0614e9
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const CONST = {
IN: 'in',
OUT: 'out',
},
BACKGROUND_IMAGE_TRANSITION_DURATION: 1000,
ARROW_HIDE_DELAY: 3000,

API_ATTACHMENT_VALIDATIONS: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function BackgroundImage(props) {
source={AndroidBackgroundImage}
pointerEvents={props.pointerEvents}
style={[styles.signInBackground, {width: props.width}]}
transition={props.transitionDuration}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ function BackgroundImage(props) {
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const src = useMemo(() => (props.isSmallScreen ? MobileBackgroundImage : DesktopBackgroundImage), [props.isSmallScreen]);

return (
<Image
source={src}
style={[styles.signInBackground, StyleUtils.getWidthStyle(props.width)]}
transition={props.transitionDuration}
/>
);
}
Expand Down
36 changes: 27 additions & 9 deletions src/pages/signin/SignInPageLayout/BackgroundImage/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PropTypes from 'prop-types';
import React from 'react';
import * as Animatable from 'react-native-animatable';
import DesktopBackgroundImage from '@assets/images/home-background--desktop.svg';
import MobileBackgroundImage from '@assets/images/home-background--mobile.svg';
import useThemeStyles from '@hooks/useThemeStyles';
Expand All @@ -17,16 +18,33 @@ const propTypes = {
};
function BackgroundImage(props) {
const styles = useThemeStyles();
return props.isSmallScreen ? (
<MobileBackgroundImage
width={props.width}
style={styles.signInBackground}
/>
) : (
<DesktopBackgroundImage
width={props.width}
const fadeIn = {
from: {
opacity: 0,
},
to: {
opacity: 1,
},
};

return (
<Animatable.View
style={styles.signInBackground}
/>
animation={fadeIn}
duration={props.transitionDuration}
>
{props.isSmallScreen ? (
<MobileBackgroundImage
width={props.width}
style={styles.signInBackground}
/>
) : (
<DesktopBackgroundImage
width={props.width}
style={styles.signInBackground}
/>
)}
</Animatable.View>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const propTypes = {

/** The width of the image. */
width: PropTypes.number.isRequired,

/** Transition duration in milliseconds */
transitionDuration: PropTypes.number,
};

export default propTypes;
3 changes: 3 additions & 0 deletions src/pages/signin/SignInPageLayout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import useWindowDimensions from '@hooks/useWindowDimensions';
import compose from '@libs/compose';
import SignInPageHero from '@pages/signin/SignInPageHero';
import variables from '@styles/variables';
import CONST from '@src/CONST';
import BackgroundImage from './BackgroundImage';
import Footer from './Footer';
import SignInPageContent from './SignInPageContent';
Expand Down Expand Up @@ -127,6 +128,7 @@ function SignInPageLayout(props) {
isSmallScreen={false}
pointerEvents="none"
width={variables.signInHeroBackgroundWidth}
transitionDuration={CONST.BACKGROUND_IMAGE_TRANSITION_DURATION}
/>
</View>
<View>
Expand Down Expand Up @@ -166,6 +168,7 @@ function SignInPageLayout(props) {
isSmallScreen
pointerEvents="none"
width={variables.signInHeroBackgroundWidthMobile}
transitionDuration={CONST.BACKGROUND_IMAGE_TRANSITION_DURATION}
/>
<SignInPageContent
welcomeHeader={props.welcomeHeader}
Expand Down

0 comments on commit a0614e9

Please sign in to comment.