Bluesky app fork with some witchin' additions 馃挮 witchsky.app
bluesky fork client
at main 36 lines 925 B view raw
1import {useEffect, useState} from 'react' 2import {Keyboard} from 'react-native' 3 4import {IS_IOS} from '#/env' 5 6export function useIsKeyboardVisible({ 7 iosUseWillEvents, 8}: { 9 iosUseWillEvents?: boolean 10} = {}) { 11 const [isKeyboardVisible, setKeyboardVisible] = useState(false) 12 13 // NOTE 14 // only iOS supports the "will" events 15 // -prf 16 const showEvent = 17 IS_IOS && iosUseWillEvents ? 'keyboardWillShow' : 'keyboardDidShow' 18 const hideEvent = 19 IS_IOS && iosUseWillEvents ? 'keyboardWillHide' : 'keyboardDidHide' 20 21 useEffect(() => { 22 const keyboardShowListener = Keyboard.addListener(showEvent, () => 23 setKeyboardVisible(true), 24 ) 25 const keyboardHideListener = Keyboard.addListener(hideEvent, () => 26 setKeyboardVisible(false), 27 ) 28 29 return () => { 30 keyboardHideListener.remove() 31 keyboardShowListener.remove() 32 } 33 }, [showEvent, hideEvent]) 34 35 return [isKeyboardVisible] 36}