my fork of the bluesky client

Fix Android keyboard bug when opening a sheet (#6739)

* reimplement KeyboardStickyView

* fix missing arg

authored by samuel.fm and committed by

GitHub 736ea3f4 ce1b04b9

+14 -10
+14 -10
src/screens/Messages/components/MessagesList.tsx
··· 1 1 import React, {useCallback, useRef} from 'react' 2 2 import {LayoutChangeEvent, View} from 'react-native' 3 - import { 4 - KeyboardStickyView, 5 - useKeyboardHandler, 6 - } from 'react-native-keyboard-controller' 7 - import { 3 + import {useKeyboardHandler} from 'react-native-keyboard-controller' 4 + import Animated, { 8 5 runOnJS, 9 6 scrollTo, 10 7 useAnimatedRef, ··· 270 267 scrollTo(flatListRef, 0, 1e7, false) 271 268 } 272 269 }, 273 - onEnd: () => { 270 + onEnd: e => { 274 271 'worklet' 272 + keyboardHeight.set(e.height) 273 + if (e.height > bottomOffset) { 274 + scrollTo(flatListRef, 0, 1e7, false) 275 + } 275 276 keyboardIsOpening.set(false) 276 277 }, 277 278 }, ··· 279 280 ) 280 281 281 282 const animatedListStyle = useAnimatedStyle(() => ({ 282 - marginBottom: 283 - keyboardHeight.get() > bottomOffset ? keyboardHeight.get() : bottomOffset, 283 + marginBottom: Math.max(keyboardHeight.get(), bottomOffset), 284 + })) 285 + 286 + const animatedStickyViewStyle = useAnimatedStyle(() => ({ 287 + transform: [{translateY: -Math.max(keyboardHeight.get(), bottomOffset)}], 284 288 })) 285 289 286 290 // -- Message sending ··· 422 426 } 423 427 /> 424 428 </ScrollProvider> 425 - <KeyboardStickyView offset={{closed: -bottomOffset, opened: 0}}> 429 + <Animated.View style={animatedStickyViewStyle}> 426 430 {convoState.status === ConvoStatus.Disabled ? ( 427 431 <ChatDisabled /> 428 432 ) : blocked ? ( ··· 441 445 </MessageInput> 442 446 </> 443 447 )} 444 - </KeyboardStickyView> 448 + </Animated.View> 445 449 446 450 {isWeb && ( 447 451 <EmojiPicker