From d20c59e19d457ee2c57496f00dc962ea0c19a691 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Thu, 13 Jun 2024 15:58:56 +0100 Subject: [PATCH] Calculate correct keyboard offset in composer (#4500) * calculate correct keyboard offset * give viewHeight a default value * much simpler approach --- src/view/com/composer/Composer.tsx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/view/com/composer/Composer.tsx b/src/view/com/composer/Composer.tsx index 9bb70401..80bce535 100644 --- a/src/view/com/composer/Composer.tsx +++ b/src/view/com/composer/Composer.tsx @@ -415,12 +415,14 @@ export const ComposePost = observer(function ComposePost({ bottomBarAnimatedStyle, } = useAnimatedBorders() + const keyboardVerticalOffset = useKeyboardVerticalOffset() + return ( + keyboardVerticalOffset={keyboardVerticalOffset} + style={a.flex_1}> @@ -741,6 +743,19 @@ function useAnimatedBorders() { } } +function useKeyboardVerticalOffset() { + const {top} = useSafeAreaInsets() + + // Android etc + if (!isIOS) return 0 + + // iPhone SE + if (top === 20) return 40 + + // all other iPhones + return top + 10 +} + const styles = StyleSheet.create({ topbarInner: { flexDirection: 'row',