|
1 |
| -import { useEffect, useState } from 'react' |
2 |
| -import { Keyboard, KeyboardEventListener, ScreenRect } from 'react-native' |
| 1 | +import {useEffect, useState} from 'react' |
| 2 | +import {Keyboard, KeyboardEventListener, ScreenRect} from 'react-native' |
3 | 3 |
|
4 | 4 | export default function useKeyboard() {
|
5 | 5 | const [shown, setShown] = useState(false)
|
6 | 6 | const [coordinates, setCoordinates] = useState<{
|
7 | 7 | start: ScreenRect
|
8 | 8 | end: ScreenRect
|
9 | 9 | }>({
|
10 |
| - start: { screenX: 0, screenY: 0, width: 0, height: 0 }, |
11 |
| - end: { screenX: 0, screenY: 0, width: 0, height: 0 }, |
| 10 | + start: {screenX: 0, screenY: 0, width: 0, height: 0}, |
| 11 | + end: {screenX: 0, screenY: 0, width: 0, height: 0}, |
12 | 12 | })
|
13 | 13 | const [keyboardHeight, setKeyboardHeight] = useState<number>(0)
|
14 | 14 |
|
15 | 15 | const handleKeyboardWillShow: KeyboardEventListener = e => {
|
16 |
| - setCoordinates({ start: e.startCoordinates, end: e.endCoordinates }) |
| 16 | + setCoordinates({start: e.startCoordinates, end: e.endCoordinates}) |
17 | 17 | }
|
18 | 18 | const handleKeyboardDidShow: KeyboardEventListener = e => {
|
19 | 19 | setShown(true)
|
20 |
| - setCoordinates({ start: e.startCoordinates, end: e.endCoordinates }) |
| 20 | + setCoordinates({start: e.startCoordinates, end: e.endCoordinates}) |
21 | 21 | setKeyboardHeight(e.endCoordinates.height)
|
22 | 22 | }
|
23 | 23 | const handleKeyboardWillHide: KeyboardEventListener = e => {
|
24 |
| - setCoordinates({ start: e.startCoordinates, end: e.endCoordinates }) |
| 24 | + setCoordinates({start: e.startCoordinates, end: e.endCoordinates}) |
25 | 25 | }
|
26 | 26 | const handleKeyboardDidHide: KeyboardEventListener = e => {
|
27 | 27 | setShown(false)
|
28 | 28 | if (e) {
|
29 |
| - setCoordinates({ start: e.startCoordinates, end: e.endCoordinates }) |
| 29 | + setCoordinates({start: e.startCoordinates, end: e.endCoordinates}) |
30 | 30 | } else {
|
31 | 31 | setCoordinates({
|
32 |
| - start: { screenX: 0, screenY: 0, width: 0, height: 0 } |
33 |
| - , end: { screenX: 0, screenY: 0, width: 0, height: 0 } |
34 |
| - }) |
35 |
| - } |
| 32 | + start: { screenX: 0, screenY: 0, width: 0, height: 0 } |
| 33 | + , end:{ screenX: 0, screenY: 0, width: 0, height: 0 } |
| 34 | + }) |
36 | 35 | setKeyboardHeight(0)
|
37 | 36 | }
|
38 | 37 |
|
|
0 commit comments