Skip to content

Commit

Permalink
Merge pull request #46265 from dominictb/fix/44685-status-bar-color
Browse files Browse the repository at this point in the history
fix: force update status bar color
  • Loading branch information
roryabraham authored Jul 29, 2024
2 parents fd4f9df + 9c2a868 commit 410a6f2
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/components/CustomStatusBarAndBackground/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,34 @@ function CustomStatusBarAndBackground({isNested = false}: CustomStatusBarAndBack
prevStatusBarBackgroundColor.current = statusBarBackgroundColor.current;
statusBarBackgroundColor.current = currentScreenBackgroundColor;

if (currentScreenBackgroundColor !== theme.appBG || prevStatusBarBackgroundColor.current !== theme.appBG) {
const callUpdateStatusBarAppearance = () => {
updateStatusBarAppearance({statusBarStyle: newStatusBarStyle});
setStatusBarStyle(newStatusBarStyle);
};

const callUpdateStatusBarBackgroundColor = () => {
statusBarAnimation.value = 0;
statusBarAnimation.value = withDelay(300, withTiming(1));
}
};

// Don't update the status bar style if it's the same as the current one, to prevent flashing.
// Force update if the root status bar is back on active or it won't overwirte the nested status bar style
if ((!didForceUpdateStatusBarRef.current && !prevIsRootStatusBarEnabled && isRootStatusBarEnabled) || newStatusBarStyle !== statusBarStyle) {
updateStatusBarAppearance({statusBarStyle: newStatusBarStyle});
setStatusBarStyle(newStatusBarStyle);
if (!didForceUpdateStatusBarRef.current && !prevIsRootStatusBarEnabled && isRootStatusBarEnabled) {
callUpdateStatusBarAppearance();
callUpdateStatusBarBackgroundColor();

if (!prevIsRootStatusBarEnabled && isRootStatusBarEnabled) {
didForceUpdateStatusBarRef.current = true;
}
return;
}

if (newStatusBarStyle !== statusBarStyle) {
callUpdateStatusBarAppearance();
}

if (currentScreenBackgroundColor !== theme.appBG || prevStatusBarBackgroundColor.current !== theme.appBG) {
callUpdateStatusBarBackgroundColor();
}
},
[prevIsRootStatusBarEnabled, isRootStatusBarEnabled, statusBarAnimation, statusBarStyle, theme.PAGE_THEMES, theme.appBG, theme.statusBarStyle],
Expand Down

0 comments on commit 410a6f2

Please sign in to comment.