react-native-keyboard-controller 1.11.4 → 1.11.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/KeyboardController-Bridging-Header.h +1 -0
- package/ios/KeyboardController.xcodeproj/project.pbxproj +14 -0
- package/ios/objc/RCTUIManager+LayoutAnimationManager.h +15 -0
- package/ios/objc/RCTUIManager+LayoutAnimationManager.m +32 -0
- package/ios/observers/KeyboardMovementObserver.swift +12 -1
- package/ios/views/KeyboardControllerView.mm +6 -0
- package/ios/views/KeyboardControllerViewManager.swift +14 -0
- package/lib/commonjs/components/KeyboardAvoidingView/hooks.js +7 -4
- package/lib/commonjs/components/KeyboardAvoidingView/hooks.js.map +1 -1
- package/lib/module/components/KeyboardAvoidingView/hooks.js +8 -5
- package/lib/module/components/KeyboardAvoidingView/hooks.js.map +1 -1
- package/package.json +1 -1
- package/src/components/KeyboardAvoidingView/hooks.ts +9 -5
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
084AEEC82ACF4AB2001A3069 /* FocusedInputObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 084AEEC72ACF4AB2001A3069 /* FocusedInputObserver.swift */; };
|
|
17
17
|
089BA5DC2B3E0C9D000A9A90 /* ViewHierarchyNavigator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 089BA5DB2B3E0C9D000A9A90 /* ViewHierarchyNavigator.swift */; };
|
|
18
18
|
08C47AFC2BA9AF7100DB93BB /* KeyboardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08C47AFB2BA9AF7100DB93BB /* KeyboardView.swift */; };
|
|
19
|
+
08DF17B32BB1838D00279890 /* RCTUIManager+LayoutAnimationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 08DF17B22BB1838D00279890 /* RCTUIManager+LayoutAnimationManager.m */; };
|
|
19
20
|
F333F8D428996B8D0015B05F /* KeyboardControllerView.mm in Sources */ = {isa = PBXBuildFile; fileRef = F333F8D228996B8D0015B05F /* KeyboardControllerView.mm */; };
|
|
20
21
|
F359D34F28133C26000B6AFE /* KeyboardControllerModule.mm in Sources */ = {isa = PBXBuildFile; fileRef = F359D34E28133C26000B6AFE /* KeyboardControllerModule.mm */; };
|
|
21
22
|
F3626A0728B3FE760021B2D9 /* KeyboardMovementObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3626A0628B3FE760021B2D9 /* KeyboardMovementObserver.swift */; };
|
|
@@ -47,6 +48,8 @@
|
|
|
47
48
|
084AEEC72ACF4AB2001A3069 /* FocusedInputObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FocusedInputObserver.swift; sourceTree = "<group>"; };
|
|
48
49
|
089BA5DB2B3E0C9D000A9A90 /* ViewHierarchyNavigator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewHierarchyNavigator.swift; sourceTree = "<group>"; };
|
|
49
50
|
08C47AFB2BA9AF7100DB93BB /* KeyboardView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyboardView.swift; sourceTree = "<group>"; };
|
|
51
|
+
08DF17B22BB1838D00279890 /* RCTUIManager+LayoutAnimationManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "RCTUIManager+LayoutAnimationManager.m"; sourceTree = "<group>"; };
|
|
52
|
+
08DF17B52BB1845500279890 /* RCTUIManager+LayoutAnimationManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RCTUIManager+LayoutAnimationManager.h"; sourceTree = "<group>"; };
|
|
50
53
|
134814201AA4EA6300B7C361 /* libKeyboardController.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libKeyboardController.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
51
54
|
B3E7B5891CC2AC0600A0062D /* KeyboardControllerViewManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = KeyboardControllerViewManager.mm; sourceTree = "<group>"; };
|
|
52
55
|
F333F8D128996B1C0015B05F /* KeyboardControllerView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KeyboardControllerView.h; sourceTree = "<group>"; };
|
|
@@ -116,6 +119,15 @@
|
|
|
116
119
|
path = traversal;
|
|
117
120
|
sourceTree = "<group>";
|
|
118
121
|
};
|
|
122
|
+
08DF17B12BB1834400279890 /* objc */ = {
|
|
123
|
+
isa = PBXGroup;
|
|
124
|
+
children = (
|
|
125
|
+
08DF17B22BB1838D00279890 /* RCTUIManager+LayoutAnimationManager.m */,
|
|
126
|
+
08DF17B52BB1845500279890 /* RCTUIManager+LayoutAnimationManager.h */,
|
|
127
|
+
);
|
|
128
|
+
path = objc;
|
|
129
|
+
sourceTree = "<group>";
|
|
130
|
+
};
|
|
119
131
|
134814211AA4EA7D00B7C361 /* Products */ = {
|
|
120
132
|
isa = PBXGroup;
|
|
121
133
|
children = (
|
|
@@ -127,6 +139,7 @@
|
|
|
127
139
|
58B511D21A9E6C8500147676 = {
|
|
128
140
|
isa = PBXGroup;
|
|
129
141
|
children = (
|
|
142
|
+
08DF17B12BB1834400279890 /* objc */,
|
|
130
143
|
089BA5DD2B3EC978000A9A90 /* traversal */,
|
|
131
144
|
084AEEC12ACF405C001A3069 /* views */,
|
|
132
145
|
084AEEC02ACDFC2A001A3069 /* observers */,
|
|
@@ -205,6 +218,7 @@
|
|
|
205
218
|
F4FF95D7245B92E800C19C63 /* KeyboardControllerViewManager.swift in Sources */,
|
|
206
219
|
F333F8D428996B8D0015B05F /* KeyboardControllerView.mm in Sources */,
|
|
207
220
|
0800511E2B65558800928E51 /* TextInput.swift in Sources */,
|
|
221
|
+
08DF17B32BB1838D00279890 /* RCTUIManager+LayoutAnimationManager.m in Sources */,
|
|
208
222
|
08C47AFC2BA9AF7100DB93BB /* KeyboardView.swift in Sources */,
|
|
209
223
|
F3F50669289E653B003091D6 /* KeyboardMoveEvent.m in Sources */,
|
|
210
224
|
083FB9852B15171600C0EFF0 /* TextChangeObserver.swift in Sources */,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RCTUIManager+LayoutAnimationManager.h
|
|
3
|
+
// react-native-keyboard-controller
|
|
4
|
+
//
|
|
5
|
+
// Created by Kiryl Ziusko on 22/03/2024.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import <React/RCTUIManager.h>
|
|
9
|
+
|
|
10
|
+
@interface RCTUIManager (LayoutAnimationManager)
|
|
11
|
+
|
|
12
|
+
- (void)scheduleKeyboardAnimation;
|
|
13
|
+
- (void)unscheduleKeyboardAnimation;
|
|
14
|
+
|
|
15
|
+
@end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RCTUIManager+LayoutAnimationManager.m
|
|
3
|
+
// react-native-keyboard-controller
|
|
4
|
+
//
|
|
5
|
+
// Created by Kiryl Ziusko on 22/03/2024.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import <React/RCTLayoutAnimationGroup.h>
|
|
9
|
+
#import "RCTUIManager+LayoutAnimationManager.h"
|
|
10
|
+
|
|
11
|
+
@implementation RCTUIManager (LayoutAnimationManager)
|
|
12
|
+
|
|
13
|
+
- (void)scheduleKeyboardAnimation
|
|
14
|
+
{
|
|
15
|
+
NSDictionary *animationConfig =
|
|
16
|
+
@{@"duration" : @250, @"update" : @{@"duration" : @250, @"type" : @"keyboard"}};
|
|
17
|
+
|
|
18
|
+
RCTLayoutAnimationGroup *layoutAnimationGroup =
|
|
19
|
+
[[RCTLayoutAnimationGroup alloc] initWithConfig:animationConfig callback:nil];
|
|
20
|
+
|
|
21
|
+
[self setValue:layoutAnimationGroup forKey:@"_layoutAnimationGroup"];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
- (void)unscheduleKeyboardAnimation
|
|
25
|
+
{
|
|
26
|
+
RCTLayoutAnimationGroup *layoutAnimationGroup =
|
|
27
|
+
[[RCTLayoutAnimationGroup alloc] initWithConfig:nil callback:nil];
|
|
28
|
+
|
|
29
|
+
[self setValue:layoutAnimationGroup forKey:@"_layoutAnimationGroup"];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@end
|
|
@@ -14,6 +14,9 @@ public class KeyboardMovementObserver: NSObject {
|
|
|
14
14
|
// class members
|
|
15
15
|
var onEvent: (NSString, NSNumber, NSNumber, NSNumber, NSNumber) -> Void
|
|
16
16
|
var onNotify: (String, Any) -> Void
|
|
17
|
+
// animation
|
|
18
|
+
var onRequestAnimation: () -> Void
|
|
19
|
+
var onCancelAnimation: () -> Void
|
|
17
20
|
// progress tracker
|
|
18
21
|
private var _keyboardView: UIView?
|
|
19
22
|
private var keyboardView: UIView? {
|
|
@@ -39,10 +42,14 @@ public class KeyboardMovementObserver: NSObject {
|
|
|
39
42
|
|
|
40
43
|
@objc public init(
|
|
41
44
|
handler: @escaping (NSString, NSNumber, NSNumber, NSNumber, NSNumber) -> Void,
|
|
42
|
-
onNotify: @escaping (String, Any) -> Void
|
|
45
|
+
onNotify: @escaping (String, Any) -> Void,
|
|
46
|
+
onRequestAnimation: @escaping () -> Void,
|
|
47
|
+
onCancelAnimation: @escaping () -> Void
|
|
43
48
|
) {
|
|
44
49
|
onEvent = handler
|
|
45
50
|
self.onNotify = onNotify
|
|
51
|
+
self.onRequestAnimation = onRequestAnimation
|
|
52
|
+
self.onCancelAnimation = onCancelAnimation
|
|
46
53
|
}
|
|
47
54
|
|
|
48
55
|
@objc public func mount() {
|
|
@@ -167,6 +174,7 @@ public class KeyboardMovementObserver: NSObject {
|
|
|
167
174
|
data["timestamp"] = Date.currentTimeStamp
|
|
168
175
|
data["target"] = tag
|
|
169
176
|
|
|
177
|
+
onRequestAnimation()
|
|
170
178
|
onEvent("onKeyboardMoveStart", Float(keyboardHeight) as NSNumber, 1, duration as NSNumber, tag)
|
|
171
179
|
onNotify("KeyboardController::keyboardWillShow", data)
|
|
172
180
|
|
|
@@ -187,6 +195,7 @@ public class KeyboardMovementObserver: NSObject {
|
|
|
187
195
|
data["timestamp"] = Date.currentTimeStamp
|
|
188
196
|
data["target"] = tag
|
|
189
197
|
|
|
198
|
+
onRequestAnimation()
|
|
190
199
|
onEvent("onKeyboardMoveStart", 0, 0, duration as NSNumber, tag)
|
|
191
200
|
onNotify("KeyboardController::keyboardWillHide", data)
|
|
192
201
|
|
|
@@ -209,6 +218,7 @@ public class KeyboardMovementObserver: NSObject {
|
|
|
209
218
|
data["timestamp"] = Date.currentTimeStamp
|
|
210
219
|
data["target"] = tag
|
|
211
220
|
|
|
221
|
+
onCancelAnimation()
|
|
212
222
|
onEvent("onKeyboardMoveEnd", keyboardHeight as NSNumber, 1, duration as NSNumber, tag)
|
|
213
223
|
onNotify("KeyboardController::keyboardDidShow", data)
|
|
214
224
|
|
|
@@ -228,6 +238,7 @@ public class KeyboardMovementObserver: NSObject {
|
|
|
228
238
|
data["timestamp"] = Date.currentTimeStamp
|
|
229
239
|
data["target"] = tag
|
|
230
240
|
|
|
241
|
+
onCancelAnimation()
|
|
231
242
|
onEvent("onKeyboardMoveEnd", 0 as NSNumber, 0, duration as NSNumber, tag)
|
|
232
243
|
onNotify("KeyboardController::keyboardDidHide", data)
|
|
233
244
|
|
|
@@ -175,6 +175,12 @@ using namespace facebook::react;
|
|
|
175
175
|
}
|
|
176
176
|
onNotify:^(NSString *event, NSDictionary *data) {
|
|
177
177
|
[KeyboardController.shared sendEvent:event body:data];
|
|
178
|
+
}
|
|
179
|
+
onRequestAnimation:^() {
|
|
180
|
+
// no-op for fabric
|
|
181
|
+
}
|
|
182
|
+
onCancelAnimation:^(){
|
|
183
|
+
// no-op for fabric
|
|
178
184
|
}];
|
|
179
185
|
}
|
|
180
186
|
|
|
@@ -52,6 +52,12 @@ class KeyboardControllerView: UIView {
|
|
|
52
52
|
},
|
|
53
53
|
onNotify: { [weak self] event, data in
|
|
54
54
|
self?.onNotify(event: event, data: data)
|
|
55
|
+
},
|
|
56
|
+
onRequestAnimation: { [weak self] in
|
|
57
|
+
self?.onRequestAnimation()
|
|
58
|
+
},
|
|
59
|
+
onCancelAnimation: { [weak self] in
|
|
60
|
+
self?.onCancelAnimation()
|
|
55
61
|
}
|
|
56
62
|
)
|
|
57
63
|
}
|
|
@@ -102,6 +108,14 @@ class KeyboardControllerView: UIView {
|
|
|
102
108
|
)
|
|
103
109
|
}
|
|
104
110
|
|
|
111
|
+
func onRequestAnimation() {
|
|
112
|
+
bridge.uiManager.scheduleKeyboardAnimation()
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
func onCancelAnimation() {
|
|
116
|
+
bridge.uiManager.unscheduleKeyboardAnimation()
|
|
117
|
+
}
|
|
118
|
+
|
|
105
119
|
func onNotify(event: String, data: Any) {
|
|
106
120
|
KeyboardController.shared()?.sendEvent(event, body: data)
|
|
107
121
|
}
|
|
@@ -7,10 +7,13 @@ exports.useKeyboardAnimation = void 0;
|
|
|
7
7
|
var _reactNativeReanimated = require("react-native-reanimated");
|
|
8
8
|
var _reactNativeKeyboardController = require("react-native-keyboard-controller");
|
|
9
9
|
const useKeyboardAnimation = () => {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
10
|
+
const {
|
|
11
|
+
reanimated
|
|
12
|
+
} = (0, _reactNativeKeyboardController.useKeyboardContext)();
|
|
13
|
+
const heightWhenOpened = (0, _reactNativeReanimated.useSharedValue)(-reanimated.height.value);
|
|
14
|
+
const height = (0, _reactNativeReanimated.useSharedValue)(-reanimated.height.value);
|
|
15
|
+
const progress = (0, _reactNativeReanimated.useSharedValue)(reanimated.progress.value);
|
|
16
|
+
const isClosed = (0, _reactNativeReanimated.useSharedValue)(reanimated.progress.value === 0);
|
|
14
17
|
(0, _reactNativeKeyboardController.useKeyboardHandler)({
|
|
15
18
|
onStart: e => {
|
|
16
19
|
"worklet";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNativeReanimated","require","_reactNativeKeyboardController","useKeyboardAnimation","heightWhenOpened","useSharedValue","height","progress","isClosed","useKeyboardHandler","onStart","e","
|
|
1
|
+
{"version":3,"names":["_reactNativeReanimated","require","_reactNativeKeyboardController","useKeyboardAnimation","reanimated","useKeyboardContext","heightWhenOpened","useSharedValue","height","value","progress","isClosed","useKeyboardHandler","onStart","e","onMove","onEnd","duration","exports"],"sources":["hooks.ts"],"sourcesContent":["import { useSharedValue } from \"react-native-reanimated\";\n\nimport {\n useKeyboardContext,\n useKeyboardHandler,\n} from \"react-native-keyboard-controller\";\n\nexport const useKeyboardAnimation = () => {\n const { reanimated } = useKeyboardContext();\n const heightWhenOpened = useSharedValue(-reanimated.height.value);\n const height = useSharedValue(-reanimated.height.value);\n const progress = useSharedValue(reanimated.progress.value);\n const isClosed = useSharedValue(reanimated.progress.value === 0);\n\n useKeyboardHandler(\n {\n onStart: (e) => {\n \"worklet\";\n\n if (e.height > 0) {\n isClosed.value = false;\n heightWhenOpened.value = e.height;\n }\n },\n onMove: (e) => {\n \"worklet\";\n\n progress.value = e.progress;\n height.value = e.height;\n },\n onEnd: (e) => {\n \"worklet\";\n\n isClosed.value = e.height === 0;\n\n // `height` update happens in `onMove` handler\n // in `onEnd` we need to update only if `onMove`\n // wasn't called (i. e. duration === 0)\n //\n // we can not call this code without condition below\n // because in some corner cases (iOS with `secureTextEntry`)\n // `onEnd` can be emitted before `onMove` and in this case\n // it may lead to choppy/glitchy/jumpy UI\n // see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/327\n if (e.duration === 0) {\n progress.value = e.progress;\n height.value = e.height;\n }\n },\n },\n [],\n );\n\n return { height, progress, heightWhenOpened, isClosed };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,sBAAA,GAAAC,OAAA;AAEA,IAAAC,8BAAA,GAAAD,OAAA;AAKO,MAAME,oBAAoB,GAAGA,CAAA,KAAM;EACxC,MAAM;IAAEC;EAAW,CAAC,GAAG,IAAAC,iDAAkB,EAAC,CAAC;EAC3C,MAAMC,gBAAgB,GAAG,IAAAC,qCAAc,EAAC,CAACH,UAAU,CAACI,MAAM,CAACC,KAAK,CAAC;EACjE,MAAMD,MAAM,GAAG,IAAAD,qCAAc,EAAC,CAACH,UAAU,CAACI,MAAM,CAACC,KAAK,CAAC;EACvD,MAAMC,QAAQ,GAAG,IAAAH,qCAAc,EAACH,UAAU,CAACM,QAAQ,CAACD,KAAK,CAAC;EAC1D,MAAME,QAAQ,GAAG,IAAAJ,qCAAc,EAACH,UAAU,CAACM,QAAQ,CAACD,KAAK,KAAK,CAAC,CAAC;EAEhE,IAAAG,iDAAkB,EAChB;IACEC,OAAO,EAAGC,CAAC,IAAK;MACd,SAAS;;MAET,IAAIA,CAAC,CAACN,MAAM,GAAG,CAAC,EAAE;QAChBG,QAAQ,CAACF,KAAK,GAAG,KAAK;QACtBH,gBAAgB,CAACG,KAAK,GAAGK,CAAC,CAACN,MAAM;MACnC;IACF,CAAC;IACDO,MAAM,EAAGD,CAAC,IAAK;MACb,SAAS;;MAETJ,QAAQ,CAACD,KAAK,GAAGK,CAAC,CAACJ,QAAQ;MAC3BF,MAAM,CAACC,KAAK,GAAGK,CAAC,CAACN,MAAM;IACzB,CAAC;IACDQ,KAAK,EAAGF,CAAC,IAAK;MACZ,SAAS;;MAETH,QAAQ,CAACF,KAAK,GAAGK,CAAC,CAACN,MAAM,KAAK,CAAC;;MAE/B;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA,IAAIM,CAAC,CAACG,QAAQ,KAAK,CAAC,EAAE;QACpBP,QAAQ,CAACD,KAAK,GAAGK,CAAC,CAACJ,QAAQ;QAC3BF,MAAM,CAACC,KAAK,GAAGK,CAAC,CAACN,MAAM;MACzB;IACF;EACF,CAAC,EACD,EACF,CAAC;EAED,OAAO;IAAEA,MAAM;IAAEE,QAAQ;IAAEJ,gBAAgB;IAAEK;EAAS,CAAC;AACzD,CAAC;AAACO,OAAA,CAAAf,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { useSharedValue } from "react-native-reanimated";
|
|
2
|
-
import { useKeyboardHandler } from "react-native-keyboard-controller";
|
|
2
|
+
import { useKeyboardContext, useKeyboardHandler } from "react-native-keyboard-controller";
|
|
3
3
|
export const useKeyboardAnimation = () => {
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
4
|
+
const {
|
|
5
|
+
reanimated
|
|
6
|
+
} = useKeyboardContext();
|
|
7
|
+
const heightWhenOpened = useSharedValue(-reanimated.height.value);
|
|
8
|
+
const height = useSharedValue(-reanimated.height.value);
|
|
9
|
+
const progress = useSharedValue(reanimated.progress.value);
|
|
10
|
+
const isClosed = useSharedValue(reanimated.progress.value === 0);
|
|
8
11
|
useKeyboardHandler({
|
|
9
12
|
onStart: e => {
|
|
10
13
|
"worklet";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSharedValue","useKeyboardHandler","useKeyboardAnimation","heightWhenOpened","height","progress","isClosed","onStart","e","
|
|
1
|
+
{"version":3,"names":["useSharedValue","useKeyboardContext","useKeyboardHandler","useKeyboardAnimation","reanimated","heightWhenOpened","height","value","progress","isClosed","onStart","e","onMove","onEnd","duration"],"sources":["hooks.ts"],"sourcesContent":["import { useSharedValue } from \"react-native-reanimated\";\n\nimport {\n useKeyboardContext,\n useKeyboardHandler,\n} from \"react-native-keyboard-controller\";\n\nexport const useKeyboardAnimation = () => {\n const { reanimated } = useKeyboardContext();\n const heightWhenOpened = useSharedValue(-reanimated.height.value);\n const height = useSharedValue(-reanimated.height.value);\n const progress = useSharedValue(reanimated.progress.value);\n const isClosed = useSharedValue(reanimated.progress.value === 0);\n\n useKeyboardHandler(\n {\n onStart: (e) => {\n \"worklet\";\n\n if (e.height > 0) {\n isClosed.value = false;\n heightWhenOpened.value = e.height;\n }\n },\n onMove: (e) => {\n \"worklet\";\n\n progress.value = e.progress;\n height.value = e.height;\n },\n onEnd: (e) => {\n \"worklet\";\n\n isClosed.value = e.height === 0;\n\n // `height` update happens in `onMove` handler\n // in `onEnd` we need to update only if `onMove`\n // wasn't called (i. e. duration === 0)\n //\n // we can not call this code without condition below\n // because in some corner cases (iOS with `secureTextEntry`)\n // `onEnd` can be emitted before `onMove` and in this case\n // it may lead to choppy/glitchy/jumpy UI\n // see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/327\n if (e.duration === 0) {\n progress.value = e.progress;\n height.value = e.height;\n }\n },\n },\n [],\n );\n\n return { height, progress, heightWhenOpened, isClosed };\n};\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,yBAAyB;AAExD,SACEC,kBAAkB,EAClBC,kBAAkB,QACb,kCAAkC;AAEzC,OAAO,MAAMC,oBAAoB,GAAGA,CAAA,KAAM;EACxC,MAAM;IAAEC;EAAW,CAAC,GAAGH,kBAAkB,CAAC,CAAC;EAC3C,MAAMI,gBAAgB,GAAGL,cAAc,CAAC,CAACI,UAAU,CAACE,MAAM,CAACC,KAAK,CAAC;EACjE,MAAMD,MAAM,GAAGN,cAAc,CAAC,CAACI,UAAU,CAACE,MAAM,CAACC,KAAK,CAAC;EACvD,MAAMC,QAAQ,GAAGR,cAAc,CAACI,UAAU,CAACI,QAAQ,CAACD,KAAK,CAAC;EAC1D,MAAME,QAAQ,GAAGT,cAAc,CAACI,UAAU,CAACI,QAAQ,CAACD,KAAK,KAAK,CAAC,CAAC;EAEhEL,kBAAkB,CAChB;IACEQ,OAAO,EAAGC,CAAC,IAAK;MACd,SAAS;;MAET,IAAIA,CAAC,CAACL,MAAM,GAAG,CAAC,EAAE;QAChBG,QAAQ,CAACF,KAAK,GAAG,KAAK;QACtBF,gBAAgB,CAACE,KAAK,GAAGI,CAAC,CAACL,MAAM;MACnC;IACF,CAAC;IACDM,MAAM,EAAGD,CAAC,IAAK;MACb,SAAS;;MAETH,QAAQ,CAACD,KAAK,GAAGI,CAAC,CAACH,QAAQ;MAC3BF,MAAM,CAACC,KAAK,GAAGI,CAAC,CAACL,MAAM;IACzB,CAAC;IACDO,KAAK,EAAGF,CAAC,IAAK;MACZ,SAAS;;MAETF,QAAQ,CAACF,KAAK,GAAGI,CAAC,CAACL,MAAM,KAAK,CAAC;;MAE/B;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA,IAAIK,CAAC,CAACG,QAAQ,KAAK,CAAC,EAAE;QACpBN,QAAQ,CAACD,KAAK,GAAGI,CAAC,CAACH,QAAQ;QAC3BF,MAAM,CAACC,KAAK,GAAGI,CAAC,CAACL,MAAM;MACzB;IACF;EACF,CAAC,EACD,EACF,CAAC;EAED,OAAO;IAAEA,MAAM;IAAEE,QAAQ;IAAEH,gBAAgB;IAAEI;EAAS,CAAC;AACzD,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { useSharedValue } from "react-native-reanimated";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
useKeyboardContext,
|
|
5
|
+
useKeyboardHandler,
|
|
6
|
+
} from "react-native-keyboard-controller";
|
|
4
7
|
|
|
5
8
|
export const useKeyboardAnimation = () => {
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
9
|
+
const { reanimated } = useKeyboardContext();
|
|
10
|
+
const heightWhenOpened = useSharedValue(-reanimated.height.value);
|
|
11
|
+
const height = useSharedValue(-reanimated.height.value);
|
|
12
|
+
const progress = useSharedValue(reanimated.progress.value);
|
|
13
|
+
const isClosed = useSharedValue(reanimated.progress.value === 0);
|
|
10
14
|
|
|
11
15
|
useKeyboardHandler(
|
|
12
16
|
{
|