From 31c92daa165d15c70ada372cb479d1a1c12ceeb5 Mon Sep 17 00:00:00 2001 From: Michal Date: Wed, 23 Oct 2024 15:56:29 +0100 Subject: [PATCH] fix(wallet-mobile): Fix keyboard avoiding view --- apps/wallet-mobile/src/AppNavigator.tsx | 17 ++++++---- .../messages/src/AppNavigator.json | 32 +++++++++---------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/apps/wallet-mobile/src/AppNavigator.tsx b/apps/wallet-mobile/src/AppNavigator.tsx index a25d1129d3..216dc554f3 100644 --- a/apps/wallet-mobile/src/AppNavigator.tsx +++ b/apps/wallet-mobile/src/AppNavigator.tsx @@ -2,7 +2,7 @@ import {NavigationContainer, NavigationContainerRef} from '@react-navigation/nat import {createStackNavigator, TransitionPresets} from '@react-navigation/stack' import {isString} from '@yoroi/common' import {supportedPrefixes} from '@yoroi/links' -import {useTheme} from '@yoroi/theme' +import {ThemedPalette, useTheme} from '@yoroi/theme' import * as React from 'react' import {defineMessages, useIntl} from 'react-intl' import {Alert, AppState, AppStateStatus, InteractionManager, Platform} from 'react-native' @@ -44,6 +44,13 @@ const Stack = createStackNavigator() const navRef = React.createRef>() const prefixes = [...supportedPrefixes] +const changeNavigationBarColor = (colorScheme: 'default-dark' | 'default-light', color: ThemedPalette) => { + const buttonsColor = colorScheme === 'default-dark' ? 'light' : 'dark' + // Using 'transparent' or 'translucent' background breaks KeyboardAvoidingView + // https://github.com/kadiraydinli/react-native-system-navigation-bar/issues/38 + SystemNavigationBar.setNavigationColor(color.bg_color_max, buttonsColor, 'navigation') +} + export const AppNavigator = () => { useDeepLinkWatcher() const strings = useStrings() @@ -53,9 +60,8 @@ export const AppNavigator = () => { const {atoms, color, colorScheme} = useTheme() React.useEffect(() => { - const buttonsColor = colorScheme === 'default-dark' ? 'light' : 'dark' - SystemNavigationBar.setNavigationColor('transparent', buttonsColor, 'navigation') - }, [colorScheme]) + changeNavigationBarColor(colorScheme, color) + }, [colorScheme, color]) useAutoLogout() @@ -64,8 +70,7 @@ export const AppNavigator = () => { onSuccess: login, onSettled: async () => { await RNBootSplash.hide({fade: true}) - const buttonsColor = colorScheme === 'default-dark' ? 'light' : 'dark' - SystemNavigationBar.setNavigationColor('transparent', buttonsColor, 'navigation') + changeNavigationBarColor(colorScheme, color) }, }) diff --git a/apps/wallet-mobile/translations/messages/src/AppNavigator.json b/apps/wallet-mobile/translations/messages/src/AppNavigator.json index e0934df248..7f0d7cd742 100644 --- a/apps/wallet-mobile/translations/messages/src/AppNavigator.json +++ b/apps/wallet-mobile/translations/messages/src/AppNavigator.json @@ -4,14 +4,14 @@ "defaultMessage": "!!!Enter PIN", "file": "src/AppNavigator.tsx", "start": { - "line": 237, + "line": 245, "column": 17, - "index": 8706 + "index": 9103 }, "end": { - "line": 240, + "line": 248, "column": 3, - "index": 8796 + "index": 9193 } }, { @@ -19,14 +19,14 @@ "defaultMessage": "!!!Set PIN", "file": "src/AppNavigator.tsx", "start": { - "line": 241, + "line": 249, "column": 18, - "index": 8816 + "index": 9213 }, "end": { - "line": 244, + "line": 252, "column": 3, - "index": 8914 + "index": 9311 } }, { @@ -34,14 +34,14 @@ "defaultMessage": "!!!Auth with OS changes", "file": "src/AppNavigator.tsx", "start": { - "line": 245, + "line": 253, "column": 25, - "index": 8941 + "index": 9338 }, "end": { - "line": 248, + "line": 256, "column": 3, - "index": 9055 + "index": 9452 } }, { @@ -49,14 +49,14 @@ "defaultMessage": "!!!Auth with OS changed detected", "file": "src/AppNavigator.tsx", "start": { - "line": 249, + "line": 257, "column": 27, - "index": 9084 + "index": 9481 }, "end": { - "line": 252, + "line": 260, "column": 3, - "index": 9205 + "index": 9602 } } ] \ No newline at end of file