Something went wrong. Try again.
Bluesky app fork with some witchin' additions 💫 forked from jollywhoppers.com/witchsky.app
Something went wrong. Try again.
925 B · 36 lines
TypeScript
at main
12345678910111213141516171819202122232425262728293031323334353637import {useEffect, useState} from 'react'import {Keyboard} from 'react-native'
import {IS_IOS} from '#/env'
export function useIsKeyboardVisible({ iosUseWillEvents,}: { iosUseWillEvents?: boolean} = {}) { const [isKeyboardVisible, setKeyboardVisible] = useState(false)
// NOTE // only iOS supports the "will" events // -prf const showEvent = IS_IOS && iosUseWillEvents ? 'keyboardWillShow' : 'keyboardDidShow' const hideEvent = IS_IOS && iosUseWillEvents ? 'keyboardWillHide' : 'keyboardDidHide'
useEffect(() => { const keyboardShowListener = Keyboard.addListener(showEvent, () => setKeyboardVisible(true), ) const keyboardHideListener = Keyboard.addListener(hideEvent, () => setKeyboardVisible(false), )
return () => { keyboardHideListener.remove() keyboardShowListener.remove() } }, [showEvent, hideEvent])
return [isKeyboardVisible]}