From 5217876f241a991e55d789cd5faa8d8ab1890d1b Mon Sep 17 00:00:00 2001 From: Hailey Date: Thu, 23 May 2024 10:01:31 -0700 Subject: Add padding to dialogs when keyboard is open on Android (#4182) * add keyboard padding to android dialogs * missing `keyboardDismissMode` for `ScrollableInner` * add to `MutedWords` * add to `LabelsOnMe` --- src/components/KeyboardPadding.android.tsx | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/components/KeyboardPadding.android.tsx (limited to 'src/components/KeyboardPadding.android.tsx') diff --git a/src/components/KeyboardPadding.android.tsx b/src/components/KeyboardPadding.android.tsx new file mode 100644 index 000000000..40dec3001 --- /dev/null +++ b/src/components/KeyboardPadding.android.tsx @@ -0,0 +1,31 @@ +import React from 'react' +import {useKeyboardHandler} from 'react-native-keyboard-controller' +import Animated, { + useAnimatedStyle, + useSharedValue, +} from 'react-native-reanimated' + +export function KeyboardPadding({maxHeight}: {maxHeight?: number}) { + const keyboardHeight = useSharedValue(0) + + useKeyboardHandler( + { + onMove: e => { + 'worklet' + + if (maxHeight && e.height > maxHeight) { + keyboardHeight.value = maxHeight + } else { + keyboardHeight.value = e.height + } + }, + }, + [maxHeight], + ) + + const animatedStyle = useAnimatedStyle(() => ({ + height: keyboardHeight.value, + })) + + return +} -- cgit 1.4.1