|
3 | 3 |
|
4 | 4 | /* eslint-disable max-lines */ |
5 | 5 |
|
| 6 | +import RNUtils from '@mattermost/rnutils'; |
6 | 7 | import merge from 'deepmerge'; |
7 | 8 | import {Appearance, DeviceEventEmitter, StatusBar, Platform, Alert, type EmitterSubscription} from 'react-native'; |
8 | | -import {type ComponentWillAppearEvent, type ImageResource, type LayoutOrientation, Navigation, type Options, OptionsModalPresentationStyle, type OptionsTopBarButton, type ScreenPoppedEvent, type EventSubscription} from 'react-native-navigation'; |
| 9 | +import {type ComponentWillAppearEvent, type ImageResource, type LayoutOrientation, Navigation, type Options, OptionsModalPresentationStyle, type OptionsTopBarButton, type ScreenPoppedEvent, type EventSubscription, type ComponentDidAppearEvent} from 'react-native-navigation'; |
9 | 10 | import tinyColor from 'tinycolor2'; |
10 | 11 |
|
11 | 12 | import CompassIcon from '@components/compass_icon'; |
12 | 13 | import {Events, Screens, Launch} from '@constants'; |
13 | | -import {NOT_READY} from '@constants/screens'; |
| 14 | +import {NOT_READY, SCREENS_WITH_EXTRA_KEYBOARD} from '@constants/screens'; |
14 | 15 | import {getDefaultThemeByAppearance} from '@context/theme'; |
15 | 16 | import EphemeralStore from '@store/ephemeral_store'; |
16 | 17 | import NavigationStore from '@store/navigation_store'; |
@@ -39,6 +40,8 @@ export function registerNavigationListeners() { |
39 | 40 | Navigation.events().registerScreenPoppedListener(onPoppedListener), |
40 | 41 | Navigation.events().registerCommandListener(onCommandListener), |
41 | 42 | Navigation.events().registerComponentWillAppearListener(onScreenWillAppear), |
| 43 | + Navigation.events().registerComponentDidAppearListener(onScreenDidAppear), |
| 44 | + Navigation.events().registerComponentDidDisappearListener(onScreenDidDisappear), |
42 | 45 | ]; |
43 | 46 | } |
44 | 47 |
|
@@ -76,12 +79,33 @@ function onPoppedListener({componentId}: ScreenPoppedEvent) { |
76 | 79 | NavigationStore.removeScreenFromStack(componentId as AvailableScreens); |
77 | 80 | } |
78 | 81 |
|
| 82 | +function setAndroidSoftKeyboard(screen: AvailableScreens) { |
| 83 | + if (Platform.OS !== 'android') { |
| 84 | + return; |
| 85 | + } |
| 86 | + |
| 87 | + if (SCREENS_WITH_EXTRA_KEYBOARD.has(screen) || (isTablet() && screen === Screens.HOME)) { |
| 88 | + RNUtils.setSoftKeyboardToAdjustNothing(); |
| 89 | + } else { |
| 90 | + RNUtils.setSoftKeyboardToAdjustResize(); |
| 91 | + } |
| 92 | +} |
| 93 | + |
79 | 94 | function onScreenWillAppear(event: ComponentWillAppearEvent) { |
80 | 95 | if (event.componentId === Screens.HOME) { |
81 | 96 | DeviceEventEmitter.emit(Events.TAB_BAR_VISIBLE, true); |
82 | 97 | } |
83 | 98 | } |
84 | 99 |
|
| 100 | +function onScreenDidAppear(event: ComponentDidAppearEvent) { |
| 101 | + setAndroidSoftKeyboard(event.componentId as AvailableScreens); |
| 102 | +} |
| 103 | + |
| 104 | +function onScreenDidDisappear() { |
| 105 | + const screen = NavigationStore.getVisibleScreen(); |
| 106 | + setAndroidSoftKeyboard(screen); |
| 107 | +} |
| 108 | + |
85 | 109 | export const loginAnimationOptions = () => { |
86 | 110 | const theme = getThemeFromState(); |
87 | 111 | return { |
|
0 commit comments