-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Fix/status bar color on mweb #34409
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
Merged
roryabraham
merged 31 commits into
Expensify:main
from
ishpaul777:fix/status-bar-color-on-mweb
Feb 26, 2024
Merged
Fix/status bar color on mweb #34409
Changes from 14 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
c144200
fixes the issue
ishpaul777 d7ad870
fixed blinking of the status bar
ishpaul777 52d3128
fixes the issue
ishpaul777 9d4e5b0
prettier diffs
ishpaul777 731f70d
Merge branch 'Expensify:main' into fix/status-bar-color-on-mweb
ishpaul777 97755dd
fixes the issue v2
ishpaul777 073a480
fixes android dark mode issue
ishpaul777 5f11157
prettier fix
ishpaul777 d19a95d
fix prettier diffs
ishpaul777 d9d6cc8
clean up
ishpaul777 0d15185
fixes color naming
ishpaul777 80deeaf
Merge branch 'Expensify:main' into fix/status-bar-color-on-mweb
ishpaul777 2f9f73b
added comments for the changes
ishpaul777 76ce335
added comment for when status bar context is required
ishpaul777 87d6656
Merge branch 'Expensify:main' into fix/status-bar-color-on-mweb
ishpaul777 233fba9
added requested changes
ishpaul777 0e790b8
fixed statusbar content style
ishpaul777 cdf6eb9
prettier diffs
ishpaul777 ea47400
Merge branch 'Expensify:main' into fix/status-bar-color-on-mweb
ishpaul777 fd7aca0
listen to theme changes
ishpaul777 cde910b
include comment for useeffect
ishpaul777 8ca38d0
Update src/components/CustomStatusBarAndBackground/index.tsx
ishpaul777 321b278
remove urelated changes
ishpaul777 4508091
rectify comment
ishpaul777 91ad613
remove unnecessary useEffect dependency
ishpaul777 cb3eb19
Merge branch 'Expensify:main' into fix/status-bar-color-on-mweb
ishpaul777 d041b91
Merge branch 'Expensify:main' into fix/status-bar-color-on-mweb
ishpaul777 0432658
refactor after merge
ishpaul777 3ea154d
prettier
ishpaul777 49f5ddd
Merge branch 'Expensify:main' into fix/status-bar-color-on-mweb
ishpaul777 b669f7b
used platform files for platform specfic code
ishpaul777 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 4 additions & 3 deletions
7
src/components/CustomStatusBarAndBackground/CustomStatusBarAndBackgroundContext.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import {createContext} from 'react'; | ||
|
||
type CustomStatusBarAndBackgroundContextType = { | ||
isRootStatusBarDisabled: boolean; | ||
disableRootStatusBar: (isDisabled: boolean) => void; | ||
isRootStatusBarEnabled: boolean; | ||
setRootStatusBarEnabled: (isEnabled: boolean) => void; | ||
}; | ||
|
||
const CustomStatusBarAndBackgroundContext = createContext<CustomStatusBarAndBackgroundContextType>({isRootStatusBarDisabled: false, disableRootStatusBar: () => undefined}); | ||
// Signin page has its seperate Statusbar and ThemeProvider, so when user is on the SignInPage we need to disable the root statusbar so there is no double status bar in component stack, first in Root and other in SignInPage | ||
const CustomStatusBarAndBackgroundContext = createContext<CustomStatusBarAndBackgroundContextType>({isRootStatusBarEnabled: true, setRootStatusBarEnabled: () => undefined}); | ||
|
||
export default CustomStatusBarAndBackgroundContext; | ||
export {type CustomStatusBarAndBackgroundContextType}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import React, {useCallback, useContext, useEffect, useRef, useState} from 'react'; | ||
import {interpolateColor, runOnJS, useAnimatedReaction, useSharedValue, withDelay, withTiming} from 'react-native-reanimated'; | ||
import useTheme from '@hooks/useTheme'; | ||
import getPlatform from '@libs/getPlatform'; | ||
import {navigationRef} from '@libs/Navigation/Navigation'; | ||
import StatusBar from '@libs/StatusBar'; | ||
import CONST from '@src/CONST'; | ||
import CustomStatusBarAndBackgroundContext from './CustomStatusBarAndBackgroundContext'; | ||
import updateGlobalBackgroundColor from './updateGlobalBackgroundColor'; | ||
import updateStatusBarAppearance from './updateStatusBarAppearance'; | ||
|
@@ -14,28 +16,30 @@ type CustomStatusBarAndBackgroundProps = { | |
}; | ||
|
||
function CustomStatusBarAndBackground({isNested = false}: CustomStatusBarAndBackgroundProps) { | ||
const {isRootStatusBarDisabled, disableRootStatusBar} = useContext(CustomStatusBarAndBackgroundContext); | ||
const {isRootStatusBarEnabled, setRootStatusBarEnabled} = useContext(CustomStatusBarAndBackgroundContext); | ||
const theme = useTheme(); | ||
const [statusBarStyle, setStatusBarStyle] = useState(theme.statusBarStyle); | ||
|
||
const isDisabled = !isNested && isRootStatusBarDisabled; | ||
const isDisabled = !isNested && !isRootStatusBarEnabled; | ||
|
||
// Disable the root status bar when a nested status bar is rendered | ||
useEffect(() => { | ||
if (isNested) { | ||
disableRootStatusBar(true); | ||
setRootStatusBarEnabled(false); | ||
} | ||
|
||
return () => { | ||
if (!isNested) { | ||
return; | ||
} | ||
disableRootStatusBar(false); | ||
setRootStatusBarEnabled(true); | ||
}; | ||
}, [disableRootStatusBar, isNested]); | ||
}, [isNested, setRootStatusBarEnabled]); | ||
|
||
const prevStatusBarBackgroundColor = useRef(theme.appBG); | ||
const statusBarBackgroundColor = useRef(theme.appBG); | ||
// the prev and current status bar background color refs are initialized with the splash screen background color so the status bar color is changed from the splash screen color to the expected color atleast once on first render - https://github.com/Expensify/App/issues/34154 | ||
const initialBgColor = getPlatform() === CONST.PLATFORM.WEB ? theme.splashBGWeb : theme.splashBG; | ||
ishpaul777 marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am curious about the use of cc: @roryabraham |
||
const prevStatusBarBackgroundColor = useRef(initialBgColor); | ||
const statusBarBackgroundColor = useRef(initialBgColor); | ||
const statusBarAnimation = useSharedValue(0); | ||
|
||
useAnimatedReaction( | ||
|
@@ -57,7 +61,9 @@ function CustomStatusBarAndBackground({isNested = false}: CustomStatusBarAndBack | |
// This callback is triggered everytime the route changes or the theme changes | ||
const updateStatusBarStyle = useCallback( | ||
(listenerId?: number) => { | ||
// Check if this function is either called through the current navigation listener or the general useEffect which listens for theme changes. | ||
// Check if this function is either called through the current navigation listener | ||
// react-navigation library has a bug internally, where it can't keep track of the listeners, therefore, sometimes when the useEffect would re-render and we run navigationRef.removeListener the listener isn't removed and we end up with two or more listeners. | ||
// https://github.com/Expensify/App/issues/34154#issuecomment-1898519399 | ||
if (listenerId !== undefined && listenerId !== listenerCount.current) { | ||
return; | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.