MCPcopy
hub / github.com/BlueWallet/BlueWallet / useKeyboard

Function useKeyboard

hooks/useKeyboard.ts:14–54  ·  view source on GitHub ↗
({ onKeyboardDidShow, onKeyboardDidHide }: UseKeyboardProps = {})

Source from the content-addressed store, hash-verified

12}
13
14export const useKeyboard = ({ onKeyboardDidShow, onKeyboardDidHide }: UseKeyboardProps = {}): KeyboardInfo => {
15 const [keyboardInfo, setKeyboardInfo] = useState<KeyboardInfo>({
16 isVisible: false,
17 height: 0,
18 });
19
20 useEffect(() => {
21 const handleKeyboardDidShow = (event: KeyboardEvent) => {
22 setKeyboardInfo({
23 isVisible: true,
24 height: event.endCoordinates.height,
25 });
26 if (onKeyboardDidShow) {
27 onKeyboardDidShow();
28 }
29 };
30
31 const handleKeyboardDidHide = () => {
32 setKeyboardInfo({
33 isVisible: false,
34 height: 0,
35 });
36 if (onKeyboardDidHide) {
37 onKeyboardDidHide();
38 }
39 };
40
41 const showEvent = Platform.OS === 'ios' ? 'keyboardWillShow' : 'keyboardDidShow';
42 const hideEvent = Platform.OS === 'ios' ? 'keyboardWillHide' : 'keyboardDidHide';
43
44 const showSubscription = Keyboard.addListener(showEvent, handleKeyboardDidShow);
45 const hideSubscription = Keyboard.addListener(hideEvent, handleKeyboardDidHide);
46
47 return () => {
48 showSubscription.remove();
49 hideSubscription.remove();
50 };
51 }, [onKeyboardDidShow, onKeyboardDidHide]);
52
53 return keyboardInfo;
54};

Callers 4

ScanLNDInvoiceFunction · 0.90
SendDetailsFunction · 0.90
CoinControlOutputSheetFunction · 0.90
ImportWalletFunction · 0.90

Calls 1

addListenerMethod · 0.65

Tested by

no test coverage detected