react-native-keyboard-controller 1.2.0 → 1.3.0
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/android/build.gradle +0 -40
- package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardControllerPackage.kt +44 -8
- package/ios/KeyboardController.xcodeproj/project.pbxproj +2 -2
- package/ios/KeyboardControllerModule.mm +1 -1
- package/ios/KeyboardControllerView.mm +4 -4
- package/lib/commonjs/animated.js +14 -59
- package/lib/commonjs/animated.js.map +1 -1
- package/lib/commonjs/context.js +28 -0
- package/lib/commonjs/context.js.map +1 -0
- package/lib/commonjs/hooks.js +39 -0
- package/lib/commonjs/hooks.js.map +1 -0
- package/lib/commonjs/index.js +39 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/internal.js +27 -0
- package/lib/commonjs/internal.js.map +1 -0
- package/lib/commonjs/monkey-patch.js +3 -3
- package/lib/commonjs/monkey-patch.js.map +1 -1
- package/lib/commonjs/native.js +24 -21
- package/lib/commonjs/native.js.map +1 -1
- package/lib/commonjs/replicas.js +2 -2
- package/lib/commonjs/replicas.js.map +1 -1
- package/lib/commonjs/{KeyboardControllerViewNativeComponent.js → specs/KeyboardControllerViewNativeComponent.js} +0 -0
- package/lib/commonjs/{KeyboardControllerViewNativeComponent.js.map → specs/KeyboardControllerViewNativeComponent.js.map} +0 -0
- package/lib/commonjs/{NativeKeyboardController.js → specs/NativeKeyboardController.js} +0 -0
- package/lib/commonjs/{NativeKeyboardController.js.map → specs/NativeKeyboardController.js.map} +0 -0
- package/lib/commonjs/{NativeStatusBarManagerCompat.js → specs/NativeStatusBarManagerCompat.js} +0 -0
- package/lib/commonjs/{NativeStatusBarManagerCompat.js.map → specs/NativeStatusBarManagerCompat.js.map} +0 -0
- package/lib/commonjs/types.js +6 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/animated.js +12 -50
- package/lib/module/animated.js.map +1 -1
- package/lib/module/context.js +18 -0
- package/lib/module/context.js.map +1 -0
- package/lib/module/hooks.js +20 -0
- package/lib/module/hooks.js.map +1 -0
- package/lib/module/index.js +3 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal.js +19 -0
- package/lib/module/internal.js.map +1 -0
- package/lib/module/monkey-patch.js +4 -3
- package/lib/module/monkey-patch.js.map +1 -1
- package/lib/module/native.js +23 -17
- package/lib/module/native.js.map +1 -1
- package/lib/module/replicas.js +1 -1
- package/lib/module/replicas.js.map +1 -1
- package/lib/module/{KeyboardControllerViewNativeComponent.js → specs/KeyboardControllerViewNativeComponent.js} +0 -0
- package/lib/module/{KeyboardControllerViewNativeComponent.js.map → specs/KeyboardControllerViewNativeComponent.js.map} +0 -0
- package/lib/module/{NativeKeyboardController.js → specs/NativeKeyboardController.js} +0 -0
- package/lib/module/{NativeKeyboardController.js.map → specs/NativeKeyboardController.js.map} +0 -0
- package/lib/module/{NativeStatusBarManagerCompat.js → specs/NativeStatusBarManagerCompat.js} +0 -0
- package/lib/module/{NativeStatusBarManagerCompat.js.map → specs/NativeStatusBarManagerCompat.js.map} +0 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/animated.d.ts +1 -17
- package/lib/typescript/context.d.ts +16 -0
- package/lib/typescript/hooks.d.ts +4 -0
- package/lib/typescript/index.d.ts +3 -0
- package/lib/typescript/internal.d.ts +4 -0
- package/lib/typescript/native.d.ts +14 -26
- package/lib/typescript/{KeyboardControllerViewNativeComponent.d.ts → specs/KeyboardControllerViewNativeComponent.d.ts} +0 -0
- package/lib/typescript/{NativeKeyboardController.d.ts → specs/NativeKeyboardController.d.ts} +0 -0
- package/lib/typescript/{NativeStatusBarManagerCompat.d.ts → specs/NativeStatusBarManagerCompat.d.ts} +0 -0
- package/lib/typescript/types.d.ts +23 -0
- package/package.json +17 -20
- package/react-native-keyboard-controller.podspec +2 -1
- package/src/animated.tsx +12 -75
- package/src/context.ts +28 -0
- package/src/hooks.ts +28 -0
- package/src/index.ts +3 -0
- package/src/internal.ts +27 -0
- package/src/{monkey-patch.tsx → monkey-patch.ts} +3 -6
- package/src/native.ts +37 -66
- package/src/replicas.ts +1 -1
- package/src/{KeyboardControllerViewNativeComponent.ts → specs/KeyboardControllerViewNativeComponent.ts} +0 -0
- package/src/{NativeKeyboardController.ts → specs/NativeKeyboardController.ts} +0 -0
- package/src/{NativeStatusBarManagerCompat.ts → specs/NativeStatusBarManagerCompat.ts} +0 -0
- package/src/types.ts +42 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +0 -5
- package/android/gradlew +0 -185
- package/android/gradlew.bat +0 -89
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerComponentsRegistry.kt +0 -31
- package/android/src/main/jni/Android.mk +0 -42
- package/android/src/main/jni/KeyboardControllerComponentsRegistry.cpp +0 -71
- package/android/src/main/jni/KeyboardControllerComponentsRegistry.h +0 -35
- package/android/src/main/jni/OnLoad.cpp +0 -9
- package/lib/commonjs/architecture.js +0 -13
- package/lib/commonjs/architecture.js.map +0 -1
- package/lib/module/architecture.js +0 -5
- package/lib/module/architecture.js.map +0 -1
- package/lib/typescript/architecture.d.ts +0 -2
- package/src/architecture.ts +0 -4
package/android/build.gradle
CHANGED
|
@@ -46,41 +46,11 @@ android {
|
|
|
46
46
|
versionCode 1
|
|
47
47
|
versionName "1.0"
|
|
48
48
|
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
49
|
-
if (isNewArchitectureEnabled()) {
|
|
50
|
-
var appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
|
|
51
|
-
externalNativeBuild {
|
|
52
|
-
ndkBuild {
|
|
53
|
-
arguments "APP_PLATFORM=android-21",
|
|
54
|
-
"APP_STL=c++_shared",
|
|
55
|
-
"NDK_TOOLCHAIN_VERSION=clang",
|
|
56
|
-
"GENERATED_SRC_DIR=${appProject.buildDir}/generated/source",
|
|
57
|
-
"PROJECT_BUILD_DIR=${appProject.buildDir}",
|
|
58
|
-
"REACT_ANDROID_DIR=${appProject.rootDir}/../node_modules/react-native/ReactAndroid",
|
|
59
|
-
"REACT_ANDROID_BUILD_DIR=${appProject.rootDir}/../node_modules/react-native/ReactAndroid/build"
|
|
60
|
-
cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1"
|
|
61
|
-
cppFlags "-std=c++17"
|
|
62
|
-
targets "reactnativekeyboardcontroller_modules"
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
49
|
ndk {
|
|
67
50
|
abiFilters (*reactNativeArchitectures())
|
|
68
51
|
}
|
|
69
52
|
}
|
|
70
53
|
|
|
71
|
-
if (isNewArchitectureEnabled()) {
|
|
72
|
-
externalNativeBuild {
|
|
73
|
-
ndkBuild {
|
|
74
|
-
path "src/main/jni/Android.mk"
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
packagingOptions {
|
|
79
|
-
exclude "**/libreact_render_*.so"
|
|
80
|
-
exclude "**/librrc_root.so"
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
54
|
sourceSets {
|
|
85
55
|
main {
|
|
86
56
|
if (isNewArchitectureEnabled()) {
|
|
@@ -186,13 +156,3 @@ dependencies {
|
|
|
186
156
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
187
157
|
implementation 'androidx.core:core-ktx:1.5.0-beta03'
|
|
188
158
|
}
|
|
189
|
-
|
|
190
|
-
if (isNewArchitectureEnabled()) {
|
|
191
|
-
react {
|
|
192
|
-
reactNativeDir = rootProject.file("../node_modules/react-native/")
|
|
193
|
-
jsRootDir = file("../src/")
|
|
194
|
-
codegenDir = rootProject.file("../node_modules/react-native-codegen/")
|
|
195
|
-
libraryName = "reactnativekeyboardcontroller"
|
|
196
|
-
codegenJavaPackageName = "com.reactnativekeyboardcontroller"
|
|
197
|
-
}
|
|
198
|
-
}
|
package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardControllerPackage.kt
CHANGED
|
@@ -1,21 +1,57 @@
|
|
|
1
1
|
package com.reactnativekeyboardcontroller
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import androidx.annotation.Nullable
|
|
4
|
+
import com.facebook.react.TurboReactPackage
|
|
4
5
|
import com.facebook.react.bridge.NativeModule
|
|
5
6
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
8
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
6
9
|
import com.facebook.react.uimanager.ViewManager
|
|
7
|
-
import com.facebook.soloader.SoLoader
|
|
8
10
|
|
|
9
|
-
class KeyboardControllerPackage :
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
class KeyboardControllerPackage : TurboReactPackage() {
|
|
12
|
+
@Nullable
|
|
13
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
14
|
+
return when (name) {
|
|
15
|
+
KeyboardControllerModuleImpl.NAME -> {
|
|
16
|
+
KeyboardControllerModule(reactContext)
|
|
17
|
+
}
|
|
18
|
+
StatusBarManagerCompatImpl.NAME -> {
|
|
19
|
+
StatusBarManagerCompatModule(reactContext)
|
|
20
|
+
}
|
|
21
|
+
else -> {
|
|
22
|
+
null
|
|
23
|
+
}
|
|
24
|
+
}
|
|
12
25
|
}
|
|
13
26
|
|
|
14
|
-
override fun
|
|
15
|
-
|
|
16
|
-
|
|
27
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
28
|
+
return ReactModuleInfoProvider {
|
|
29
|
+
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
|
|
30
|
+
val isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
|
|
31
|
+
|
|
32
|
+
moduleInfos[KeyboardControllerModuleImpl.NAME] = ReactModuleInfo(
|
|
33
|
+
KeyboardControllerModuleImpl.NAME,
|
|
34
|
+
KeyboardControllerModuleImpl.NAME,
|
|
35
|
+
false, // canOverrideExistingModule
|
|
36
|
+
false, // needsEagerInit
|
|
37
|
+
true, // hasConstants
|
|
38
|
+
false, // isCxxModule
|
|
39
|
+
isTurboModule // isTurboModule
|
|
40
|
+
)
|
|
41
|
+
moduleInfos[StatusBarManagerCompatImpl.NAME] = ReactModuleInfo(
|
|
42
|
+
StatusBarManagerCompatImpl.NAME,
|
|
43
|
+
StatusBarManagerCompatImpl.NAME,
|
|
44
|
+
false, // canOverrideExistingModule
|
|
45
|
+
false, // needsEagerInit
|
|
46
|
+
true, // hasConstants
|
|
47
|
+
false, // isCxxModule
|
|
48
|
+
isTurboModule // isTurboModule
|
|
49
|
+
)
|
|
50
|
+
moduleInfos
|
|
17
51
|
}
|
|
52
|
+
}
|
|
18
53
|
|
|
54
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
19
55
|
return listOf(KeyboardControllerViewManager(reactContext))
|
|
20
56
|
}
|
|
21
57
|
}
|
|
@@ -187,7 +187,7 @@
|
|
|
187
187
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
|
188
188
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
|
189
189
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
|
190
|
-
IPHONEOS_DEPLOYMENT_TARGET =
|
|
190
|
+
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
|
|
191
191
|
MTL_ENABLE_DEBUG_INFO = YES;
|
|
192
192
|
ONLY_ACTIVE_ARCH = YES;
|
|
193
193
|
SDKROOT = iphoneos;
|
|
@@ -230,7 +230,7 @@
|
|
|
230
230
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
|
231
231
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
|
232
232
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
|
233
|
-
IPHONEOS_DEPLOYMENT_TARGET =
|
|
233
|
+
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
|
|
234
234
|
MTL_ENABLE_DEBUG_INFO = NO;
|
|
235
235
|
SDKROOT = iphoneos;
|
|
236
236
|
VALIDATE_PRODUCT = YES;
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
// Thanks to this guard, we won't import this header when we build for the old architecture.
|
|
13
13
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
14
14
|
#import <FBReactNativeSpec/FBReactNativeSpec.h>
|
|
15
|
-
#import
|
|
15
|
+
#import <reactnativekeyboardcontroller/reactnativekeyboardcontroller.h>
|
|
16
16
|
#endif
|
|
17
17
|
|
|
18
18
|
#import "KeyboardControllerModule-Header.h"
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
#import "KeyboardMoveEvent.h"
|
|
13
13
|
#import "react_native_keyboard_controller-Swift.h"
|
|
14
14
|
|
|
15
|
-
#import <react/renderer/components/
|
|
16
|
-
#import <react/renderer/components/
|
|
17
|
-
#import <react/renderer/components/
|
|
18
|
-
#import <react/renderer/components/
|
|
15
|
+
#import <react/renderer/components/reactnativekeyboardcontroller/ComponentDescriptors.h>
|
|
16
|
+
#import <react/renderer/components/reactnativekeyboardcontroller/EventEmitters.h>
|
|
17
|
+
#import <react/renderer/components/reactnativekeyboardcontroller/Props.h>
|
|
18
|
+
#import <react/renderer/components/reactnativekeyboardcontroller/RCTComponentViewHelpers.h>
|
|
19
19
|
|
|
20
20
|
#import <React/RCTBridge+Private.h>
|
|
21
21
|
|
package/lib/commonjs/animated.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.styles = exports.KeyboardProvider = void 0;
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
@@ -11,6 +11,10 @@ var _reactNative = require("react-native");
|
|
|
11
11
|
|
|
12
12
|
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
13
13
|
|
|
14
|
+
var _context = require("./context");
|
|
15
|
+
|
|
16
|
+
var _internal = require("./internal");
|
|
17
|
+
|
|
14
18
|
var _native = require("./native");
|
|
15
19
|
|
|
16
20
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -19,59 +23,6 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
19
23
|
|
|
20
24
|
const KeyboardControllerViewAnimated = _reactNativeReanimated.default.createAnimatedComponent(_reactNative.Animated.createAnimatedComponent(_native.KeyboardControllerView));
|
|
21
25
|
|
|
22
|
-
const defaultContext = {
|
|
23
|
-
animated: {
|
|
24
|
-
progress: new _reactNative.Animated.Value(0),
|
|
25
|
-
height: new _reactNative.Animated.Value(0)
|
|
26
|
-
},
|
|
27
|
-
reanimated: {
|
|
28
|
-
progress: {
|
|
29
|
-
value: 0
|
|
30
|
-
},
|
|
31
|
-
height: {
|
|
32
|
-
value: 0
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const KeyboardContext = /*#__PURE__*/_react.default.createContext(defaultContext);
|
|
38
|
-
|
|
39
|
-
exports.KeyboardContext = KeyboardContext;
|
|
40
|
-
|
|
41
|
-
const useKeyboardAnimation = () => {
|
|
42
|
-
(0, _native.useResizeMode)();
|
|
43
|
-
const context = (0, _react.useContext)(KeyboardContext);
|
|
44
|
-
return context.animated;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
exports.useKeyboardAnimation = useKeyboardAnimation;
|
|
48
|
-
|
|
49
|
-
const useReanimatedKeyboardAnimation = () => {
|
|
50
|
-
(0, _native.useResizeMode)();
|
|
51
|
-
const context = (0, _react.useContext)(KeyboardContext);
|
|
52
|
-
return context.reanimated;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
exports.useReanimatedKeyboardAnimation = useReanimatedKeyboardAnimation;
|
|
56
|
-
|
|
57
|
-
function useAnimatedKeyboardHandler(handlers, dependencies) {
|
|
58
|
-
const {
|
|
59
|
-
context,
|
|
60
|
-
doDependenciesDiffer
|
|
61
|
-
} = (0, _reactNativeReanimated.useHandler)(handlers, dependencies);
|
|
62
|
-
return (0, _reactNativeReanimated.useEvent)(event => {
|
|
63
|
-
'worklet';
|
|
64
|
-
|
|
65
|
-
const {
|
|
66
|
-
onKeyboardMove
|
|
67
|
-
} = handlers;
|
|
68
|
-
|
|
69
|
-
if (onKeyboardMove && event.eventName.endsWith('onKeyboardMove')) {
|
|
70
|
-
onKeyboardMove(event, context);
|
|
71
|
-
}
|
|
72
|
-
}, ['onKeyboardMove'], doDependenciesDiffer);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
26
|
const styles = _reactNative.StyleSheet.create({
|
|
76
27
|
container: {
|
|
77
28
|
flex: 1
|
|
@@ -89,10 +40,13 @@ const KeyboardProvider = _ref => {
|
|
|
89
40
|
children,
|
|
90
41
|
statusBarTranslucent
|
|
91
42
|
} = _ref;
|
|
43
|
+
// animated values
|
|
92
44
|
const progress = (0, _react.useRef)(new _reactNative.Animated.Value(0)).current;
|
|
93
|
-
const height = (0, _react.useRef)(new _reactNative.Animated.Value(0)).current;
|
|
45
|
+
const height = (0, _react.useRef)(new _reactNative.Animated.Value(0)).current; // shared values
|
|
46
|
+
|
|
94
47
|
const progressSV = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
95
|
-
const heightSV = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
48
|
+
const heightSV = (0, _reactNativeReanimated.useSharedValue)(0); // memo
|
|
49
|
+
|
|
96
50
|
const context = (0, _react.useMemo)(() => ({
|
|
97
51
|
animated: {
|
|
98
52
|
progress: progress,
|
|
@@ -117,8 +71,9 @@ const KeyboardProvider = _ref => {
|
|
|
117
71
|
}
|
|
118
72
|
}], {
|
|
119
73
|
useNativeDriver: true
|
|
120
|
-
}), []);
|
|
121
|
-
|
|
74
|
+
}), []); // handlers
|
|
75
|
+
|
|
76
|
+
const handler = (0, _internal.useAnimatedKeyboardHandler)({
|
|
122
77
|
onKeyboardMove: event => {
|
|
123
78
|
'worklet';
|
|
124
79
|
|
|
@@ -126,7 +81,7 @@ const KeyboardProvider = _ref => {
|
|
|
126
81
|
heightSV.value = event.height;
|
|
127
82
|
}
|
|
128
83
|
}, []);
|
|
129
|
-
return /*#__PURE__*/_react.default.createElement(KeyboardContext.Provider, {
|
|
84
|
+
return /*#__PURE__*/_react.default.createElement(_context.KeyboardContext.Provider, {
|
|
130
85
|
value: context
|
|
131
86
|
}, /*#__PURE__*/_react.default.createElement(KeyboardControllerViewAnimated, {
|
|
132
87
|
onKeyboardMoveReanimated: handler,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["KeyboardControllerViewAnimated","Reanimated","createAnimatedComponent","Animated","KeyboardControllerView","
|
|
1
|
+
{"version":3,"names":["KeyboardControllerViewAnimated","Reanimated","createAnimatedComponent","Animated","KeyboardControllerView","styles","StyleSheet","create","container","flex","hidden","display","position","KeyboardProvider","children","statusBarTranslucent","progress","useRef","Value","current","height","progressSV","useSharedValue","heightSV","context","useMemo","animated","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","handler","useAnimatedKeyboardHandler","value"],"sources":["animated.tsx"],"sourcesContent":["import React, { useMemo, useRef } from 'react';\nimport { Animated, StyleSheet, ViewStyle } from 'react-native';\nimport Reanimated, { useSharedValue } from 'react-native-reanimated';\n\nimport { KeyboardContext } from './context';\nimport { useAnimatedKeyboardHandler } from './internal';\nimport { KeyboardControllerView } from './native';\n\nimport type { KeyboardControllerProps, NativeEvent } from './types';\n\nconst KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(\n Animated.createAnimatedComponent(\n KeyboardControllerView\n ) as React.FC<KeyboardControllerProps>\n);\n\ntype Styles = {\n container: ViewStyle;\n hidden: ViewStyle;\n};\n\nexport const styles = StyleSheet.create<Styles>({\n container: {\n flex: 1,\n },\n hidden: {\n display: 'none',\n position: 'absolute',\n },\n});\n\ntype KeyboardProviderProps = {\n children: React.ReactNode;\n /**\n * Set the value to `true`, if you use translucent status bar on Android.\n * If you already control status bar translucency via `react-native-screens`\n * or `StatusBar` component from `react-native`, you can ignore it.\n * Defaults to `false`.\n *\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/14\n * @platform android\n */\n statusBarTranslucent?: boolean;\n};\n\nexport const KeyboardProvider = ({\n children,\n statusBarTranslucent,\n}: KeyboardProviderProps) => {\n // animated values\n const progress = useRef(new Animated.Value(0)).current;\n const height = useRef(new Animated.Value(0)).current;\n // shared values\n const progressSV = useSharedValue(0);\n const heightSV = useSharedValue(0);\n // memo\n const context = useMemo(\n () => ({\n animated: { progress: progress, height: height },\n reanimated: { progress: progressSV, height: heightSV },\n }),\n []\n );\n const style = useMemo(\n () => [\n styles.hidden,\n { transform: [{ translateX: height }, { translateY: progress }] },\n ],\n []\n );\n const onKeyboardMove = useMemo(\n () =>\n Animated.event(\n [\n {\n nativeEvent: {\n progress,\n height,\n },\n },\n ],\n { useNativeDriver: true }\n ),\n []\n );\n // handlers\n const handler = useAnimatedKeyboardHandler(\n {\n onKeyboardMove: (event: NativeEvent) => {\n 'worklet';\n progressSV.value = event.progress;\n heightSV.value = event.height;\n },\n },\n []\n );\n\n return (\n <KeyboardContext.Provider value={context}>\n <KeyboardControllerViewAnimated\n onKeyboardMoveReanimated={handler}\n onKeyboardMove={onKeyboardMove}\n statusBarTranslucent={statusBarTranslucent}\n style={styles.container}\n >\n <>\n <Animated.View\n // we are using this small hack, because if the component (where\n // animated value has been used) is unmounted, then animation will\n // stop receiving events (seems like it's react-native optimization).\n // So we need to keep a reference to the animated value, to keep it's\n // always mounted (keep a reference to an animated value).\n //\n // To test why it's needed, try to open screen which consumes Animated.Value\n // then close it and open it again (for example 'Animated transition').\n style={style}\n />\n {children}\n </>\n </KeyboardControllerViewAnimated>\n </KeyboardContext.Provider>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;AAIA,MAAMA,8BAA8B,GAAGC,8BAAA,CAAWC,uBAAX,CACrCC,qBAAA,CAASD,uBAAT,CACEE,8BADF,CADqC,CAAvC;;AAWO,MAAMC,MAAM,GAAGC,uBAAA,CAAWC,MAAX,CAA0B;EAC9CC,SAAS,EAAE;IACTC,IAAI,EAAE;EADG,CADmC;EAI9CC,MAAM,EAAE;IACNC,OAAO,EAAE,MADH;IAENC,QAAQ,EAAE;EAFJ;AAJsC,CAA1B,CAAf;;;;AAwBA,MAAMC,gBAAgB,GAAG,QAGH;EAAA,IAHI;IAC/BC,QAD+B;IAE/BC;EAF+B,CAGJ;EAC3B;EACA,MAAMC,QAAQ,GAAG,IAAAC,aAAA,EAAO,IAAId,qBAAA,CAASe,KAAb,CAAmB,CAAnB,CAAP,EAA8BC,OAA/C;EACA,MAAMC,MAAM,GAAG,IAAAH,aAAA,EAAO,IAAId,qBAAA,CAASe,KAAb,CAAmB,CAAnB,CAAP,EAA8BC,OAA7C,CAH2B,CAI3B;;EACA,MAAME,UAAU,GAAG,IAAAC,qCAAA,EAAe,CAAf,CAAnB;EACA,MAAMC,QAAQ,GAAG,IAAAD,qCAAA,EAAe,CAAf,CAAjB,CAN2B,CAO3B;;EACA,MAAME,OAAO,GAAG,IAAAC,cAAA,EACd,OAAO;IACLC,QAAQ,EAAE;MAAEV,QAAQ,EAAEA,QAAZ;MAAsBI,MAAM,EAAEA;IAA9B,CADL;IAELO,UAAU,EAAE;MAAEX,QAAQ,EAAEK,UAAZ;MAAwBD,MAAM,EAAEG;IAAhC;EAFP,CAAP,CADc,EAKd,EALc,CAAhB;EAOA,MAAMK,KAAK,GAAG,IAAAH,cAAA,EACZ,MAAM,CACJpB,MAAM,CAACK,MADH,EAEJ;IAAEmB,SAAS,EAAE,CAAC;MAAEC,UAAU,EAAEV;IAAd,CAAD,EAAyB;MAAEW,UAAU,EAAEf;IAAd,CAAzB;EAAb,CAFI,CADM,EAKZ,EALY,CAAd;EAOA,MAAMgB,cAAc,GAAG,IAAAP,cAAA,EACrB,MACEtB,qBAAA,CAAS8B,KAAT,CACE,CACE;IACEC,WAAW,EAAE;MACXlB,QADW;MAEXI;IAFW;EADf,CADF,CADF,EASE;IAAEe,eAAe,EAAE;EAAnB,CATF,CAFmB,EAarB,EAbqB,CAAvB,CAtB2B,CAqC3B;;EACA,MAAMC,OAAO,GAAG,IAAAC,oCAAA,EACd;IACEL,cAAc,EAAGC,KAAD,IAAwB;MACtC;;MACAZ,UAAU,CAACiB,KAAX,GAAmBL,KAAK,CAACjB,QAAzB;MACAO,QAAQ,CAACe,KAAT,GAAiBL,KAAK,CAACb,MAAvB;IACD;EALH,CADc,EAQd,EARc,CAAhB;EAWA,oBACE,6BAAC,wBAAD,CAAiB,QAAjB;IAA0B,KAAK,EAAEI;EAAjC,gBACE,6BAAC,8BAAD;IACE,wBAAwB,EAAEY,OAD5B;IAEE,cAAc,EAAEJ,cAFlB;IAGE,oBAAoB,EAAEjB,oBAHxB;IAIE,KAAK,EAAEV,MAAM,CAACG;EAJhB,gBAME,yEACE,6BAAC,qBAAD,CAAU,IAAV;IACE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,KAAK,EAAEoB;EATT,EADF,EAYGd,QAZH,CANF,CADF,CADF;AAyBD,CA7EM"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.KeyboardContext = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _reactNative = require("react-native");
|
|
11
|
+
|
|
12
|
+
const defaultContext = {
|
|
13
|
+
animated: {
|
|
14
|
+
progress: new _reactNative.Animated.Value(0),
|
|
15
|
+
height: new _reactNative.Animated.Value(0)
|
|
16
|
+
},
|
|
17
|
+
reanimated: {
|
|
18
|
+
progress: {
|
|
19
|
+
value: 0
|
|
20
|
+
},
|
|
21
|
+
height: {
|
|
22
|
+
value: 0
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const KeyboardContext = /*#__PURE__*/(0, _react.createContext)(defaultContext);
|
|
27
|
+
exports.KeyboardContext = KeyboardContext;
|
|
28
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["defaultContext","animated","progress","Animated","Value","height","reanimated","value","KeyboardContext","createContext"],"sources":["context.ts"],"sourcesContent":["import { createContext } from 'react';\nimport { Animated } from 'react-native';\n\nimport type { SharedValue } from 'react-native-reanimated';\n\nexport type AnimatedContext = {\n progress: Animated.Value;\n height: Animated.Value;\n};\nexport type ReanimatedContext = {\n progress: SharedValue<number>;\n height: SharedValue<number>;\n};\nexport type KeyboardAnimationContext = {\n animated: AnimatedContext;\n reanimated: ReanimatedContext;\n};\nconst defaultContext: KeyboardAnimationContext = {\n animated: {\n progress: new Animated.Value(0),\n height: new Animated.Value(0),\n },\n reanimated: {\n progress: { value: 0 },\n height: { value: 0 },\n },\n};\nexport const KeyboardContext = createContext(defaultContext);\n"],"mappings":";;;;;;;AAAA;;AACA;;AAgBA,MAAMA,cAAwC,GAAG;EAC/CC,QAAQ,EAAE;IACRC,QAAQ,EAAE,IAAIC,qBAAA,CAASC,KAAb,CAAmB,CAAnB,CADF;IAERC,MAAM,EAAE,IAAIF,qBAAA,CAASC,KAAb,CAAmB,CAAnB;EAFA,CADqC;EAK/CE,UAAU,EAAE;IACVJ,QAAQ,EAAE;MAAEK,KAAK,EAAE;IAAT,CADA;IAEVF,MAAM,EAAE;MAAEE,KAAK,EAAE;IAAT;EAFE;AALmC,CAAjD;AAUO,MAAMC,eAAe,gBAAG,IAAAC,oBAAA,EAAcT,cAAd,CAAxB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useResizeMode = exports.useReanimatedKeyboardAnimation = exports.useKeyboardAnimation = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _context = require("./context");
|
|
11
|
+
|
|
12
|
+
var _native = require("./native");
|
|
13
|
+
|
|
14
|
+
const useResizeMode = () => {
|
|
15
|
+
(0, _react.useEffect)(() => {
|
|
16
|
+
_native.KeyboardController.setInputMode(_native.AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE);
|
|
17
|
+
|
|
18
|
+
return () => _native.KeyboardController.setDefaultMode();
|
|
19
|
+
}, []);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
exports.useResizeMode = useResizeMode;
|
|
23
|
+
|
|
24
|
+
const useKeyboardAnimation = () => {
|
|
25
|
+
useResizeMode();
|
|
26
|
+
const context = (0, _react.useContext)(_context.KeyboardContext);
|
|
27
|
+
return context.animated;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
exports.useKeyboardAnimation = useKeyboardAnimation;
|
|
31
|
+
|
|
32
|
+
const useReanimatedKeyboardAnimation = () => {
|
|
33
|
+
useResizeMode();
|
|
34
|
+
const context = (0, _react.useContext)(_context.KeyboardContext);
|
|
35
|
+
return context.reanimated;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
exports.useReanimatedKeyboardAnimation = useReanimatedKeyboardAnimation;
|
|
39
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useResizeMode","useEffect","KeyboardController","setInputMode","AndroidSoftInputModes","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","useKeyboardAnimation","context","useContext","KeyboardContext","animated","useReanimatedKeyboardAnimation","reanimated"],"sources":["hooks.ts"],"sourcesContent":["import { useContext, useEffect } from 'react';\n\nimport { AnimatedContext, KeyboardContext, ReanimatedContext } from './context';\nimport { AndroidSoftInputModes, KeyboardController } from './native';\n\nexport const useResizeMode = () => {\n useEffect(() => {\n KeyboardController.setInputMode(\n AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE\n );\n\n return () => KeyboardController.setDefaultMode();\n }, []);\n};\n\nexport const useKeyboardAnimation = (): AnimatedContext => {\n useResizeMode();\n const context = useContext(KeyboardContext);\n\n return context.animated;\n};\n\nexport const useReanimatedKeyboardAnimation = (): ReanimatedContext => {\n useResizeMode();\n const context = useContext(KeyboardContext);\n\n return context.reanimated;\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;AAEO,MAAMA,aAAa,GAAG,MAAM;EACjC,IAAAC,gBAAA,EAAU,MAAM;IACdC,0BAAA,CAAmBC,YAAnB,CACEC,6BAAA,CAAsBC,wBADxB;;IAIA,OAAO,MAAMH,0BAAA,CAAmBI,cAAnB,EAAb;EACD,CAND,EAMG,EANH;AAOD,CARM;;;;AAUA,MAAMC,oBAAoB,GAAG,MAAuB;EACzDP,aAAa;EACb,MAAMQ,OAAO,GAAG,IAAAC,iBAAA,EAAWC,wBAAX,CAAhB;EAEA,OAAOF,OAAO,CAACG,QAAf;AACD,CALM;;;;AAOA,MAAMC,8BAA8B,GAAG,MAAyB;EACrEZ,aAAa;EACb,MAAMQ,OAAO,GAAG,IAAAC,iBAAA,EAAWC,wBAAX,CAAhB;EAEA,OAAOF,OAAO,CAACK,UAAf;AACD,CALM"}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -44,4 +44,43 @@ Object.keys(_replicas).forEach(function (key) {
|
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
46
|
});
|
|
47
|
+
|
|
48
|
+
var _context = require("./context");
|
|
49
|
+
|
|
50
|
+
Object.keys(_context).forEach(function (key) {
|
|
51
|
+
if (key === "default" || key === "__esModule") return;
|
|
52
|
+
if (key in exports && exports[key] === _context[key]) return;
|
|
53
|
+
Object.defineProperty(exports, key, {
|
|
54
|
+
enumerable: true,
|
|
55
|
+
get: function () {
|
|
56
|
+
return _context[key];
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
var _hooks = require("./hooks");
|
|
62
|
+
|
|
63
|
+
Object.keys(_hooks).forEach(function (key) {
|
|
64
|
+
if (key === "default" || key === "__esModule") return;
|
|
65
|
+
if (key in exports && exports[key] === _hooks[key]) return;
|
|
66
|
+
Object.defineProperty(exports, key, {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function () {
|
|
69
|
+
return _hooks[key];
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
var _types = require("./types");
|
|
75
|
+
|
|
76
|
+
Object.keys(_types).forEach(function (key) {
|
|
77
|
+
if (key === "default" || key === "__esModule") return;
|
|
78
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
79
|
+
Object.defineProperty(exports, key, {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
get: function () {
|
|
82
|
+
return _types[key];
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
47
86
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import './monkey-patch';\n\nexport * from './native';\nexport * from './animated';\nexport * from './replicas';\n"],"mappings":";;;;;;AAAA;;AAEA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import './monkey-patch';\n\nexport * from './native';\nexport * from './animated';\nexport * from './replicas';\nexport * from './context';\nexport * from './hooks';\nexport * from './types';\n"],"mappings":";;;;;;AAAA;;AAEA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useAnimatedKeyboardHandler = useAnimatedKeyboardHandler;
|
|
7
|
+
|
|
8
|
+
var _reactNativeReanimated = require("react-native-reanimated");
|
|
9
|
+
|
|
10
|
+
function useAnimatedKeyboardHandler(handlers, dependencies) {
|
|
11
|
+
const {
|
|
12
|
+
context,
|
|
13
|
+
doDependenciesDiffer
|
|
14
|
+
} = (0, _reactNativeReanimated.useHandler)(handlers, dependencies);
|
|
15
|
+
return (0, _reactNativeReanimated.useEvent)(event => {
|
|
16
|
+
'worklet';
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
onKeyboardMove
|
|
20
|
+
} = handlers;
|
|
21
|
+
|
|
22
|
+
if (onKeyboardMove && event.eventName.endsWith('onKeyboardMove')) {
|
|
23
|
+
onKeyboardMove(event, context);
|
|
24
|
+
}
|
|
25
|
+
}, ['onKeyboardMove'], doDependenciesDiffer);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useAnimatedKeyboardHandler","handlers","dependencies","context","doDependenciesDiffer","useHandler","useEvent","event","onKeyboardMove","eventName","endsWith"],"sources":["internal.ts"],"sourcesContent":["import { useEvent, useHandler } from 'react-native-reanimated';\n\nimport type { EventWithName, NativeEvent } from './types';\n\nexport function useAnimatedKeyboardHandler<\n TContext extends Record<string, unknown>\n>(\n handlers: {\n onKeyboardMove?: (e: NativeEvent, context: TContext) => void;\n },\n dependencies?: ReadonlyArray<unknown>\n) {\n const { context, doDependenciesDiffer } = useHandler(handlers, dependencies);\n\n return useEvent(\n (event: EventWithName<NativeEvent>) => {\n 'worklet';\n const { onKeyboardMove } = handlers;\n\n if (onKeyboardMove && event.eventName.endsWith('onKeyboardMove')) {\n onKeyboardMove(event, context);\n }\n },\n ['onKeyboardMove'],\n doDependenciesDiffer\n );\n}\n"],"mappings":";;;;;;;AAAA;;AAIO,SAASA,0BAAT,CAGLC,QAHK,EAMLC,YANK,EAOL;EACA,MAAM;IAAEC,OAAF;IAAWC;EAAX,IAAoC,IAAAC,iCAAA,EAAWJ,QAAX,EAAqBC,YAArB,CAA1C;EAEA,OAAO,IAAAI,+BAAA,EACJC,KAAD,IAAuC;IACrC;;IACA,MAAM;MAAEC;IAAF,IAAqBP,QAA3B;;IAEA,IAAIO,cAAc,IAAID,KAAK,CAACE,SAAN,CAAgBC,QAAhB,CAAyB,gBAAzB,CAAtB,EAAkE;MAChEF,cAAc,CAACD,KAAD,EAAQJ,OAAR,CAAd;IACD;EACF,CARI,EASL,CAAC,gBAAD,CATK,EAULC,oBAVK,CAAP;AAYD"}
|
|
@@ -4,18 +4,18 @@ var _reactNative = require("react-native");
|
|
|
4
4
|
|
|
5
5
|
var NativeAndroidManager = _interopRequireWildcard(require("react-native/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid"));
|
|
6
6
|
|
|
7
|
-
var _architecture = require("./architecture");
|
|
8
|
-
|
|
9
7
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
10
8
|
|
|
11
9
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
12
10
|
|
|
13
11
|
// @ts-expect-error because there is no corresponding type definition
|
|
14
12
|
const getConstants = NativeAndroidManager.default.getConstants;
|
|
15
|
-
|
|
13
|
+
|
|
14
|
+
const RCTStatusBarManagerCompat = require('./specs/NativeStatusBarManagerCompat').default; // On Android < 11 RN uses legacy API which breaks EdgeToEdge mode in RN, so
|
|
16
15
|
// in order to use library on all available platforms we have to monkey patch
|
|
17
16
|
// default RN implementation and use modern `WindowInsetsControllerCompat`.
|
|
18
17
|
|
|
18
|
+
|
|
19
19
|
if (_reactNative.Platform.OS === 'android') {
|
|
20
20
|
NativeAndroidManager.default = {
|
|
21
21
|
getConstants,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getConstants","NativeAndroidManager","default","RCTStatusBarManagerCompat","
|
|
1
|
+
{"version":3,"names":["getConstants","NativeAndroidManager","default","RCTStatusBarManagerCompat","require","Platform","OS","setColor","color","animated","setTranslucent","translucent","setStyle","statusBarStyle","setHidden","hidden"],"sources":["monkey-patch.ts"],"sourcesContent":["import { Platform } from 'react-native';\n// @ts-expect-error because there is no corresponding type definition\nimport * as NativeAndroidManager from 'react-native/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid';\n\nconst getConstants = NativeAndroidManager.default.getConstants;\n\nconst RCTStatusBarManagerCompat =\n require('./specs/NativeStatusBarManagerCompat').default;\n\n// On Android < 11 RN uses legacy API which breaks EdgeToEdge mode in RN, so\n// in order to use library on all available platforms we have to monkey patch\n// default RN implementation and use modern `WindowInsetsControllerCompat`.\nif (Platform.OS === 'android') {\n NativeAndroidManager.default = {\n getConstants,\n setColor(color: number, animated: boolean): void {\n RCTStatusBarManagerCompat.setColor(color, animated);\n },\n\n setTranslucent(translucent: boolean): void {\n RCTStatusBarManagerCompat.setTranslucent(translucent);\n },\n\n /**\n * - statusBarStyles can be:\n * - 'default'\n * - 'dark-content'\n */\n setStyle(statusBarStyle?: string): void {\n RCTStatusBarManagerCompat.setStyle(statusBarStyle);\n },\n\n setHidden(hidden: boolean): void {\n RCTStatusBarManagerCompat.setHidden(hidden);\n },\n };\n}\n"],"mappings":";;AAAA;;AAEA;;;;;;AADA;AAGA,MAAMA,YAAY,GAAGC,oBAAoB,CAACC,OAArB,CAA6BF,YAAlD;;AAEA,MAAMG,yBAAyB,GAC7BC,OAAO,CAAC,sCAAD,CAAP,CAAgDF,OADlD,C,CAGA;AACA;AACA;;;AACA,IAAIG,qBAAA,CAASC,EAAT,KAAgB,SAApB,EAA+B;EAC7BL,oBAAoB,CAACC,OAArB,GAA+B;IAC7BF,YAD6B;;IAE7BO,QAAQ,CAACC,KAAD,EAAgBC,QAAhB,EAAyC;MAC/CN,yBAAyB,CAACI,QAA1B,CAAmCC,KAAnC,EAA0CC,QAA1C;IACD,CAJ4B;;IAM7BC,cAAc,CAACC,WAAD,EAA6B;MACzCR,yBAAyB,CAACO,cAA1B,CAAyCC,WAAzC;IACD,CAR4B;;IAU7B;AACJ;AACA;AACA;AACA;IACIC,QAAQ,CAACC,cAAD,EAAgC;MACtCV,yBAAyB,CAACS,QAA1B,CAAmCC,cAAnC;IACD,CAjB4B;;IAmB7BC,SAAS,CAACC,MAAD,EAAwB;MAC/BZ,yBAAyB,CAACW,SAA1B,CAAoCC,MAApC;IACD;;EArB4B,CAA/B;AAuBD"}
|
package/lib/commonjs/native.js
CHANGED
|
@@ -3,18 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
8
|
-
var _react = require("react");
|
|
6
|
+
exports.KeyboardEvents = exports.KeyboardControllerView = exports.KeyboardController = exports.AndroidSoftInputModes = void 0;
|
|
9
7
|
|
|
10
8
|
var _reactNative = require("react-native");
|
|
11
9
|
|
|
12
|
-
var _architecture = require("./architecture");
|
|
13
|
-
|
|
14
10
|
const LINKING_ERROR = `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
15
11
|
ios: "- You have run 'pod install'\n",
|
|
16
12
|
default: ''
|
|
17
|
-
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo
|
|
13
|
+
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n'; // copied from `android.view.WindowManager.LayoutParams`
|
|
14
|
+
|
|
18
15
|
let AndroidSoftInputModes;
|
|
19
16
|
exports.AndroidSoftInputModes = AndroidSoftInputModes;
|
|
20
17
|
|
|
@@ -23,28 +20,34 @@ exports.AndroidSoftInputModes = AndroidSoftInputModes;
|
|
|
23
20
|
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_ADJUST_PAN"] = 32] = "SOFT_INPUT_ADJUST_PAN";
|
|
24
21
|
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_ADJUST_RESIZE"] = 16] = "SOFT_INPUT_ADJUST_RESIZE";
|
|
25
22
|
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_ADJUST_UNSPECIFIED"] = 0] = "SOFT_INPUT_ADJUST_UNSPECIFIED";
|
|
23
|
+
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_IS_FORWARD_NAVIGATION"] = 256] = "SOFT_INPUT_IS_FORWARD_NAVIGATION";
|
|
24
|
+
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_MASK_ADJUST"] = 240] = "SOFT_INPUT_MASK_ADJUST";
|
|
25
|
+
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_MASK_STATE"] = 15] = "SOFT_INPUT_MASK_STATE";
|
|
26
|
+
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_MODE_CHANGED"] = 512] = "SOFT_INPUT_MODE_CHANGED";
|
|
27
|
+
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_ALWAYS_HIDDEN"] = 3] = "SOFT_INPUT_STATE_ALWAYS_HIDDEN";
|
|
28
|
+
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_ALWAYS_VISIBLE"] = 5] = "SOFT_INPUT_STATE_ALWAYS_VISIBLE";
|
|
29
|
+
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_HIDDEN"] = 2] = "SOFT_INPUT_STATE_HIDDEN";
|
|
30
|
+
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_UNCHANGED"] = 1] = "SOFT_INPUT_STATE_UNCHANGED";
|
|
31
|
+
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_UNSPECIFIED"] = 0] = "SOFT_INPUT_STATE_UNSPECIFIED";
|
|
32
|
+
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_VISIBLE"] = 4] = "SOFT_INPUT_STATE_VISIBLE";
|
|
26
33
|
})(AndroidSoftInputModes || (exports.AndroidSoftInputModes = AndroidSoftInputModes = {}));
|
|
27
34
|
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
const KeyboardController = RCTKeyboardController
|
|
35
|
+
const RCTKeyboardController = require('./specs/NativeKeyboardController').default;
|
|
36
|
+
|
|
37
|
+
const KeyboardController = RCTKeyboardController ? RCTKeyboardController : new Proxy({}, {
|
|
38
|
+
get() {
|
|
39
|
+
throw new Error(LINKING_ERROR);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
});
|
|
31
43
|
exports.KeyboardController = KeyboardController;
|
|
32
|
-
const eventEmitter = new _reactNative.NativeEventEmitter(
|
|
44
|
+
const eventEmitter = new _reactNative.NativeEventEmitter(KeyboardController);
|
|
33
45
|
const KeyboardEvents = {
|
|
34
46
|
addListener: (name, cb) => eventEmitter.addListener('KeyboardController::' + name, cb)
|
|
35
47
|
};
|
|
36
48
|
exports.KeyboardEvents = KeyboardEvents;
|
|
37
|
-
const KeyboardControllerView = _architecture.isFabricEnabled ? require('./KeyboardControllerViewNativeComponent').default : _reactNative.UIManager.getViewManagerConfig(ComponentName) != null ? (0, _reactNative.requireNativeComponent)(ComponentName) : () => {
|
|
38
|
-
throw new Error(LINKING_ERROR);
|
|
39
|
-
};
|
|
40
|
-
exports.KeyboardControllerView = KeyboardControllerView;
|
|
41
49
|
|
|
42
|
-
const
|
|
43
|
-
(0, _react.useEffect)(() => {
|
|
44
|
-
KeyboardController.setInputMode(AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE);
|
|
45
|
-
return () => KeyboardController.setDefaultMode();
|
|
46
|
-
}, []);
|
|
47
|
-
};
|
|
50
|
+
const KeyboardControllerView = require('./specs/KeyboardControllerViewNativeComponent').default;
|
|
48
51
|
|
|
49
|
-
exports.
|
|
52
|
+
exports.KeyboardControllerView = KeyboardControllerView;
|
|
50
53
|
//# sourceMappingURL=native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["LINKING_ERROR","Platform","select","ios","default","AndroidSoftInputModes","
|
|
1
|
+
{"version":3,"names":["LINKING_ERROR","Platform","select","ios","default","AndroidSoftInputModes","RCTKeyboardController","require","KeyboardController","Proxy","get","Error","eventEmitter","NativeEventEmitter","KeyboardEvents","addListener","name","cb","KeyboardControllerView"],"sources":["native.ts"],"sourcesContent":["import { Platform, NativeEventEmitter } from 'react-native';\n\nimport type {\n KeyboardControllerEvents,\n KeyboardControllerModule,\n KeyboardEventData,\n} from './types';\n\nconst LINKING_ERROR =\n `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo Go\\n';\n\n// copied from `android.view.WindowManager.LayoutParams`\nexport enum AndroidSoftInputModes {\n SOFT_INPUT_ADJUST_NOTHING = 48,\n SOFT_INPUT_ADJUST_PAN = 32,\n SOFT_INPUT_ADJUST_RESIZE = 16,\n SOFT_INPUT_ADJUST_UNSPECIFIED = 0,\n SOFT_INPUT_IS_FORWARD_NAVIGATION = 256,\n SOFT_INPUT_MASK_ADJUST = 240,\n SOFT_INPUT_MASK_STATE = 15,\n SOFT_INPUT_MODE_CHANGED = 512,\n SOFT_INPUT_STATE_ALWAYS_HIDDEN = 3,\n SOFT_INPUT_STATE_ALWAYS_VISIBLE = 5,\n SOFT_INPUT_STATE_HIDDEN = 2,\n SOFT_INPUT_STATE_UNCHANGED = 1,\n SOFT_INPUT_STATE_UNSPECIFIED = 0,\n SOFT_INPUT_STATE_VISIBLE = 4,\n}\n\nconst RCTKeyboardController =\n require('./specs/NativeKeyboardController').default;\nexport const KeyboardController = (\n RCTKeyboardController\n ? RCTKeyboardController\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n )\n) as KeyboardControllerModule;\n\nconst eventEmitter = new NativeEventEmitter(KeyboardController);\n\nexport const KeyboardEvents = {\n addListener: (\n name: KeyboardControllerEvents,\n cb: (e: KeyboardEventData) => void\n ) => eventEmitter.addListener('KeyboardController::' + name, cb),\n};\nexport const KeyboardControllerView =\n require('./specs/KeyboardControllerViewNativeComponent').default;\n"],"mappings":";;;;;;;AAAA;;AAQA,MAAMA,aAAa,GAChB,2FAAD,GACAC,qBAAA,CAASC,MAAT,CAAgB;EAAEC,GAAG,EAAE,gCAAP;EAAyCC,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,+BAJF,C,CAMA;;IACYC,qB;;;WAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;GAAAA,qB,qCAAAA,qB;;AAiBZ,MAAMC,qBAAqB,GACzBC,OAAO,CAAC,kCAAD,CAAP,CAA4CH,OAD9C;;AAEO,MAAMI,kBAAkB,GAC7BF,qBAAqB,GACjBA,qBADiB,GAEjB,IAAIG,KAAJ,CACE,EADF,EAEE;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAJ,CAAUX,aAAV,CAAN;EACD;;AAHH,CAFF,CAHC;;AAaP,MAAMY,YAAY,GAAG,IAAIC,+BAAJ,CAAuBL,kBAAvB,CAArB;AAEO,MAAMM,cAAc,GAAG;EAC5BC,WAAW,EAAE,CACXC,IADW,EAEXC,EAFW,KAGRL,YAAY,CAACG,WAAb,CAAyB,yBAAyBC,IAAlD,EAAwDC,EAAxD;AAJuB,CAAvB;;;AAMA,MAAMC,sBAAsB,GACjCX,OAAO,CAAC,+CAAD,CAAP,CAAyDH,OADpD"}
|