about summary refs log tree commit diff
path: root/src/view/com/composer/Composer.tsx
diff options
context:
space:
mode:
authorSamuel Newman <mozzius@protonmail.com>2024-06-13 15:58:56 +0100
committerGitHub <noreply@github.com>2024-06-13 15:58:56 +0100
commitd20c59e19d457ee2c57496f00dc962ea0c19a691 (patch)
tree25596833fe4e0c560fdf4a67f7b7330da90b2943 /src/view/com/composer/Composer.tsx
parent498e46ae4e698e5a75dec9972209fe2bb8a2a603 (diff)
downloadvoidsky-d20c59e19d457ee2c57496f00dc962ea0c19a691.tar.zst
Calculate correct keyboard offset in composer (#4500)
* calculate correct keyboard offset

* give viewHeight a default value

* much simpler approach
Diffstat (limited to 'src/view/com/composer/Composer.tsx')
-rw-r--r--src/view/com/composer/Composer.tsx19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/view/com/composer/Composer.tsx b/src/view/com/composer/Composer.tsx
index 9bb704012..80bce5351 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 (
     <KeyboardAvoidingView
       testID="composePostView"
       behavior={isIOS ? 'padding' : 'height'}
-      keyboardVerticalOffset={isIOS ? 70 : 0}
-      style={[a.flex_1]}>
+      keyboardVerticalOffset={keyboardVerticalOffset}
+      style={a.flex_1}>
       <View style={[a.flex_1, viewStyles]} aria-modal accessibilityViewIsModal>
         <Animated.View style={topBarAnimatedStyle}>
           <View style={styles.topbarInner}>
@@ -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',