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: Workspace settings page design #5804

Merged
merged 2 commits into from
Oct 18, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 8 additions & 0 deletions src/pages/workspace/WorkspacePageWithSections.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,24 @@ const propTypes = {

/** From Onyx */
reimbursementAccount: reimbursementAccountPropTypes,
parasharrajat marked this conversation as resolved.
Show resolved Hide resolved

/** User Data from Onyx */
user: userPropTypes,

/** Main content of the page */
children: PropTypes.func,

/** Content to be added as fixed footer */
footer: PropTypes.element,

...withLocalizePropTypes,
};

const defaultProps = {
children: () => {},
user: {},
reimbursementAccount: {},
footer: null,
Comment on lines 49 to +52
Copy link
Contributor

Choose a reason for hiding this comment

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

NAB; I think it could be nice to alphabetize these props or put them in the order they appear in propTypes. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

Usually, we keep the capital case for props that are a Component but here I am passing an element.

so if we want to use the footer as <Footer> then it will make more sense.

So, I think this is fine.

};

class WorkspacePageWithSections extends React.Component {
Expand Down Expand Up @@ -73,6 +80,7 @@ class WorkspacePageWithSections extends React.Component {

</View>
</ScrollView>
{this.props.footer}
</ScreenWrapper>
);
}
Expand Down
105 changes: 51 additions & 54 deletions src/pages/workspace/WorkspaceSettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,64 +136,61 @@ class WorkspaceSettingsPage extends React.Component {
<WorkspacePageWithSections
headerText={this.props.translate('workspace.common.settings')}
route={this.props.route}
footer={(
<FixedFooter style={[styles.w100]}>
<Button
success
isLoading={policy.isPolicyUpdating}
text={this.props.translate('workspace.editor.save')}
onPress={this.submit}
pressOnEnter
/>
</FixedFooter>
)}
>
{hasVBA => (
<>
<View style={[styles.pageWrapper, styles.flex1, styles.pRelative, styles.flexGrow1]}>
<View style={[styles.w100, styles.flexGrow1]}>
<AvatarWithImagePicker
isUploading={policy.isAvatarUploading}
avatarURL={this.state.previewAvatarURL}
size={CONST.AVATAR_SIZE.LARGE}
DefaultAvatar={() => (
<Icon
src={Workspace}
height={80}
width={80}
fill={defaultTheme.iconSuccessFill}
/>
)}
style={[styles.mb3]}
anchorPosition={{top: 172, right: 18}}
isUsingDefaultAvatar={!this.state.previewAvatarURL}
onImageSelected={this.uploadAvatar}
onImageRemoved={this.removeAvatar}
/>

<ExpensiTextInput
label={this.props.translate('workspace.editor.nameInputLabel')}
containerStyles={[styles.mt4]}
onChangeText={name => this.setState({name})}
value={this.state.name}
hasError={!this.state.name.trim().length}
errorText={this.state.name.trim().length ? '' : this.props.translate('workspace.editor.nameIsRequiredError')}
/>

<View style={[styles.mt4]}>
<ExpensiPicker
label={this.props.translate('workspace.editor.currencyInputLabel')}
onChange={currency => this.setState({currency})}
items={this.getCurrencyItems()}
value={this.state.currency}
isDisabled={hasVBA}
/>
</View>
<Text style={[styles.textLabel, styles.colorMuted, styles.mt2]}>
{this.props.translate('workspace.editor.currencyInputHelpText')}
</Text>
</View>

<FixedFooter style={[styles.w100]}>
<Button
success
isLoading={policy.isPolicyUpdating}
text={this.props.translate('workspace.editor.save')}
onPress={this.submit}
pressOnEnter
<View style={[styles.pageWrapper, styles.flex1, styles.alignItemsStretch]}>
<AvatarWithImagePicker
isUploading={policy.isAvatarUploading}
avatarURL={this.state.previewAvatarURL}
size={CONST.AVATAR_SIZE.LARGE}
DefaultAvatar={() => (
<Icon
src={Workspace}
height={80}
width={80}
fill={defaultTheme.iconSuccessFill}
/>
</FixedFooter>
)}
style={[styles.mb3]}
anchorPosition={{top: 172, right: 18}}
isUsingDefaultAvatar={!this.state.previewAvatarURL}
onImageSelected={this.uploadAvatar}
onImageRemoved={this.removeAvatar}
/>

<ExpensiTextInput
label={this.props.translate('workspace.editor.nameInputLabel')}
containerStyles={[styles.mt4]}
onChangeText={name => this.setState({name})}
value={this.state.name}
hasError={!this.state.name.trim().length}
errorText={this.state.name.trim().length ? '' : this.props.translate('workspace.editor.nameIsRequiredError')}
/>

<View style={[styles.mt4]}>
<ExpensiPicker
label={this.props.translate('workspace.editor.currencyInputLabel')}
onChange={currency => this.setState({currency})}
items={this.getCurrencyItems()}
value={this.state.currency}
isDisabled={hasVBA}
/>
</View>
</>
<Text style={[styles.textLabel, styles.colorMuted, styles.mt2]}>
{this.props.translate('workspace.editor.currencyInputHelpText')}
</Text>
</View>
)}
</WorkspacePageWithSections>
);
Expand Down
4 changes: 4 additions & 0 deletions src/styles/utilities/flex.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ export default {
alignItems: 'baseline',
},

alignItemsStretch: {
alignItems: 'stretch',
},

flexWrap: {
flexWrap: 'wrap',
},
Expand Down