diff --git a/src/pages/signin/SignInHeroImage.js b/src/pages/signin/SignInHeroImage.js index bfd076336af7..302e09a7afbc 100644 --- a/src/pages/signin/SignInHeroImage.js +++ b/src/pages/signin/SignInHeroImage.js @@ -1,3 +1,4 @@ +import PropTypes from 'prop-types'; import React from 'react'; import Lottie from '@components/Lottie'; import LottieAnimations from '@components/LottieAnimations'; @@ -7,12 +8,18 @@ import variables from '@styles/variables'; const propTypes = { ...windowDimensionsPropTypes, + + shouldShowSmallScreen: PropTypes.bool, +}; + +const defaultProps = { + shouldShowSmallScreen: false, }; function SignInHeroImage(props) { const styles = useThemeStyles(); let imageSize; - if (props.isSmallScreenWidth) { + if (props.isSmallScreenWidth || props.shouldShowSmallScreen) { imageSize = { height: variables.signInHeroImageMobileHeight, width: variables.signInHeroImageMobileWidth, @@ -42,5 +49,6 @@ function SignInHeroImage(props) { SignInHeroImage.displayName = 'SignInHeroImage'; SignInHeroImage.propTypes = propTypes; +SignInHeroImage.defaultProps = defaultProps; export default withWindowDimensions(SignInHeroImage); diff --git a/src/pages/signin/SignInPage.js b/src/pages/signin/SignInPage.js index 8d3b10ce606d..5222a0afe73e 100644 --- a/src/pages/signin/SignInPage.js +++ b/src/pages/signin/SignInPage.js @@ -241,7 +241,7 @@ function SignInPage({credentials, account, isInModal, activeClients, preferredLo shouldShowWelcomeHeader={shouldShowWelcomeHeader || !isSmallScreenWidth || !isInModal} shouldShowWelcomeText={shouldShowWelcomeText} ref={signInPageLayoutRef} - isInModal={isInModal} + shouldShowSmallScreen={shouldShowSmallScreen} > {/* LoginForm must use the isVisible prop. This keeps it mounted, but visually hidden so that password managers can access the values. Conditionally rendering this component will break this feature. */} diff --git a/src/pages/signin/SignInPageLayout/SignInPageContent.js b/src/pages/signin/SignInPageLayout/SignInPageContent.js index a85e193a8356..d09cee9aa1c2 100755 --- a/src/pages/signin/SignInPageLayout/SignInPageContent.js +++ b/src/pages/signin/SignInPageLayout/SignInPageContent.js @@ -7,7 +7,7 @@ import OfflineIndicator from '@components/OfflineIndicator'; import SignInPageForm from '@components/SignInPageForm'; import Text from '@components/Text'; import withLocalize, {withLocalizePropTypes} from '@components/withLocalize'; -import withWindowDimensions, {windowDimensionsPropTypes} from '@components/withWindowDimensions'; +import useWindowDimensions from '@hooks/useWindowDimensions'; import compose from '@libs/compose'; import SignInHeroImage from '@pages/signin/SignInHeroImage'; import * as StyleUtils from '@styles/StyleUtils'; @@ -32,20 +32,24 @@ const propTypes = { /** Whether to show welcome header on a particular page */ shouldShowWelcomeHeader: PropTypes.bool.isRequired, + /** Whether to show signIn hero image on a particular page */ + shouldShowSmallScreen: PropTypes.bool.isRequired, + ...withLocalizePropTypes, - ...windowDimensionsPropTypes, }; function SignInPageContent(props) { + const {isSmallScreenWidth} = useWindowDimensions(); const styles = useThemeStyles(); + return ( {/* This empty view creates margin on the top of the sign in form which will shrink and grow depending on if the keyboard is open or not */} - + - + @@ -56,7 +60,7 @@ function SignInPageContent(props) { StyleUtils.getLineHeightStyle(variables.lineHeightSignInHeroXSmall), StyleUtils.getFontSizeStyle(variables.fontSizeSignInHeroXSmall), !props.welcomeText ? styles.mb5 : {}, - !props.isSmallScreenWidth ? styles.textAlignLeft : {}, + !isSmallScreenWidth ? styles.textAlignLeft : {}, styles.mb5, ]} > @@ -64,7 +68,7 @@ function SignInPageContent(props) { ) : null} {props.shouldShowWelcomeText && props.welcomeText ? ( - {props.welcomeText} + {props.welcomeText} ) : null} {props.children} @@ -72,9 +76,9 @@ function SignInPageContent(props) { - {props.isSmallScreenWidth ? ( + {props.shouldShowSmallScreen ? ( - + ) : null} @@ -86,4 +90,4 @@ function SignInPageContent(props) { SignInPageContent.propTypes = propTypes; SignInPageContent.displayName = 'SignInPageContent'; -export default compose(withWindowDimensions, withLocalize, withSafeAreaInsets)(SignInPageContent); +export default compose(withLocalize, withSafeAreaInsets)(SignInPageContent); diff --git a/src/pages/signin/SignInPageLayout/index.js b/src/pages/signin/SignInPageLayout/index.js index a9b48acbd90b..1b5ac55c9da2 100644 --- a/src/pages/signin/SignInPageLayout/index.js +++ b/src/pages/signin/SignInPageLayout/index.js @@ -4,8 +4,8 @@ import {ScrollView, View} from 'react-native'; import {withSafeAreaInsets} from 'react-native-safe-area-context'; import SignInGradient from '@assets/images/home-fade-gradient.svg'; import withLocalize, {withLocalizePropTypes} from '@components/withLocalize'; -import withWindowDimensions, {windowDimensionsPropTypes} from '@components/withWindowDimensions'; import usePrevious from '@hooks/usePrevious'; +import useWindowDimensions from '@hooks/useWindowDimensions'; import compose from '@libs/compose'; import SignInPageHero from '@pages/signin/SignInPageHero'; import * as StyleUtils from '@styles/StyleUtils'; @@ -39,7 +39,7 @@ const propTypes = { innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), /** Whether or not the sign in page is being rendered in the RHP modal */ - isInModal: PropTypes.bool, + shouldShowSmallScreen: PropTypes.bool, /** Override the green headline copy */ customHeadline: PropTypes.string, @@ -47,13 +47,12 @@ const propTypes = { /** Override the smaller hero body copy below the headline */ customHeroBody: PropTypes.string, - ...windowDimensionsPropTypes, ...withLocalizePropTypes, }; const defaultProps = { innerRef: () => {}, - isInModal: false, + shouldShowSmallScreen: false, customHeadline: '', customHeroBody: '', }; @@ -65,12 +64,12 @@ function SignInPageLayout(props) { const prevPreferredLocale = usePrevious(props.preferredLocale); let containerStyles = [styles.flex1, styles.signInPageInner]; let contentContainerStyles = [styles.flex1, styles.flexRow]; - const shouldShowSmallScreen = props.isSmallScreenWidth || props.isInModal; + const {windowHeight} = useWindowDimensions(); // To scroll on both mobile and web, we need to set the container height manually - const containerHeight = props.windowHeight - props.insets.top - props.insets.bottom; + const containerHeight = windowHeight - props.insets.top - props.insets.bottom; - if (shouldShowSmallScreen) { + if (props.shouldShowSmallScreen) { containerStyles = [styles.flex1]; contentContainerStyles = [styles.flex1, styles.flexColumn]; } @@ -96,7 +95,7 @@ function SignInPageLayout(props) { return ( - {!shouldShowSmallScreen ? ( + {!props.shouldShowSmallScreen ? ( {props.children} @@ -167,6 +167,7 @@ function SignInPageLayout(props) { welcomeText={props.welcomeText} shouldShowWelcomeText={props.shouldShowWelcomeText} shouldShowWelcomeHeader={props.shouldShowWelcomeHeader} + shouldShowSmallScreen={props.shouldShowSmallScreen} > {props.children} @@ -197,4 +198,4 @@ const SignInPageLayoutWithRef = forwardRef((props, ref) => ( SignInPageLayoutWithRef.displayName = 'SignInPageLayoutWithRef'; -export default compose(withWindowDimensions, withSafeAreaInsets, withLocalize)(SignInPageLayoutWithRef); +export default compose(withSafeAreaInsets, withLocalize)(SignInPageLayoutWithRef);