1
- import React , { ReactNode , useContext , useEffect , useMemo } from 'react'
1
+ import React , { ReactNode , useContext , useEffect } from 'react'
2
2
import { DimensionValue , EmitterSubscription , Keyboard , View , ViewStyle } from 'react-native'
3
3
import Animated , { useSharedValue , useAnimatedStyle , withTiming , Easing } from 'react-native-reanimated'
4
- import { GestureDetector , Gesture } from 'react-native-gesture-handler'
5
4
import { KeyboardAvoidContext } from './context'
6
5
import { isIOS } from './utils'
7
6
@@ -19,17 +18,6 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
19
18
const basic = useSharedValue ( 'auto' )
20
19
const keyboardAvoid = useContext ( KeyboardAvoidContext )
21
20
22
- const dismiss = ( ) => {
23
- Keyboard . isVisible ( ) && Keyboard . dismiss ( )
24
- }
25
-
26
- const gesture = useMemo ( ( ) => {
27
- return Gesture . Tap ( )
28
- . onEnd ( ( ) => {
29
- dismiss ( )
30
- } ) . runOnJS ( true )
31
- } , [ ] )
32
-
33
21
const animatedStyle = useAnimatedStyle ( ( ) => ( {
34
22
transform : [ { translateY : - offset . value } ] ,
35
23
flexBasis : basic . value as DimensionValue
@@ -43,6 +31,10 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
43
31
basic . value = 'auto'
44
32
}
45
33
34
+ const onTouchEnd = ( ) => {
35
+ Keyboard . isVisible ( ) && Keyboard . dismiss ( )
36
+ }
37
+
46
38
useEffect ( ( ) => {
47
39
let subscriptions : EmitterSubscription [ ] = [ ]
48
40
@@ -99,18 +91,16 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
99
91
} , [ keyboardAvoid ] )
100
92
101
93
return (
102
- < GestureDetector gesture = { gesture } >
103
- < View style = { style } >
104
- < Animated . View
105
- style = { [
106
- contentContainerStyle ,
107
- animatedStyle
108
- ] }
109
- >
110
- { children }
111
- </ Animated . View >
112
- </ View >
113
- </ GestureDetector >
94
+ < View style = { style } onTouchEnd = { onTouchEnd } >
95
+ < Animated . View
96
+ style = { [
97
+ contentContainerStyle ,
98
+ animatedStyle
99
+ ] }
100
+ >
101
+ { children }
102
+ </ Animated . View >
103
+ </ View >
114
104
)
115
105
}
116
106
0 commit comments