Skip to content

Commit

Permalink
Fix Android keyboard bug when opening a sheet (#6739)
Browse files Browse the repository at this point in the history
* reimplement KeyboardStickyView

* fix missing arg
  • Loading branch information
mozzius authored Nov 26, 2024
1 parent ce1b04b commit 736ea3f
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/screens/Messages/components/MessagesList.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import React, {useCallback, useRef} from 'react'
import {LayoutChangeEvent, View} from 'react-native'
import {
KeyboardStickyView,
useKeyboardHandler,
} from 'react-native-keyboard-controller'
import {
import {useKeyboardHandler} from 'react-native-keyboard-controller'
import Animated, {
runOnJS,
scrollTo,
useAnimatedRef,
Expand Down Expand Up @@ -270,17 +267,24 @@ export function MessagesList({
scrollTo(flatListRef, 0, 1e7, false)
}
},
onEnd: () => {
onEnd: e => {
'worklet'
keyboardHeight.set(e.height)
if (e.height > bottomOffset) {
scrollTo(flatListRef, 0, 1e7, false)
}
keyboardIsOpening.set(false)
},
},
[bottomOffset],
)

const animatedListStyle = useAnimatedStyle(() => ({
marginBottom:
keyboardHeight.get() > bottomOffset ? keyboardHeight.get() : bottomOffset,
marginBottom: Math.max(keyboardHeight.get(), bottomOffset),
}))

const animatedStickyViewStyle = useAnimatedStyle(() => ({
transform: [{translateY: -Math.max(keyboardHeight.get(), bottomOffset)}],
}))

// -- Message sending
Expand Down Expand Up @@ -422,7 +426,7 @@ export function MessagesList({
}
/>
</ScrollProvider>
<KeyboardStickyView offset={{closed: -bottomOffset, opened: 0}}>
<Animated.View style={animatedStickyViewStyle}>
{convoState.status === ConvoStatus.Disabled ? (
<ChatDisabled />
) : blocked ? (
Expand All @@ -441,7 +445,7 @@ export function MessagesList({
</MessageInput>
</>
)}
</KeyboardStickyView>
</Animated.View>

{isWeb && (
<EmojiPicker
Expand Down

0 comments on commit 736ea3f

Please sign in to comment.