Skip to content

Commit caac07f

Browse files
committed
fix(suite-native): android button navigation bar colors
1 parent a26cc38 commit caac07f

File tree

4 files changed

+41
-5
lines changed

4 files changed

+41
-5
lines changed

scripts/list-outdated-dependencies/mobile-dependencies.txt

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ expo-haptics
4444
expo-image
4545
expo-linear-gradient
4646
expo-local-authentication
47+
expo-navigation-bar
4748
expo-secure-store
4849
expo-splash-screen
4950
expo-status-bar

suite-native/navigation/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"@trezor/styles": "workspace:*",
2828
"@trezor/theme": "workspace:*",
2929
"expo-linking": "^7.0.2",
30+
"expo-navigation-bar": "^4.0.2",
3031
"expo-system-ui": "^4.0.2",
3132
"react": "18.2.0",
3233
"react-native": "0.76.1",

suite-native/navigation/src/components/Screen.tsx

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { useEffect, useContext, ReactNode } from 'react';
2-
import { ScrollViewProps, View } from 'react-native';
2+
import { ScrollViewProps, View, Platform } from 'react-native';
33
import { EdgeInsets } from 'react-native-safe-area-context';
44
import { useSelector } from 'react-redux';
55
import { SystemBars, SystemBarStyle } from 'react-native-edge-to-edge';
66

77
import * as SystemUI from 'expo-system-ui';
8+
import * as NavigationBar from 'expo-navigation-bar';
89
import { BottomTabBarHeightContext } from '@react-navigation/bottom-tabs';
9-
import { useRoute } from '@react-navigation/native';
10+
import { useIsFocused, useRoute } from '@react-navigation/native';
1011

1112
import { useOfflineBannerAwareSafeAreaInsets } from '@suite-native/connection-status';
1213
import { prepareNativeStyle, useNativeStyles } from '@trezor/styles';
@@ -114,12 +115,23 @@ export const Screen = ({
114115

115116
const isMessageBannerDisplayed = useSelector(selectIsAnyBannerMessageActive);
116117

118+
const isFocused = useIsFocused();
117119
const { name } = useRoute();
118120

119121
useEffect(() => {
120-
// this prevents some weird flashing of splash screen on Android during screen transitions
121-
SystemUI.setBackgroundColorAsync(backgroundCSSColor);
122-
}, [backgroundCSSColor]);
122+
if (isFocused) {
123+
// this prevents some weird flashing of splash screen on Android during screen transitions
124+
SystemUI.setBackgroundColorAsync(backgroundCSSColor);
125+
126+
// change colors of button navigation bar on Android
127+
if (Platform.OS === 'android') {
128+
NavigationBar.setBackgroundColorAsync(backgroundCSSColor);
129+
NavigationBar.setButtonStyleAsync(
130+
isDarkColor(backgroundCSSColor) ? 'light' : 'dark',
131+
);
132+
}
133+
}
134+
}, [backgroundCSSColor, isDarkColor, isFocused]);
123135

124136
return (
125137
<View

yarn.lock

+22
Original file line numberDiff line numberDiff line change
@@ -7107,6 +7107,13 @@ __metadata:
71077107
languageName: node
71087108
linkType: hard
71097109

7110+
"@react-native/normalize-colors@npm:0.76.6":
7111+
version: 0.76.6
7112+
resolution: "@react-native/normalize-colors@npm:0.76.6"
7113+
checksum: 10/0e28cbdecbba96bd3e26a537623f68b77a77fda481b60dfa11d2a6e532aaae414d07e422d61465e40261d92a835d2f8342780cbe904a19c57e1fe223e4dc4a24
7114+
languageName: node
7115+
linkType: hard
7116+
71107117
"@react-native/virtualized-lists@npm:0.76.1":
71117118
version: 0.76.1
71127119
resolution: "@react-native/virtualized-lists@npm:0.76.1"
@@ -10951,6 +10958,7 @@ __metadata:
1095110958
"@trezor/styles": "workspace:*"
1095210959
"@trezor/theme": "workspace:*"
1095310960
expo-linking: "npm:^7.0.2"
10961+
expo-navigation-bar: "npm:^4.0.2"
1095410962
expo-system-ui: "npm:^4.0.2"
1095510963
react: "npm:18.2.0"
1095610964
react-native: "npm:0.76.1"
@@ -23144,6 +23152,20 @@ __metadata:
2314423152
languageName: node
2314523153
linkType: hard
2314623154

23155+
"expo-navigation-bar@npm:^4.0.2":
23156+
version: 4.0.7
23157+
resolution: "expo-navigation-bar@npm:4.0.7"
23158+
dependencies:
23159+
"@react-native/normalize-colors": "npm:0.76.6"
23160+
debug: "npm:^4.3.2"
23161+
peerDependencies:
23162+
expo: "*"
23163+
react: "*"
23164+
react-native: "*"
23165+
checksum: 10/50af462efb6c4ecc5d4a515e795f45c65ad8d87579a0ecaefe7c97e7f5d520eeba79ae1d1e4391652e4bf523da18f4760f8727ca3aa8c09b6e976320701673eb
23166+
languageName: node
23167+
linkType: hard
23168+
2314723169
"expo-secure-store@npm:^14.0.0":
2314823170
version: 14.0.0
2314923171
resolution: "expo-secure-store@npm:14.0.0"

0 commit comments

Comments
 (0)