Skip to content

Commit

Permalink
handle statusbar style on welcome page vs rest of app
Browse files Browse the repository at this point in the history
  • Loading branch information
JGreenlee committed Sep 20, 2024
1 parent f671e04 commit 33a38c9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
12 changes: 5 additions & 7 deletions www/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,13 @@ window.skipLocalNotificationReady = true;

deviceReady.then(() => {
logDebug('deviceReady');
// On init, use 'default' status bar (black text)
window['StatusBar']?.styleDefault();
cordova.plugin.http.setDataSerializer('json');
const rootEl = document.getElementById('appRoot');
const reactRoot = createRoot(rootEl);

const theme = getTheme();
/* Set Cordova StatusBar color to match the "elevated" AppBar
https://cordova.apache.org/docs/en/10.x/reference/cordova-plugin-statusbar/#statusbarbackgroundcolorbyhexstring
https://callstack.github.io/react-native-paper/docs/components/Appbar/#theme-colors */
if (window['StatusBar']) {
window['StatusBar'].backgroundColorByHexString(theme.colors.elevation.level2);
}

reactRoot.render(
<PaperProvider theme={theme}>
Expand All @@ -45,7 +41,9 @@ deviceReady.then(() => {
}
`}
</style>
<SafeAreaView style={{ flex: 1 }}>
{/* The background color of this SafeAreaView effectively controls the status bar background color.
Set to theme.colors.elevation.level2 to match the background of the elevated AppBars present on each tab. */}
<SafeAreaView style={{ flex: 1, backgroundColor: theme.colors.elevation.level2 }}>
<App />
</SafeAreaView>
</PaperProvider>,
Expand Down
7 changes: 6 additions & 1 deletion www/js/onboarding/OnboardingStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ const OnboardingStack = () => {
const { onboardingState } = useContext(AppContext);

if (onboardingState.route == OnboardingRoute.WELCOME) {
// This page needs 'light content' status bar (white text) due to blue header at the top
window['StatusBar']?.styleLightContent();

Check warning on line 17 in www/js/onboarding/OnboardingStack.tsx

View check run for this annotation

Codecov / codecov/patch

www/js/onboarding/OnboardingStack.tsx#L17

Added line #L17 was not covered by tests
return <WelcomePage />;
} else if (onboardingState.route == OnboardingRoute.SUMMARY) {
}
// All other pages go back to 'default' (black text)
window['StatusBar']?.styleDefault();

Check warning on line 21 in www/js/onboarding/OnboardingStack.tsx

View check run for this annotation

Codecov / codecov/patch

www/js/onboarding/OnboardingStack.tsx#L21

Added line #L21 was not covered by tests
if (onboardingState.route == OnboardingRoute.SUMMARY) {
return <SummaryPage />;
} else if (onboardingState.route == OnboardingRoute.PROTOCOL) {
return <ProtocolPage />;
Expand Down

0 comments on commit 33a38c9

Please sign in to comment.