Files
jitsi-meet/react/features/base/modal/hooks.native.ts
Calinteodor b6d89b0939 feat(modal): fixes around JitsiScreen footer (#17041)
*Add extra px for Jitsi screen footer when native keyboard is visible.
2026-03-02 15:54:41 +02:00

27 lines
853 B
TypeScript

import { useEffect, useState } from 'react';
import { Keyboard, Platform } from 'react-native';
const showEvent = Platform.OS === 'ios' ? 'keyboardWillShow' : 'keyboardDidShow';
const hideEvent = Platform.OS === 'ios' ? 'keyboardWillHide' : 'keyboardDidHide';
/**
* A hook that tracks whether the native keyboard is visible.
*
* @returns {boolean} - Whether the keyboard is visible.
*/
export const useKeyboardVisible = (): boolean => {
const [ keyboardVisible, setKeyboardVisible ] = useState(false);
useEffect(() => {
const showSub = Keyboard.addListener(showEvent, () => setKeyboardVisible(true));
const hideSub = Keyboard.addListener(hideEvent, () => setKeyboardVisible(false));
return () => {
showSub.remove();
hideSub.remove();
};
}, []);
return keyboardVisible;
};