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

fix: LoginPage for wide screens #6137

Merged
merged 8 commits into from
Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes from 7 commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import TermsAndLicenses from '../TermsAndLicenses';
import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize';
import Form from '../../../components/Form';
import compose from '../../../libs/compose';
import scrollViewContentContainerStyles from './signInPageStyles.js';
import scrollViewContentContainerStyles from './signInPageStyles';
import LoginKeyboardAvoidingView from './LoginKeyboardAvoidingView';
import withKeyboardState from '../../../components/withKeyboardState';
import withWindowDimensions, {windowDimensionsPropTypes} from '../../../components/withWindowDimensions';

const propTypes = {
/** The children to show inside the layout */
Expand All @@ -26,31 +27,35 @@ const propTypes = {
/** Whether to show welcome text on a particular page */
shouldShowWelcomeText: PropTypes.bool.isRequired,

/** SafeArea insets */
insets: PropTypes.shape(PropTypes.object),

...withLocalizePropTypes,
...windowDimensionsPropTypes,
};

const defaultProps = {
insets: {},
};

const SignInPageLayoutNarrow = props => (
const SignInPageContent = props => (
<ScrollView
keyboardShouldPersistTaps="handled"
showsVerticalScrollIndicator={false}
style={[
styles.h100,
styles.alignSelfCenter,
!props.isSmallScreenWidth && styles.signInPageWideLeftContainer,
]}
contentContainerStyle={[
scrollViewContentContainerStyles,
!props.isSmallScreenWidth && styles.ph6,
]}
contentContainerStyle={scrollViewContentContainerStyles}
>
<Form style={[styles.flex1, styles.signInPageNarrowContentContainer, styles.alignSelfStretch, styles.ph5]}>
<Form style={[
styles.flex1,
styles.alignSelfStretch,
props.isSmallScreenWidth && styles.signInPageNarrowContentContainer,
props.isSmallScreenWidth ? styles.ph5 : styles.ph4,
]}
>
Comment on lines +48 to +54
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation looks a little weird here. Maybe ]}>?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it's totally fine. There are two ways here.
This one
e.g.

<View style={[
(this.state.isFocused || this.state.isDraggingOver)
? styles.chatItemComposeBoxFocusedColor
: styles.chatItemComposeBoxColor,
styles.chatItemComposeBox,
styles.flexRow,
]}
>

and

        <Form
            style={[
                styles.flex1,
                styles.alignSelfStretch,
                props.isSmallScreenWidth && styles.signInPageNarrowContentContainer,
                props.isSmallScreenWidth ? styles.ph5 : styles.ph4,
            ]}
        >

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, Ok well that's fine with me. This was a NAB.

<LoginKeyboardAvoidingView
behavior="position"
contentContainerStyle={[
styles.mt40Percentage,
props.isSmallScreenWidth ? styles.signInPageNarrowContentMargin : styles.signInPageWideLeftContentMargin,
styles.mb3,
StyleUtils.getModalPaddingStyles({
shouldAddBottomSafeAreaPadding: true,
Expand All @@ -59,7 +64,11 @@ const SignInPageLayoutNarrow = props => (
}),
]}
>
<View style={[styles.componentHeightLarge, styles.mb2]}>
<View style={[
styles.componentHeightLarge,
...(props.isSmallScreenWidth ? [styles.mb2] : [styles.mt6, styles.mb5]),
]}
>
<ExpensifyCashLogo
width={variables.componentSizeLarge}
height={variables.componentSizeLarge}
Expand All @@ -73,18 +82,20 @@ const SignInPageLayoutNarrow = props => (
{props.children}
</LoginKeyboardAvoidingView>
</Form>
<View style={[styles.mb5, styles.alignSelfCenter, styles.signInPageNarrowContentContainer, styles.ph5]}>
<View style={[styles.mb5, styles.alignSelfCenter, props.isSmallScreenWidth && styles.signInPageNarrowContentContainer, styles.ph5]}>
<TermsAndLicenses />
</View>
</ScrollView>
);

SignInPageLayoutNarrow.propTypes = propTypes;
SignInPageLayoutNarrow.defaultProps = defaultProps;
SignInPageLayoutNarrow.displayName = 'SignInPageLayoutNarrow';
SignInPageContent.propTypes = propTypes;
SignInPageContent.displayName = 'SignInPageContent';

export default compose(
withWindowDimensions,
withLocalize,

// KeyboardState HOC is needed to trigger recalculation of the UI when keyboard opens or closes
withKeyboardState,
withSafeAreaInsets,
)(SignInPageLayoutNarrow);
)(SignInPageContent);
85 changes: 0 additions & 85 deletions src/pages/signin/SignInPageLayout/SignInPageLayoutWide.js

This file was deleted.

41 changes: 41 additions & 0 deletions src/pages/signin/SignInPageLayout/SignInPageWideContainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React from 'react';
import {View} from 'react-native';
import PropTypes from 'prop-types';
import SVGImage from '../../../components/SVGImage';
import styles from '../../../styles/styles';
import * as StyleUtils from '../../../styles/StyleUtils';
import withWindowDimensions, {windowDimensionsPropTypes} from '../../../components/withWindowDimensions';

const propTypes = {
/** The children to show inside the Container */
children: PropTypes.node.isRequired,

...windowDimensionsPropTypes,
};

const backgroundStyle = StyleUtils.getLoginPagePromoStyle();

const SignInPageWideContainer = props => (
<View style={[styles.flex1, styles.signInPageInner]}>
<View style={[styles.flex1, styles.flexRow, styles.flexGrow1]}>
{props.children}
<View style={[
styles.flexGrow1,
StyleUtils.getBackgroundColorStyle(backgroundStyle.backgroundColor),
props.isMediumScreenWidth && styles.alignItemsCenter,
]}
>
<SVGImage
width="100%"
height="100%"
src={backgroundStyle.backgroundImageUri}
/>
</View>
</View>
</View>
);

SignInPageWideContainer.propTypes = propTypes;
SignInPageWideContainer.displayName = 'SignInPageWideContainer';

export default withWindowDimensions(SignInPageWideContainer);
40 changes: 18 additions & 22 deletions src/pages/signin/SignInPageLayout/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import SignInPageLayoutNarrow from './SignInPageLayoutNarrow';
import SignInPageLayoutWide from './SignInPageLayoutWide';
import SignInPageContent from './SignInPageContent';
import SignInPageWideContainer from './SignInPageWideContainer';
import withWindowDimensions, {windowDimensionsPropTypes} from '../../../components/withWindowDimensions';

const propTypes = {
Expand All @@ -18,26 +18,22 @@ const propTypes = {
...windowDimensionsPropTypes,
};

const SignInPageLayout = props => (
!props.isSmallScreenWidth
? (
<SignInPageLayoutWide
welcomeText={props.welcomeText}
isMediumScreenWidth={props.isMediumScreenWidth}
shouldShowWelcomeText={props.shouldShowWelcomeText}
>
{props.children}
</SignInPageLayoutWide>
)
: (
<SignInPageLayoutNarrow
welcomeText={props.welcomeText}
shouldShowWelcomeText={props.shouldShowWelcomeText}
>
{props.children}
</SignInPageLayoutNarrow>
)
);
const SignInPageLayout = (props) => {
const content = (
<SignInPageContent
welcomeText={props.welcomeText}
shouldShowWelcomeText={props.shouldShowWelcomeText}
>
{props.children}
</SignInPageContent>
);

if (props.isSmallScreenWidth) {
return content;
}

return <SignInPageWideContainer>{content}</SignInPageWideContainer>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there really an advantage to having the SignInPageWideContainer be its own component? I think it'd be better for us to get rid of the SignInPageWideContainer altogether and have the View and SVG components it contains live here in this file instead. In other words, why have these as two files when it's not really complicated to have them be one?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks clean this way but let me know I can merge.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just merged. Thanks for the suggestion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I appreciate your willingness to do that. 👍

};

SignInPageLayout.propTypes = propTypes;
SignInPageLayout.displayName = 'SignInPageLayout';
Expand Down
9 changes: 9 additions & 0 deletions src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -811,8 +811,17 @@ const styles = {
maxWidth: 335,
},

signInPageNarrowContentMargin: {
marginTop: '40%',
},

signInPageWideLeftContainer: {
width: 375,
maxWidth: 375,
},

signInPageWideLeftContentMargin: {
marginTop: '44.5%',
},

signInPageWideHeroContent: {
Expand Down
4 changes: 0 additions & 4 deletions src/styles/utilities/spacing.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,6 @@ export default {
marginTop: 24,
},

mt40Percentage: {
marginTop: '40%',
},

mb0: {
marginBottom: 0,
},
Expand Down