Skip to content

Create Right-Docked Settings Modal - #1325

Merged
yuwenmemon merged 14 commits into
masterfrom
yuwen-settingsModal
Jan 27, 2021
Merged

yuwenmemon merged 14 commits into
masterfrom
yuwen-settingsModal

Conversation

@yuwenmemon

@yuwenmemon yuwenmemon commented Jan 25, 2021 •

Copy link
Copy Markdown
Contributor

@marcaaron please review

Details

Create a right-docked settings modal.

Fixed Issues

Fixes https://github.com/Expensify/Expensify/issues/150956

Tests

  • For each of the formats below, click on the user icon to bring up the settings modal.
  • X out of the settings modal, make sure that you are brought back to the report you were viewing before.

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Web

Kapture 2021-01-26 at 16 22 06

Mobile Web

Kapture 2021-01-26 at 18 10 22

Desktop

Kapture 2021-01-25 at 19 10 47

iOS

Kapture 2021-01-25 at 20 38 28

Android

Kapture 2021-01-25 at 21 02 20

@yuwenmemon
yuwenmemon requested a review from marcaaron January 25, 2021 22:09
@yuwenmemon
yuwenmemon requested a review from a team as a code owner January 25, 2021 22:09
@yuwenmemon yuwenmemon self-assigned this Jan 25, 2021
@github-actions

github-actions Bot commented Jan 25, 2021 •

Copy link
Copy Markdown
Contributor

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@botify
botify requested review from madmax330 and removed request for a team January 25, 2021 22:09

@marcaaron marcaaron left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great so far! Just leaving early feedback since it's still in WIP.

Comment thread src/pages/home/MainView.js Outdated
class MainView extends Component {
render() {
const reportIDInUrl = parseInt(this.props.match.params.reportID, 10);
let activeReportID = parseInt(this.props.match.params.reportID, 10);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm curious what would happen if we simply stopped relying on the match params here. IIRC we should be updating the currentlyViewedReportID when we hit one of these routes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

By that you mean just doing

activeReportID = parseInt(this.props.currentlyViewedReportID, 10);

always, right?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah exactly. I'm trying to think of a time when the reportID in the URL wouldn't be the currentlyViewedReportID and not sure there is one. If we don't need it then the logic in this file becomes a little simpler and we can stop making an exception for the settings route.

Comment thread src/styles/getModalStyles.js Outdated
case CONST.MODAL.MODAL_TYPE.RIGHT_DOCKED:
modalStyle = {
margin: 0,
flexDirection: 'row-reverse',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this doing anything? I think it would be flex-end that would move the modal to the right of the screen.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was following the flex-direction example here: https://reactnative.dev/docs/flexbox#flex-direction

If I remove this then the modal goes to the left side.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cool. I guess it works then? If your width was 100% of the screen then I'd think flex-end would stick it at the right side but didn't really dig too much into what this is doing

@yuwenmemon yuwenmemon Jan 26, 2021 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think I see what you're saying. Switched this up to use row and end below.

Comment thread src/styles/getModalStyles.js Outdated
break;
case CONST.MODAL.MODAL_TYPE.RIGHT_DOCKED:
modalStyle = {
margin: 0,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

NAB, pretty much every modal has this margin: 0 on it. I wonder if this should just be a default for all of them.

Comment thread src/styles/getModalStyles.js Outdated
justifyContent: 'end',
};
modalContainerStyle = {
width: isSmallScreen ? '100%' : '40%',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

cc @shawnborton we might want to use a constant for the right side pane instead of the 40%? I know there wasn't really a clear guideline for this part.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah maybe a max-width? 450px maybe?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What if we just reuse the variable for the LHN? So basically at mobile breakpoints, this should take up the whole screen (like the LHN) but at wider desktops, this should share the same LHN variable which would make it 375px. This is what we've been doing in all of our mockups.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@yuwenmemon I think you'll need to pull master, and then you should find sideBarWidth: 375 inside of variables.js

Comment thread src/styles/getModalStyles.js Outdated
height: '100%',
overflow: 'hidden',
marginRight: 0,
paddingTop: 0,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

NAB, I haven't looked yet but who/what is adding margin and padding that we need to reset it? Maybe it would be better to only add margin/padding to the places that need it instead of override it here.

Comment thread src/components/SettingsModal.js Outdated
>
<View>
<SettingsPage />
</View>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need this extra View?

@yuwenmemon

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@yuwenmemon

Copy link
Copy Markdown
Contributor Author

recheck

@yuwenmemon yuwenmemon changed the title [WIP] Create Right-Docked Settings Modal Create Right-Docked Settings Modal Jan 26, 2021
@yuwenmemon

Copy link
Copy Markdown
Contributor Author

Removing WIP

@shawnborton

shawnborton commented Jan 26, 2021 •

Copy link
Copy Markdown
Contributor

One small thing I found (maybe not related to this PR at all) is that when you launch the settings sidepane modal, the active style of the LHN row, where the background is a darker color, goes away:

Settings open:
image

Screen Shot 2021-01-26 at 10 31 10 AM

Settings closed:
image

@marcaaron

Copy link
Copy Markdown
Contributor

@shawnborton Interesting, is it disappearing or is it just the same color as the overlay?

@shawnborton

Copy link
Copy Markdown
Contributor

It's actually disappearing, the property gets removed.

Comment thread src/components/SettingsModal.js Outdated
currentlyViewedReportID: '',
};

class SettingsModal extends Component {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

NAB, we can probably make this a stateless functional component by using an anonymous arrow function for the onClose method.

Comment thread src/pages/SettingsPage.js Outdated
</Text>
</TouchableOpacity>
</View>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

NAB, new line

Comment thread src/pages/home/HomePage.js Outdated
/>
{this.props.currentURL === '/settings' && <SettingsPage />}
<SettingsModal
isVisible={this.props.currentURL === '/settings'}

@marcaaron marcaaron Jan 26, 2021 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

NAB, this was left by someone else but can we take this opportunity to update /settings to use the constant in ROUTES?

Comment thread src/pages/home/MainView.js Outdated
class MainView extends Component {
render() {
const reportIDInUrl = parseInt(this.props.match.params.reportID, 10);
let activeReportID = parseInt(this.props.match.params.reportID, 10);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah exactly. I'm trying to think of a time when the reportID in the URL wouldn't be the currentlyViewedReportID and not sure there is one. If we don't need it then the logic in this file becomes a little simpler and we can stop making an exception for the settings route.

@marcaaron

Copy link
Copy Markdown
Contributor

Tests great and looks real nice so far. Left some NABs. And I'm still curious if we can just ditch the match params for reportIDInUrl. Also noticed that the header and LHN row are disappearing in some cases (probably because they are also relying on the reportIDInUrl)

2021-01-26_07-06-41.mp4

Comment thread src/pages/home/HeaderView.js
shawnborton
shawnborton previously approved these changes Jan 26, 2021
@shawnborton

Copy link
Copy Markdown
Contributor

Signing off for the night, so don't block on me if you want to merge this today. I think we just need to update the screenshots and make sure the side modal on desktop is 375px wide. Nice work @yuwenmemon !

@marcaaron marcaaron left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good two more small comments.

Comment thread src/components/SettingsModal.js Outdated
const SettingsModal = props => (
<ModalWithHeader
type={CONST.MODAL.MODAL_TYPE.RIGHT_DOCKED}
onClose={() => redirect(ROUTES.getReportRoute(props.currentlyViewedReportID))}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This seems like a minor regression from what we were doing before. Which is, cover the case where currentlyViewedReportID has no value.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah yep, missed that - nice catch.

Comment thread src/components/SettingsModal.js
Comment thread src/pages/home/HeaderView.js
Comment thread src/styles/getModalStyles.js Outdated
// viewed on a smaller device (e.g. mobile or mobile web).
modalStyle = {
margin: 0,
modalStyle = _.extend(modalStyle, {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

NAB, I believe we have more or less standardized on using spread operator instead of _.extend but could be wrong about that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually yes double checked, there are 0 usages in the codebase. For consistency, maybe we can stick to just using spread operator? Mostly my concern is that we will have 2 ways of doing one thing. Just like we shouldn't be mixing Array.map and _.map we shouldn't be using {...something} and _.extend(something, {});

Comment thread src/pages/home/HeaderView.js
@yuwenmemon

Copy link
Copy Markdown
Contributor Author

Updated, and updated the Web GIF to be more up to date

Comment thread src/pages/home/sidebar/SidebarLinks.js Outdated
: [styles.sidebarHeader];

const {recentReports} = getSidebarOptions(props.reports, props.personalDetails, props.draftComments, reportIDInUrl);
const {recentReports} = getSidebarOptions(props.reports, props.personalDetails, props.draftComments, activeReportID);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should fix this. It's a warning but we are treating them as not optional. I have an open issue to make this more clear.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah, sorry didn't realize what you were referring to at first. You're referring to the fact that this is a linter warning.

@marcaaron

Copy link
Copy Markdown
Contributor

This is looking good to me and testing well. However, the out animation looks a little fast on web (almost like it's not happening at all?). also, the mobile web video seems to just be web at a mobile resolution. We should make sure we are testing mobile web by using something like iOS simulator + Safari.

@marcaaron

Copy link
Copy Markdown
Contributor

Looks like the animations for the side bar are not happening on Android. iOS looks ok though.

@yuwenmemon

yuwenmemon commented Jan 27, 2021 •

Copy link
Copy Markdown
Contributor Author

This is looking good to me and testing well. However, the out animation looks a little fast on web (almost like it's not happening at all?)

So, it's odd - for whatever reason on browsers the out animation is faster than the in (was the same case in Safari as Chrome).
In: 300, Out: 900
Kapture 2021-01-26 at 17 55 42

But then doing that makes it super slow on mobile:
Kapture 2021-01-26 at 17 56 39

@marcaaron

Copy link
Copy Markdown
Contributor

Oh hmm, that is super weird. Maybe it's a bug within the modal library. Either way we don't necessarily have to worry about it now.

@marcaaron

Copy link
Copy Markdown
Contributor

Once work-around could be to set a different animationOutTiming value for web... but ideally we could figure out why they are different.

@yuwenmemon

yuwenmemon commented Jan 27, 2021 •

Copy link
Copy Markdown
Contributor Author

the mobile web video seems to just be web at a mobile resolution. We should make sure we are testing mobile web by using something like iOS simulator + Safari.

Done - updated OP

Looks like the animations for the side bar are not happening on Android.

Yeah... I have no idea why this is happening... 😕 In general, my android emulator is pretty laggy so it's been hard to see anyway.

EDIT: Okay, from what I can gather, looks like android suffers from the same inconsistency that web does vs iOS. Lowering the animation speeds brought the animation back. Seems like android likes to slow down a bunch at the end, hence why at the faster speeds it looks like it does not have any animation
In 2000 / Out 2000
Kapture 2021-01-26 at 18 27 01

@yuwenmemon

Copy link
Copy Markdown
Contributor Author

@marcaaron do we want to worry about the modal animation timing inconsistency across platforms for now or not?

@marcaaron

Copy link
Copy Markdown
Contributor

It would be nice to know why if we can look into it now. But it's up to you. I'm also fine with creating a new issue to follow up.

@yuwenmemon

Copy link
Copy Markdown
Contributor Author

@marcaaron dug around for an hour or so, didn't really get anywhere so I vote we move forward and just create a new issue to follow up.

@marcaaron

Copy link
Copy Markdown
Contributor

Ok I agree. One follow-up idea is to see if this is just generally reproducible and then create an issue in react-native-modal. It would be good to know if we are holding it wrong or if there is a bug. Then we can add that context to the issue.

Separately, there are a couple of unresolved comments from me here. Other than that I am 👍

@yuwenmemon

Copy link
Copy Markdown
Contributor Author

Yeah, I'd also want to try it on real devices as opposed to simulators.

Also, I believe there was just the one comment about style. Sorry, didn't understand what you were saying at first. But I'm not sure there are any others? If you could point them out that would be helpful.

@marcaaron

Copy link
Copy Markdown
Contributor

Looks great thanks!

@yuwenmemon
yuwenmemon merged commit ea7a327 into master Jan 27, 2021
@yuwenmemon
yuwenmemon deleted the yuwen-settingsModal branch January 27, 2021 23:54
@github-actions github-actions Bot locked and limited conversation to collaborators Jan 27, 2021
@shawnborton

Copy link
Copy Markdown
Contributor

Looks great! I agree, let's please do a follow up issue for finessing the animation style.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants