-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Update app modal design refactor #1973
Update app modal design refactor #1973
Conversation
….cash into sameera-update-app-modal-refactor
src/styles/getModalStyles.js
Outdated
|
||
borderRadius: 12, | ||
overflow: 'hidden', | ||
width: isSmallScreenWidth ? '90%' : windowWidth * 0.3, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want to have a fixed width on all non-small screens, so I think just using 375 (the same width as the sidebar) works.
For small screens, I think it makes sense to repeat the bottomDocked modal pattern here where it would look something like:
cc @roryabraham
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shawnborton Sure. I'll update the changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think of a "confirm" modal as having modal which is sized like the one you have here, but which also:
- Does not have an
x
to close in the header - Has two buttons, one "confirm" button and one "cancel", both of which should close the modal
This is a very common reusable pattern for a modal, so I'd like to see it created as it's own component. You could call it ConfirmModal
, and give it props like this:
const propTypes = {
title: PropTypes.string.isRequired,
onConfirm: PropTypes.func.isRequired,
onCancel: PropTypes.func.isRequired,
confirmText: PropTypes.string,
cancelText: PropTypes.string,
prompt: PropTypes.string,
};
const defaultProps = {
confirmText: 'Yes',
cancelText: 'No',
prompt: '',
};
That component would internally use withWindowDimensions
, and be BottomDocked
on small screens and confirm
on wider screens. Then BaseUpdateAppModal
can use the ConfirmModal
.
@@ -33,31 +35,42 @@ class BaseUpdateAppModal extends PureComponent { | |||
onSubmit={this.submitAndClose} | |||
onClose={() => this.setState({isModalOpen: false})} | |||
isVisible={this.state.isModalOpen} | |||
type={this.props.isSmallScreenWidth | |||
? CONST.MODAL.MODAL_TYPE.BOTTOM_DOCKED : CONST.MODAL.MODAL_TYPE.CONFIRM} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NAB typically we format multiline ternaries like this:
const result = condition
? valueIfTrue
: valueIfFalse;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll update it.
Update now or restart the app at a later time to download the latest changes. | ||
</Text> | ||
{this.props.onSubmit && ( | ||
<View style={[styles.m5]}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for square brackets if it's just a single style.
<View style={[styles.m5]}> | |
<View style={styles.m5}> |
</Text> | ||
{this.props.onSubmit && ( | ||
<View style={[styles.m5]}> | ||
<View style={[styles.flexRow]}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<View style={[styles.flexRow]}> | |
<View style={styles.flexRow}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does the header need to be wrapped in a view w/ flexRow
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because <Header>
component does have another view and it has flex1
.
In other places <Header>
component is used inside a <view>
with flexRow
.
If I remove flexRow
from here it won't show in the mobile app.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thanks for explaining.
I will do it accordingly. But I have few questions.
|
Hmmm, this is a bit contrary to how our other modals typically work. We should give |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good, just some minor code style comments. Also, since you just have one file in the ConfirmModal
module, you don't need it to be a directory. You can just move src/components/ConfirmModal/index.js
to src/components/ConfirmModal.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks for the quick turnaround. Code looks good. I tested it out a bit too and it seems to work well. However, can you please be sure to retest on all platforms and provide screenshots for @shawnborton to re-review. In my opinion, the font size for the prompt maybe looks a bit small and has maybe too large a top margin, but otherwise all looks good.
Thanks @roryabraham |
Could you please update the screenshots in the original comment of this PR? |
@shawnborton PR comment updated with latest screenshots. |
src/components/ConfirmModal.js
Outdated
<Header title={props.title} /> | ||
</View> | ||
|
||
<Text style={[styles.textLabel, styles.mt4]}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use styles.textP
here please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, this is not a blocker but I think I prefer adding margin to the bottom of the modal header as opposed to the top of this text block.
src/components/ConfirmModal.js
Outdated
style={[ | ||
styles.buttonText, | ||
styles.buttonSuccessText, | ||
styles.buttonConfirmText, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does buttonConfirmText
do versus buttonSuccessText
? I'm not entirely sure why buttonConfirmText
exists, it looks like it just adds padding to the left and the right but I actually don't think we need it. I would suggest we remove this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. styles.buttonConfirmText
is for add horizontal padding. Seems we don't need it here. I'll remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thank you! Changes look good, you'll just need to update the screenshots again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Screenshots updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interestingly, I noticed the same thing but didn't comment because the view component doesn't support the focusable prop in react-native-web 14. @SameeraMadushan If you wanted, however, you could update react-native-web to v15, which now supports that prop. https://github.com/necolas/react-native-web/releases/tag/0.15.0 |
Thanks for the suggestion @roryabraham. Setting |
Hooray! ....hopefully we don't break anything 😬 |
We'll also need to upgrade to react 17 |
Tested with all platforms. It works without any regression. |
Well, I just noticed that react 17 is listed as a peer dependency, which makes me more nervous to greenlight this change. |
Thanks for looking into that! Since it's already a pre-existing issue with our app and it requires updating some libs that would affect all functionality, I suggest we do this in a different PR. @SameeraMadushan can we revert the update to react-native-web and hold off on updating react to 17 in this PR? We can create a new issue for the blue border and handle it separately. |
@roryabraham I see react 17 used in react native 0.64. So it's a bit hard to predict what will happen. |
Yeah, sorry for the go-around here @SameeraMadushan, let's tackle this later. |
This reverts commit f16ff72.
@SameeraMadushan Hello! This PR looks like internal QA. If so, can you let me know when it's QA'd in staging so I can check it off the deploy list? Thanks in advance! |
@isagoico, in this case there's really no easy way to QA the issue on staging, so feel free to check it off the deploy list. |
Details
Update modal design modified with adding a new modal type called
CONFIRM
.Also
HeaderWithCloseButton
replaced with theHeader
component insideBaseUpdateAppModal
Fixed Issues
Fixes #1853
Tests
To view the update modal temporarily you have to set visibility to true. To do that you can do the following.
this.props.updateAvailable
to!this.props.updateAvailable
inExpensify.js
Tested On
Screenshots
Web
Web - small screen
Mobile Web
Desktop
iOS
Android