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

Inset the full screen modal used for workspaces on large devices #3887

Merged
merged 9 commits into from
Aug 9, 2021

Conversation

HorusGoul
Copy link
Contributor

@HorusGoul HorusGoul commented Jul 6, 2021

cc @marcaaron

Details

Added the expected spacing around the full-screen modals without modifying too many things.

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/169135

Tests / QA Steps

Using a large screen (like the web version or the desktop app):

  1. Create a new workspace
  2. Go to its settings page
  3. Verify that the full-screen modal is separated from the window border and that its corners are rounded, like this photo:
    image

Using a small screen (mobile version):

  1. Create a new workspace
  2. Go to its settings page
  3. Verify that the full-screen modal is not separated from the window border and has no rounded corners, like in this photo:
    image

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Web

image

Mobile Web

image

Desktop

image

iOS

image

Android

image

@HorusGoul HorusGoul self-assigned this Jul 6, 2021
@HorusGoul HorusGoul requested a review from marcaaron July 6, 2021 15:48
@HorusGoul HorusGoul marked this pull request as ready for review July 6, 2021 15:48
@HorusGoul HorusGoul requested a review from a team as a code owner July 6, 2021 15:48
@MelvinBot MelvinBot requested review from joelbettner and removed request for a team July 6, 2021 15:48
@HorusGoul
Copy link
Contributor Author

Should we set the overlay background color to the one used in the Figma design or leave it as rgba(0, 0, 0, 0.5)?

@shawnborton
Copy link
Contributor

I think we should already have a color variable for the correct overlay color. If you launch an attachment modal from a chat, you should see what I mean.

@HorusGoul HorusGoul marked this pull request as draft July 6, 2021 15:53
@HorusGoul
Copy link
Contributor Author

Done! I had to create a new component to customize the background color. Let me know what you think about the changes.

@HorusGoul HorusGoul marked this pull request as ready for review July 6, 2021 16:18
@shawnborton
Copy link
Contributor

Mind sharing a screenshot?

@marcaaron
Copy link
Contributor

I'm not sure if this is a blocker, but interacting with the backdrop won't dismiss this modal.

Copy link
Contributor

@marcaaron marcaaron left a comment

Choose a reason for hiding this comment

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

Mostly LGTM! But did have some questions


if (!props.isSmallScreenWidth) {
return (
<View style={styles.navigationSceneFullScreenWrapper}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we change only the styles passed to sceneContainerStyle? Why is the additional View necessary? Asking mostly because it would make this logic a bit cleaner without having to create the content variable, but not a blocker.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's what I tried first, and I found that the sceneContainerStyle targets a different UI component.

Adding the View wrapper was necessary because it was the only way to wrap the Drawer and the Screen contents and apply the rounded corners to them.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it. Does having the extra View around everything else cause issues as well? Something like

<View style={props.isSmallScreenWidth ? styles.navigationSceneFullScreenWrapper : undefined}>
     ... other stuff

Copy link
Contributor

Choose a reason for hiding this comment

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

Also no worries if there is no way to keep all the JSX together. I think it's just easier to parse without the content variable.

* @param {Boolean} isSmallScreenWidth
* @returns {Object}
*/
function getNavigationDrawerStyle(windowWidth, windowHeight, isSmallScreenWidth) {
function getNavigationDrawerStyle(isSmallScreenWidth) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity, is this change just clean up or were the non relative width/height causing some issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, the non-relative values were causing issues after I added the spacing around the modal (essentially, the modal wasn't respecting the parent's right and bottom padding), so I ended up making all the sizes relative to fix the issue.

An alternative to this was subtracting spacing size * 2 from the absolute values, but that was a worse solution IMO.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, the non-relative values were causing issues after I added the spacing around the modal (essentially, the modal wasn't respecting the parent's right and bottom padding), so I ended up making all the sizes relative to fix the issue.

Got it, thanks. I think maybe in this case it would be good to add that context in a comment since a future change could undo that and the reasoning for these values is not very clear.

An alternative to this was subtracting spacing size * 2 from the absolute values, but that was a worse solution IMO.

That does sound more complicated.

left: 0,
width: '100%',
height: '100%',
opacity: 0.5,
Copy link
Contributor

Choose a reason for hiding this comment

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

This style should be moved into styles.js. We have standardized on avoiding inline styles and there is some more explanation here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@HorusGoul
Copy link
Contributor Author

HorusGoul commented Jul 7, 2021

@shawnborton

Mind sharing a screenshot?

image

@HorusGoul
Copy link
Contributor Author

@marcaaron

I'm not sure if this is a blocker, but interacting with the backdrop won't dismiss this modal.

We could use a Touchable inside the CardOverlay to handle these interactions. However, the visible surface of the overlay is tiny (20px per side), so it may not add that much value.

Have we considered adding support for the Esc key to close modals? I think that would be more suited for this use case.

@HorusGoul HorusGoul requested a review from marcaaron July 7, 2021 10:25
@marcaaron
Copy link
Contributor

We could use a Touchable inside the CardOverlay to handle these interactions. However, the visible surface of the overlay is tiny (20px per side), so it may not add that much value.

I'll defer to @shawnborton on this one. I see your point about the small surface, but also can see an argument where the universal expected behavior for a backdrop behind a modal (however small) would be to dismiss the modal. No strong feelings on it though :)

Have we considered adding support for the Esc key to close modals? I think that would be more suited for this use case.

esc key should already be enabled, yes

Copy link
Contributor

@marcaaron marcaaron left a comment

Choose a reason for hiding this comment

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

Code changes look good, but I think this PR is introducing a regression as the height expands much larger than the screen size. See video:

2021-07-07_07-14-21.mp4


if (!props.isSmallScreenWidth) {
return (
<View style={styles.navigationSceneFullScreenWrapper}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Got it. Does having the extra View around everything else cause issues as well? Something like

<View style={props.isSmallScreenWidth ? styles.navigationSceneFullScreenWrapper : undefined}>
     ... other stuff


if (!props.isSmallScreenWidth) {
return (
<View style={styles.navigationSceneFullScreenWrapper}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Also no worries if there is no way to keep all the JSX together. I think it's just easier to parse without the content variable.

* @param {Boolean} isSmallScreenWidth
* @returns {Object}
*/
function getNavigationDrawerStyle(windowWidth, windowHeight, isSmallScreenWidth) {
function getNavigationDrawerStyle(isSmallScreenWidth) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, the non-relative values were causing issues after I added the spacing around the modal (essentially, the modal wasn't respecting the parent's right and bottom padding), so I ended up making all the sizes relative to fix the issue.

Got it, thanks. I think maybe in this case it would be good to add that context in a comment since a future change could undo that and the reasoning for these values is not very clear.

An alternative to this was subtracting spacing size * 2 from the absolute values, but that was a worse solution IMO.

That does sound more complicated.

@shawnborton
Copy link
Contributor

I don't feel strongly about the outside area being clickable. I agree with Marc though that it is expected behavior, but I could live without it here. I feel like the Esc key is more useful though so if I had to pick, I would want the Esc key before the outer area.

@HorusGoul
Copy link
Contributor Author

I'll pick this back after coming back from OOO 😄

Copy link
Contributor

@joelbettner joelbettner left a comment

Choose a reason for hiding this comment

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

Left one comment. Other than that it LGTM.

src/styles/styles.js Show resolved Hide resolved
@@ -215,10 +217,14 @@ class AuthScreens extends React.Component {
};
const fullscreenModalScreenOptions = {
...commonModalScreenOptions,
cardStyle: {...styles.fullscreenCard},
cardStyle: {
...styles.fullscreenCard,
Copy link
Contributor

Choose a reason for hiding this comment

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

Since styles.cardOverlay is being added below and has the following styles:

    cardOverlay: {
        backgroundColor: themeColors.modalBackdrop,
        position: 'absolute',
        top: 0,
        left: 0,
        width: '100%',
        height: '100%',
        opacity: 0.5,
    }

and styles.fullscreenCard has the following styles:

    fullscreenCard: {
        position: 'absolute',
        left: 0,
        top: 0,
        width: '100%',
        height: '100%',
    }

why do we need to add ...styles.fullscreenCard here? Won't all these styles be included in cardOverlay?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The cardOverlay is for the backdrop of the modal, and the fullscreenCard is for the content that appears on top of the backdrop. These styles are for two different components, hence the need for the two different styles.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was just wondering if the styles would be inherited. In any case, if the cardOverlay component might be used elsewhere, it makes sense to pass the styles along and not rely on inheritence.

isFullScreenModal: true,
cardOverlay: CardOverlay,
Copy link
Contributor

Choose a reason for hiding this comment

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

Sould it make more sense just to have

cardOverlay: <View style={styles.cardOverlay} />,

Why have an entirely different file for something that is only used in this one place?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could move it to the AuthScreen but, we would still need to pass it as cardOverlay: CardOverlay. I think it's best to leave it as a separate file just in case we need to use it for another modal.

@HorusGoul
Copy link
Contributor Author

I just fixed the bug @marcaaron mentioned for the Reports screen. I still need to test other screens similar to the Reports one to see if there are similar regressions.

@marcaaron
Copy link
Contributor

Let us know when it's ready for another review 👍

@HorusGoul
Copy link
Contributor Author

Ready for review!

@github-actions
Copy link
Contributor

github-actions bot commented Jul 20, 2021

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

@HorusGoul
Copy link
Contributor Author

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

joelbettner
joelbettner previously approved these changes Jul 20, 2021
@marcaaron
Copy link
Contributor

I'm not sure if this PR was blocked on me (sorry, if so) but it has conflicts now.

@HorusGoul
Copy link
Contributor Author

Conflicts fixed. If you could review @marcaaron

@marcaaron marcaaron merged commit 21b1ee4 into main Aug 9, 2021
@marcaaron marcaaron deleted the horus-inset-full-screen-modal branch August 9, 2021 16:50
@OSBotify
Copy link
Contributor

OSBotify commented Aug 9, 2021

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by @marcaaron in version: 1.0.83-2 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 failure ❌
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @isagoico in version: 1.0.85-9 🚀

platform result
🤖 android 🤖 failure ❌
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants