Calculate correct keyboard offset in composer (#4500)
* calculate correct keyboard offset * give viewHeight a default value * much simpler approachzio/stable
parent
498e46ae4e
commit
d20c59e19d
|
@ -415,12 +415,14 @@ export const ComposePost = observer(function ComposePost({
|
||||||
bottomBarAnimatedStyle,
|
bottomBarAnimatedStyle,
|
||||||
} = useAnimatedBorders()
|
} = useAnimatedBorders()
|
||||||
|
|
||||||
|
const keyboardVerticalOffset = useKeyboardVerticalOffset()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<KeyboardAvoidingView
|
<KeyboardAvoidingView
|
||||||
testID="composePostView"
|
testID="composePostView"
|
||||||
behavior={isIOS ? 'padding' : 'height'}
|
behavior={isIOS ? 'padding' : 'height'}
|
||||||
keyboardVerticalOffset={isIOS ? 70 : 0}
|
keyboardVerticalOffset={keyboardVerticalOffset}
|
||||||
style={[a.flex_1]}>
|
style={a.flex_1}>
|
||||||
<View style={[a.flex_1, viewStyles]} aria-modal accessibilityViewIsModal>
|
<View style={[a.flex_1, viewStyles]} aria-modal accessibilityViewIsModal>
|
||||||
<Animated.View style={topBarAnimatedStyle}>
|
<Animated.View style={topBarAnimatedStyle}>
|
||||||
<View style={styles.topbarInner}>
|
<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({
|
const styles = StyleSheet.create({
|
||||||
topbarInner: {
|
topbarInner: {
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
|
|
Loading…
Reference in New Issue