@@ -31,7 +31,7 @@ import { StackActions, useFocusEffect, useNavigation } from "@react-navigation/n
3131import type { ReactNode } from "react" ;
3232import { useEffect , useLayoutEffect , useRef , useState , type RefObject } from "react" ;
3333import { Keyboard , Platform , View , type ViewStyle } from "react-native" ;
34- import { useKeyboardState } from "react-native-keyboard-controller" ;
34+ import { KeyboardController , KeyboardEvents } from "react-native-keyboard-controller" ;
3535import { composerImageGallery } from "../../lib/composerImageGallery" ;
3636import { filePreviewGallery } from "../../lib/filePreviewGallery" ;
3737import { FilePreviewModal , type FilePreviewSource } from "../../components/FilePreviewModal" ;
@@ -470,6 +470,19 @@ export function ComposerSurface(props: {
470470 ) ;
471471}
472472
473+ function useKeyboardShowing ( ) {
474+ const [ showing , setShowing ] = useState ( KeyboardController . isVisible ) ;
475+ useEffect ( ( ) => {
476+ const show = KeyboardEvents . addListener ( "keyboardWillShow" , ( ) => setShowing ( true ) ) ;
477+ const hide = KeyboardEvents . addListener ( "keyboardWillHide" , ( ) => setShowing ( false ) ) ;
478+ return ( ) => {
479+ show . remove ( ) ;
480+ hide . remove ( ) ;
481+ } ;
482+ } , [ ] ) ;
483+ return showing ;
484+ }
485+
473486/** Space below the composer pill, inside the bottom inset it is given. */
474487export const THREAD_COMPOSER_BOTTOM_GUTTER = 6 ;
475488
@@ -483,7 +496,7 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
483496 const fallbackInputRef = useRef < ComposerEditorHandle > ( null ) ;
484497 const inputRef = props . editorRef ?? fallbackInputRef ;
485498 const [ isFocused , setIsFocused ] = useState ( false ) ;
486- const keyboardVisible = useKeyboardState ( ( state ) => state . isVisible ) ;
499+ const keyboardVisible = useKeyboardShowing ( ) ;
487500 const pendingPastedTextAttachmentCountRef = useRef ( 0 ) ;
488501 const pendingNativeImagePasteCountRef = useRef ( 0 ) ;
489502 const [ pendingPastedTextAttachmentCount , setPendingPastedTextAttachmentCount ] = useState ( 0 ) ;
0 commit comments