-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Fix 20516 mWeb topbar color #20805
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 20516 mWeb topbar color #20805
Conversation
|
@pecanoro @thesahindia 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] |
|
@thesahindia Friendly bump so we can merge it within the bonus! |
|
Looks like I won't be able to look into it before Monday so @allroundexperts will take my place. Thanks!! |
Reviewer Checklist
Screenshots/VideosMobile Web - ChromeScreen.Recording.2023-06-19.at.8.18.45.AM.movMobile Web - SafariScreen.Recording.2023-06-19.at.8.19.39.AM.moviOSScreen.Recording.2023-06-19.at.8.36.55.AM.movAndroidScreen.Recording.2023-06-19.at.8.30.45.AM.mov |
| useEffect(() => { | ||
| if (!Browser.isMobile()) return; | ||
| InteractionManager.runAfterInteractions(() => StatusBar.setBackgroundColor(themeColors.appBG)); | ||
| }, []); | ||
|
|
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 aren't we using useFocusEffect here?
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.
As useFocusEffect will call on every focus, we don't want it here because SidebarScreen is our main screen for mWeb with different bg color. we always have to return to main screen by going back so we have to useFocusEffect there so it can get called on everytime screen is focused. as RightModalNavigator will called for every screen it contains, changing color once will do the job. And we direct modify meta color we should always minimize the calls
src/pages/home/ReportScreen.js
Outdated
| componentDidMount() { | ||
| if (this.isMobileBrowser) { | ||
| InteractionManager.runAfterInteractions(() => StatusBar.setBackgroundColor(themeColors.appBG)); | ||
| } | ||
|
|
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.
Same question as above. componentDidMount will get triggered even if the screen is not visible.
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.
Same as above. ReportScreen contains appBG as background color. So we can just do it on screen mount.
| useFocusEffect(() => { | ||
| InteractionManager.runAfterInteractions(() => StatusBar.setBackgroundColor(themeColors.sidebar)); | ||
| }); |
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.
You might want to wrap this function inside a callback because if above is used as it is, the code will run ALWAYS when:
- Screen is focused
- The component re-renders
ref: https://reactnavigation.org/docs/use-focus-effect/
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, I have updated the code. so it will run on focus only.
| function SidebarScreen(props) { | ||
| const popoverModal = useRef(null); | ||
|
|
||
| useFocusEffect(() => { |
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.
You might also want to run a cleanup function that restores the previous colour.
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 guess you are right. If we use cleanup to restore previous then we don't have to use change on other screen 😇
| } | ||
|
|
||
| StatusBar.setBackgroundColor(color); | ||
| InteractionManager.runAfterInteractions(() => StatusBar.setBackgroundColor(color)); |
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.
@kushu7 Why do we need to change other files (like SidebarScreen etc)? Shouldn't a change in this file alone handle the status bar colours?
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.
Its required to keep consistency between colors, SidebarScreen bg is using different color.
And Modal contains overlay, full screen modal. So changing color here alone will not work.
You should see one of my mWeb video. You will get my point.
|
@allroundexperts I have completed the requested changes and also did some cleanup ☮️ |
|
|
||
| useFocusEffect( | ||
| useCallback(() => { | ||
| if (!isFocused) return; |
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.
This is not needed. useFocusEffect gets triggered only when the screen is focused.
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
| return () => { | ||
| InteractionManager.runAfterInteractions(() => StatusBar.setBackgroundColor(previousColor)); | ||
| }; | ||
| }, [isFocused]), |
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.
This should be empty.
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.
Updated
| InteractionManager.runAfterInteractions(() => StatusBar.setBackgroundColor(themeColors.sidebar)); | ||
|
|
||
| return () => { | ||
| InteractionManager.runAfterInteractions(() => StatusBar.setBackgroundColor(previousColor)); |
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.
Cant we set background without InteractionManager?
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.
Without interaction manager will cause lag on mid-end android devices. I have tested it with two devices
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 you attach a video of before and after?
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.
Without InteractionManager
Record_2023-06-18-05-52-41.mp4
With InteractionManager
Record_2023-06-18-05-53-28.mp4
| import CONST from '../../CONST'; | ||
|
|
||
| function Modal(props) { | ||
| const [previousStatusBarColor, setPreviousStatusBarColor] = useState(); |
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.
Where is this being used?
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.
on hideModal
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.
But where are we setting 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.
We setPreviousStatusBarColor on showModal with currrent color. and restore it on hideModal
@allroundexperts I have attached the video that you requested. |
|
@pecanoro Friendly bump for review 🫣 |
|
It was a federal holiday yesterday in the US so I was out (it won't count for bonus either), but I am taking a look today. |
@pecanoro @allroundexperts I guess for doing this in native it would require more refactoring. App/src/pages/home/ReportScreen.js Line 272 in 99214de
for doing this we have to refactor it allow different color for both StatusBar and background. |
|
Ahh interesting, yeah, after digging more on how this works, I think we should stick to the background color since then it might get too complicated for future cases. With that in mind, it looks and works great, I don't think we can do anything about that tiny browser delay. @thesahindia Can you do a final review and complete the checklist so I can do my final review? |
I think @allroundexperts is C+ here. |
|
@pecanoro I've already completed the review and filled in the checklist! |
|
Ah sorry, got confused with the assignments in the PR, my bad for not checking 😄 I will do a final check then before approving. |
|
I keep getting a crash on this branch when running the web version, I can run the app without issues on main, can you check to see if it's only me? |
@pecanoro What error message are you seeing? |
|
@kushu7 can you check? Probably also merge with main. |
|
I just checked seems working fine, |
|
@pecanoro Can you try again, I just merged main. |
|
That did the trick, thanks! Testing again |
|
Just a small change. I wonder why it requested changes were posted twice lol |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/pecanoro in version: 1.3.30-0 🚀
|
|
🚀 Deployed to production by https://github.com/luacmartins in version: 1.3.30-5 🚀
|





Details
Setting StatusBar for mWeb to keep consistency with Native Apps.
Fixed Issues
$ #20516
PROPOSAL: #20516 (comment)
Tests
TopBarof LHN should match with LHN background.TopBarshould match with native appStatusBar.Offline tests
Same as Tests
QA Steps
Same as Tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Web
web.mov
Mobile Web - Chrome
mweb.chrome.mov
Mobile Web - Safari
mweb.safari.mov
Desktop
desktop.mov
iOS
ios.mp4
Android
android.mov