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

Adapt status bar color to modal backdrop #13215

Merged
merged 13 commits into from
Dec 7, 2022

Conversation

dnlfrst
Copy link
Contributor

@dnlfrst dnlfrst commented Nov 30, 2022

@eVoloshchak
@tgolen

Details

Previously, the status bar color did not match the backdrop of a modal on Safari. This pull request fixes this issue by changing the status bar color as soon as a modal opens.

Fixed Issues

$ #12156
$ #12156 (comment)

Tests

  1. Open a chat.
  2. Tap long onto a message to open its context menu.
  3. Discard the context menu by shortly tapping outside of it.

By design, these steps only apply on iOS / Safari and Android / Chrome since the issue never appeared on iOS / native and Android / native. The remaining platforms do not offer a comparable context menu.

  • Verify that no errors appear in the JS console

Offline tests

See the steps from above.

QA Steps

See the steps from above.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • MacOS / Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product was added in all src/languages/* files
    • I verified any copy / text that was added to the app is correct English and approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Web

Not applicable.

Mobile Web - Chrome
Android.webm
Mobile Web - Safari
iOS.MP4
Desktop

Not applicable.

iOS

Not applicable.

Android

Not applicable.

@dnlfrst dnlfrst requested a review from a team as a code owner November 30, 2022 23:54
@melvin-bot melvin-bot bot requested review from eVoloshchak and removed request for a team November 30, 2022 23:54
@melvin-bot
Copy link

melvin-bot bot commented Nov 30, 2022

@tgolen @eVoloshchak One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot melvin-bot bot requested a review from tgolen November 30, 2022 23:54
@github-actions
Copy link
Contributor

github-actions bot commented Nov 30, 2022

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

@dnlfrst
Copy link
Contributor Author

dnlfrst commented Nov 30, 2022

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

Copy link
Contributor

@tgolen tgolen left a comment

Choose a reason for hiding this comment

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

Mostly looks good, but I think the naming of things could use some work. I hope these tips are helpful!

src/styles/StyleUtils.js Outdated Show resolved Hide resolved
src/styles/StyleUtils.js Outdated Show resolved Hide resolved
src/styles/StyleUtils.js Outdated Show resolved Hide resolved
src/styles/StyleUtils.js Outdated Show resolved Hide resolved
@dnlfrst dnlfrst requested review from tgolen and removed request for eVoloshchak December 1, 2022 23:47
@tgolen tgolen requested a review from eVoloshchak December 2, 2022 15:25
@tgolen
Copy link
Contributor

tgolen commented Dec 2, 2022

@eVoloshchak should remain a reviewer on this PR since they were the ContributorPlus person assigned to the issue.

@eVoloshchak
Copy link
Contributor

Will test this tomorrow, sorry for the delay

Copy link
Contributor

@tgolen tgolen left a comment

Choose a reason for hiding this comment

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

Those names are looking much better, thank you!

src/components/Modal/index.web.js Outdated Show resolved Hide resolved
src/styles/StyleUtils.js Outdated Show resolved Hide resolved
src/styles/StyleUtils.js Outdated Show resolved Hide resolved
Also, rename method for clarity and use `undefined` over `null`.
src/components/Modal/index.web.js Outdated Show resolved Hide resolved
@dnlfrst
Copy link
Contributor Author

dnlfrst commented Dec 2, 2022

@tgolen is there anything else you would like me to change in this PR?

src/components/Modal/index.web.js Outdated Show resolved Hide resolved
@eVoloshchak
Copy link
Contributor

eVoloshchak commented Dec 3, 2022

Code looks good.
iOS is working good (there is a slight delay, but that was discussed before).

But there's an issue with Android, the status bar flickers when changing color

Screen_Recording_20221203-223038_Chrome.mp4

The behavior is the same in production build, I checked a couple of phones (android 12/13), all behave the same, probably a bug in Chrome app itself

@tgolen, I'm not sure we can do anything about this, but it looks wrong in my opinion. What do you think?

@dnlfrst
Copy link
Contributor Author

dnlfrst commented Dec 4, 2022

I can confirm this for Chrome on Android, although I did not notice this myself initially. Here is a slow version that clearly shows the status bar flashing the previous color:

Android.slow.mp4

While I couldn't find an official bug report for this, the problem of white flashes seems to be a thing with Chrome. I couldn't fathom how the code change would cause this visual bug, though. Especially, since the problem does not occur on iOS.

@tgolen
Copy link
Contributor

tgolen commented Dec 5, 2022

Are there any other techniques for changing the status bar color that might prevent the flash from happening @dnlfrst ?

@dnlfrst
Copy link
Contributor Author

dnlfrst commented Dec 5, 2022

Are there any other techniques for changing the status bar color that might prevent the flash from happening @dnlfrst ?

None that I would be aware of, at least.

@shawnborton
Copy link
Contributor

On Chrome, why isn't the top a dark dark green to match the body? Like when the overlay is open, the top matches the overlay color... so when the overlay is not open, why can't we match the background color?

@dnlfrst
Copy link
Contributor Author

dnlfrst commented Dec 6, 2022

That's a good question! I wasn't sure about this myself, yet. On iOS, Safari automatically adapts the status color to the background color of the app. Google Chrome on Android does not do so, though. Hence, I have applied the following patch (929f85e) to this PR:

diff --git a/src/components/CustomStatusBar/index.web.js b/src/components/CustomStatusBar/index.web.js
new file mode 100644
index 0000000000..56799ecf32
--- /dev/null
+++ b/src/components/CustomStatusBar/index.web.js
@@ -0,0 +1,16 @@
+import React from 'react';
+import {StatusBar} from 'react-native';
+import themeColors from '../../styles/themes/default';
+
+export default class CustomStatusBar extends React.Component {
+    componentDidMount() {
+        StatusBar.setBarStyle('light-content', true);
+
+        // Match the default status bar color to the app's background color.
+        document.querySelector('meta[name=theme-color]').content = themeColors.appBG;
+    }
+
+    render() {
+        return <StatusBar />;
+    }
+}
diff --git a/src/components/Modal/index.web.js b/src/components/Modal/index.web.js
index 2ee534457e..79d5751403 100644
--- a/src/components/Modal/index.web.js
+++ b/src/components/Modal/index.web.js
@@ -3,9 +3,10 @@ import withWindowDimensions from '../withWindowDimensions';
 import BaseModal from './BaseModal';
 import {propTypes, defaultProps} from './modalPropTypes';
 import * as StyleUtils from '../../styles/StyleUtils';
+import themeColors from '../../styles/themes/default';
 
 const Modal = (props) => {
-    const setStatusBarColor = (color = '') => {
+    const setStatusBarColor = (color = themeColors.appBG) => {
         if (!props.fullscreen) {
             return;
         }

It sets the default status bar color to match the app's background color. This applies to web but only affects Android's Google Chrome since Safari already exhibits this behavior by default. Coincidentally, this also resolves the status bar color flashing on Google Chrome. However, the animation on the status bar color change remains:

Android.mp4

@tgolen
Copy link
Contributor

tgolen commented Dec 6, 2022

Oh, that's pretty good! I think that flash is much less noticeable now, and kudos @shawnborton for asking the right question! That never even occurred to me.

src/components/Modal/index.web.js Outdated Show resolved Hide resolved
src/components/CustomStatusBar/index.web.js Outdated Show resolved Hide resolved
@tgolen
Copy link
Contributor

tgolen commented Dec 6, 2022

I tested it on Android briefly and I think it looks good and I'm OK merging this. @eVoloshchak do you have time to go through the checklist and other platforms today?

@eVoloshchak
Copy link
Contributor

@eVoloshchak do you have time to go through the checklist and other platforms today?

Yes, I'll do it in a couple of hours
The video looks great!

@eVoloshchak
Copy link
Contributor

It seems we need a more universal solution, there are a lot of cases where background color is not the themeColors.appBG. For example on login, notice how the status bar is darker:
Simulator Screen Shot - iPhone 12 - 2022-12-06 at 21 47 20

I think this is getting a bit out of scope of this particular issue, but ideally, we'd want to mimic the behavior the native platforms have, which is to have status bar mimic the screen's background color on every screen.

@shawnborton
Copy link
Contributor

Yeah, I 100% agree with that sentiment. It feels odd that iOS has the different color status bar from the rest of the page.

@eVoloshchak
Copy link
Contributor

Yeah, I 100% agree with that sentiment. It feels odd that iOS has the different color status bar from the rest of the page.

It's not only iOS, since this change is mWeb-only, it can be also observed on Android
image

@shawnborton
Copy link
Contributor

Got it. Hmm, what can we do to avoid that?

@eVoloshchak
Copy link
Contributor

Got it. Hmm, what can we do to avoid that?

Not sure, we need to somehow detect the background color of the current screen. But I can't think of a non-hacky way to do this, probably needs discussing on slack

@dnlfrst
Copy link
Contributor Author

dnlfrst commented Dec 6, 2022

Do you guys still want me to work on this or will you take care of this internally?

@shawnborton
Copy link
Contributor

Hmm yeah, so maybe this is trickier than we thought and relates back to the big status bar discussion we were having previously, cc @Julesssss @vitHoracek @JmillsExpensify where did we land with that one?

@Julesssss
Copy link
Contributor

Julesssss commented Dec 7, 2022

where did we land with that one?

We agreed to merge the PR and have the status bar show as a different colour until a better solution can be found. I'm working on that but it is far lower priority than docs and other WhatsApp quality issues.

The screenshots actually show how the app functions on main already, so I don't think this PR has introduced further regressions to native mobile. Unless I've missed something, I'd say we can merge the proposed solution, then await the completion of this issue to further improve the status bar issue.

As for why the status bar has 'changed' on iOS, this is because the login screen background color is not themeColors.appBG. Pages other than auth and LHN look correct

Copy link
Contributor

@Julesssss Julesssss left a comment

Choose a reason for hiding this comment

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

The 'regressions' are known, I think we can go ahead with this change.

@eVoloshchak
Copy link
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • MacOS / Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product was added in all src/languages/* files
    • I verified any copy / text that was added to the app is correct English and approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Web
Screen.Recording.2022-12-07.at.12.50.32.mov
Mobile Web - Chrome
Screen_Recording_20221207-124529_Chrome.mp4
Mobile Web - Safari
Screen.Recording.2022-12-07.at.12.46.43.mov
Desktop
Screen.Recording.2022-12-07.at.12.49.21.mov
iOS
Screen.Recording.2022-12-07.at.12.47.28.mov
Android
Screen_Recording_20221207-124618_New.Expensify.mp4

@eVoloshchak
Copy link
Contributor

@dnlfrst, could you please add $ before the link for the proposal in Fixed Issues section?

Make sure this section looks similar to this (you can link multiple issues using the same formatting, just add a new line):

$ https://github.com/Expensify/App/issues/<number-of-the-issue>
$ https://github.com/Expensify/App/issues/<number-of-the-issue(comment)>

Copy link
Contributor

@eVoloshchak eVoloshchak left a comment

Choose a reason for hiding this comment

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

Tests well!

@dnlfrst
Copy link
Contributor Author

dnlfrst commented Dec 7, 2022

@dnlfrst, could you please add $ before the link for the proposal in Fixed Issues section?


Make sure this section looks similar to this (you can link multiple issues using the same formatting, just add a new line):



$ https://github.com/Expensify/App/issues/<number-of-the-issue>

$ https://github.com/Expensify/App/issues/<number-of-the-issue(comment)>

Done that!

@tgolen tgolen merged commit 3e050bd into Expensify:main Dec 7, 2022
@OSBotify
Copy link
Contributor

OSBotify commented Dec 7, 2022

✋ 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 production by @chiragsalian in version: 1.2.38-6 🚀

platform result
🤖 android 🤖 success ✅
🖥 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.

6 participants