Skip to content

Commit 53e26da

Browse files
authored
fix: empty space android (#6715)
1 parent 553902a commit 53e26da

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

app/containers/MessageComposer/hooks/useEmojiKeyboard.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { createContext, ReactElement, useContext, useState } from 'react';
2+
import { Platform } from 'react-native';
23
import { useKeyboardHandler } from 'react-native-keyboard-controller';
34
import { runOnJS, SharedValue, useAnimatedReaction, useSharedValue } from 'react-native-reanimated';
45
import { useSafeAreaInsets } from 'react-native-safe-area-context';
@@ -77,8 +78,9 @@ export const useEmojiKeyboard = () => {
7778

7879
const { bottom } = useSafeAreaInsets();
7980
const { height } = useKeyboardAnimation();
80-
const keyboardHeight = useSharedValue(bottom);
81-
const previousHeight = useSharedValue(bottom);
81+
const initialHeight = Platform.OS === 'ios' ? bottom : 0;
82+
const keyboardHeight = useSharedValue(initialHeight);
83+
const previousHeight = useSharedValue(initialHeight);
8284

8385
const updateHeight = (force: boolean = false) => {
8486
'worklet';
@@ -90,7 +92,9 @@ export const useEmojiKeyboard = () => {
9092
) {
9193
return;
9294
}
93-
const notch = height.value > 0 ? 0 : bottom;
95+
// On iOS, keyboard controller doesn't include bottom inset, so we add it when keyboard is closed
96+
// On Android, keyboard controller already includes it, so we don't add it
97+
const notch = Platform.OS === 'ios' && height.value === 0 ? bottom : 0;
9498
keyboardHeight.value = height.value + notch;
9599
previousHeight.value = keyboardHeight.value;
96100
};

app/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { Dimensions, EmitterSubscription, Linking } from 'react-native';
33
import { GestureHandlerRootView } from 'react-native-gesture-handler';
4-
import { SafeAreaProvider, initialWindowMetrics } from 'react-native-safe-area-context';
4+
import { SafeAreaProvider } from 'react-native-safe-area-context';
55
import { enableScreens } from 'react-native-screens';
66
import { Provider } from 'react-redux';
77
import { KeyboardProvider } from 'react-native-keyboard-controller';
@@ -208,7 +208,7 @@ export default class Root extends React.Component<{}, IState> {
208208
render() {
209209
const { themePreferences, theme, width, height, scale, fontScale } = this.state;
210210
return (
211-
<SafeAreaProvider initialMetrics={initialWindowMetrics} style={{ backgroundColor: themes[this.state.theme].surfaceRoom }}>
211+
<SafeAreaProvider style={{ backgroundColor: themes[this.state.theme].surfaceRoom }}>
212212
<Provider store={store}>
213213
<ThemeContext.Provider
214214
value={{

0 commit comments

Comments
 (0)