react-native-keyboard-controller 1.16.7 → 1.17.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/README.md +2 -8
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/OverKeyboardViewManager.kt +11 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/overlay/OverKeyboardViewGroup.kt +17 -0
- package/android/src/main/jni/CMakeLists.txt +85 -0
- package/android/src/main/jni/reactnativekeyboardcontroller.h +23 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardControllerViewComponentDescriptor.h +21 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardControllerViewShadowNode.cpp +7 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardControllerViewShadowNode.h +23 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardControllerViewState.h +21 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardGestureAreaComponentDescriptor.h +20 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardGestureAreaShadowNode.cpp +7 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardGestureAreaShadowNode.h +23 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardGestureAreaState.h +21 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCOverKeyboardViewComponentDescriptor.h +31 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCOverKeyboardViewShadowNode.cpp +7 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCOverKeyboardViewShadowNode.h +23 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCOverKeyboardViewState.cpp +12 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCOverKeyboardViewState.h +43 -0
- package/ios/KeyboardController-Bridging-Header.h +0 -1
- package/ios/objc/{RCTUITextView+DelegateManager.h → UITextView+DelegateManager.h} +2 -4
- package/ios/objc/{RCTUITextView+DelegateManager.m → UITextView+DelegateManager.m} +3 -3
- package/ios/observers/FocusedInputObserver.swift +2 -2
- package/ios/views/KeyboardControllerView.mm +1 -1
- package/ios/views/KeyboardGestureAreaManager.mm +1 -1
- package/ios/views/OverKeyboardViewManager.mm +1 -1
- package/jest/index.js +14 -1
- package/lib/commonjs/components/KeyboardAvoidingView/index.js +2 -2
- package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardStickyView/index.js +12 -12
- package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/index.js +18 -8
- package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -1
- package/lib/commonjs/hooks/index.js +12 -0
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useKeyboardState/index.js +34 -0
- package/lib/commonjs/hooks/useKeyboardState/index.js.map +1 -0
- package/lib/commonjs/module.js +12 -5
- package/lib/commonjs/module.js.map +1 -1
- package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js +3 -1
- package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
- package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js +3 -1
- package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
- package/lib/commonjs/specs/OverKeyboardViewNativeComponent.js +3 -1
- package/lib/commonjs/specs/OverKeyboardViewNativeComponent.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/views/OverKeyboardView/index.js +10 -4
- package/lib/commonjs/views/OverKeyboardView/index.js.map +1 -1
- package/lib/module/components/KeyboardAvoidingView/index.js +2 -2
- package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -1
- package/lib/module/components/KeyboardStickyView/index.js +13 -13
- package/lib/module/components/KeyboardStickyView/index.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/index.js +18 -8
- package/lib/module/components/KeyboardToolbar/index.js.map +1 -1
- package/lib/module/hooks/index.js +1 -0
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useKeyboardState/index.js +27 -0
- package/lib/module/hooks/useKeyboardState/index.js.map +1 -0
- package/lib/module/module.js +12 -5
- package/lib/module/module.js.map +1 -1
- package/lib/module/specs/KeyboardControllerViewNativeComponent.js +3 -1
- package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
- package/lib/module/specs/KeyboardGestureAreaNativeComponent.js +3 -1
- package/lib/module/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
- package/lib/module/specs/OverKeyboardViewNativeComponent.js +3 -1
- package/lib/module/specs/OverKeyboardViewNativeComponent.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/views/OverKeyboardView/index.js +10 -4
- package/lib/module/views/OverKeyboardView/index.js.map +1 -1
- package/lib/typescript/components/KeyboardToolbar/index.d.ts +5 -0
- package/lib/typescript/hooks/index.d.ts +1 -0
- package/lib/typescript/hooks/useKeyboardState/index.d.ts +2 -0
- package/lib/typescript/types.d.ts +4 -1
- package/package.json +4 -1
- package/react-native-keyboard-controller.podspec +8 -0
- package/react-native.config.js +14 -0
- package/src/components/KeyboardAvoidingView/index.tsx +14 -7
- package/src/components/KeyboardStickyView/index.tsx +18 -17
- package/src/components/KeyboardToolbar/index.tsx +36 -19
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useKeyboardState/index.ts +38 -0
- package/src/module.ts +12 -5
- package/src/specs/KeyboardControllerViewNativeComponent.ts +3 -3
- package/src/specs/KeyboardGestureAreaNativeComponent.ts +3 -3
- package/src/specs/OverKeyboardViewNativeComponent.ts +3 -3
- package/src/types.ts +4 -1
- package/src/views/OverKeyboardView/index.tsx +11 -4
- package/lib/commonjs/architecture.js +0 -8
- package/lib/commonjs/architecture.js.map +0 -1
- package/lib/module/architecture.js +0 -2
- package/lib/module/architecture.js.map +0 -1
- package/lib/typescript/architecture.d.ts +0 -1
- package/src/architecture.ts +0 -1
package/README.md
CHANGED
|
@@ -22,17 +22,11 @@ Keyboard manager which works in identical way on both iOS and Android.
|
|
|
22
22
|
|
|
23
23
|
## Installation
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
```shell
|
|
28
|
-
yarn add react-native-keyboard-controller
|
|
29
|
-
# or
|
|
30
|
-
npm install react-native-keyboard-controller --save
|
|
31
|
-
```
|
|
25
|
+
Check out the [installation](https://kirillzyusko.github.io/react-native-keyboard-controller/docs/installation) section of docs for the detailed installation instructions.
|
|
32
26
|
|
|
33
27
|
## Documentation
|
|
34
28
|
|
|
35
|
-
Check out
|
|
29
|
+
Check out the dedicated documentation page for information about this library, API reference and more: [https://kirillzyusko.github.io/react-native-keyboard-controller/](https://kirillzyusko.github.io/react-native-keyboard-controller/)
|
|
36
30
|
|
|
37
31
|
## Contributing
|
|
38
32
|
|
package/android/src/fabric/java/com/reactnativekeyboardcontroller/OverKeyboardViewManager.kt
CHANGED
|
@@ -2,6 +2,8 @@ package com.reactnativekeyboardcontroller
|
|
|
2
2
|
|
|
3
3
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
4
|
import com.facebook.react.uimanager.LayoutShadowNode
|
|
5
|
+
import com.facebook.react.uimanager.ReactStylesDiffMap
|
|
6
|
+
import com.facebook.react.uimanager.StateWrapper
|
|
5
7
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
6
8
|
import com.facebook.react.uimanager.ViewGroupManager
|
|
7
9
|
import com.facebook.react.uimanager.ViewManagerDelegate
|
|
@@ -30,6 +32,15 @@ class OverKeyboardViewManager(
|
|
|
30
32
|
|
|
31
33
|
override fun getShadowNodeClass(): Class<out LayoutShadowNode> = OverKeyboardHostShadowNode::class.java
|
|
32
34
|
|
|
35
|
+
override fun updateState(
|
|
36
|
+
view: OverKeyboardHostView,
|
|
37
|
+
props: ReactStylesDiffMap,
|
|
38
|
+
stateWrapper: StateWrapper,
|
|
39
|
+
): Any? {
|
|
40
|
+
view.stateWrapper = stateWrapper
|
|
41
|
+
return null
|
|
42
|
+
}
|
|
43
|
+
|
|
33
44
|
@ReactProp(name = "visible")
|
|
34
45
|
override fun setVisible(
|
|
35
46
|
view: OverKeyboardHostView,
|
|
@@ -7,12 +7,17 @@ import android.view.MotionEvent
|
|
|
7
7
|
import android.view.View
|
|
8
8
|
import android.view.WindowManager
|
|
9
9
|
import com.facebook.react.bridge.UiThreadUtil
|
|
10
|
+
import com.facebook.react.bridge.WritableMap
|
|
11
|
+
import com.facebook.react.bridge.WritableNativeMap
|
|
10
12
|
import com.facebook.react.config.ReactFeatureFlags
|
|
11
13
|
import com.facebook.react.uimanager.JSTouchDispatcher
|
|
14
|
+
import com.facebook.react.uimanager.StateWrapper
|
|
12
15
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
13
16
|
import com.facebook.react.uimanager.UIManagerHelper
|
|
14
17
|
import com.facebook.react.uimanager.events.EventDispatcher
|
|
15
18
|
import com.facebook.react.views.view.ReactViewGroup
|
|
19
|
+
import com.reactnativekeyboardcontroller.extensions.dp
|
|
20
|
+
import com.reactnativekeyboardcontroller.extensions.getDisplaySize
|
|
16
21
|
|
|
17
22
|
@SuppressLint("ViewConstructor")
|
|
18
23
|
class OverKeyboardHostView(
|
|
@@ -22,6 +27,8 @@ class OverKeyboardHostView(
|
|
|
22
27
|
private var windowManager: WindowManager = reactContext.getSystemService(Context.WINDOW_SERVICE) as WindowManager
|
|
23
28
|
private var hostView: OverKeyboardRootViewGroup = OverKeyboardRootViewGroup(reactContext)
|
|
24
29
|
|
|
30
|
+
internal var stateWrapper: StateWrapper? = null
|
|
31
|
+
|
|
25
32
|
init {
|
|
26
33
|
hostView.eventDispatcher = dispatcher
|
|
27
34
|
}
|
|
@@ -82,14 +89,24 @@ class OverKeyboardHostView(
|
|
|
82
89
|
PixelFormat.TRANSLUCENT,
|
|
83
90
|
)
|
|
84
91
|
|
|
92
|
+
stretchTo(fullScreen = true)
|
|
85
93
|
windowManager.addView(hostView, layoutParams)
|
|
86
94
|
}
|
|
87
95
|
|
|
88
96
|
fun hide() {
|
|
89
97
|
if (hostView.isAttached) {
|
|
90
98
|
windowManager.removeView(hostView)
|
|
99
|
+
stretchTo(fullScreen = false)
|
|
91
100
|
}
|
|
92
101
|
}
|
|
102
|
+
|
|
103
|
+
private fun stretchTo(fullScreen: Boolean) {
|
|
104
|
+
val displaySize = reactContext.getDisplaySize()
|
|
105
|
+
val newStateData: WritableMap = WritableNativeMap()
|
|
106
|
+
newStateData.putDouble("screenWidth", if (fullScreen) displaySize.x.toFloat().dp else 0.0)
|
|
107
|
+
newStateData.putDouble("screenHeight", if (fullScreen) displaySize.y.toFloat().dp else 0.0)
|
|
108
|
+
stateWrapper?.updateState(newStateData)
|
|
109
|
+
}
|
|
93
110
|
}
|
|
94
111
|
|
|
95
112
|
@SuppressLint("ViewConstructor")
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.13)
|
|
2
|
+
set(CMAKE_VERBOSE_MAKEFILE ON)
|
|
3
|
+
|
|
4
|
+
set(LIB_LITERAL reactnativekeyboardcontroller)
|
|
5
|
+
set(LIB_TARGET_NAME react_codegen_${LIB_LITERAL})
|
|
6
|
+
|
|
7
|
+
set(LIB_ANDROID_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
|
|
8
|
+
set(LIB_COMMON_DIR ${LIB_ANDROID_DIR}/../common/cpp)
|
|
9
|
+
set(LIB_COMMON_COMPONENTS_DIR ${LIB_COMMON_DIR}/react/renderer/components/${LIB_LITERAL})
|
|
10
|
+
set(LIB_ANDROID_GENERATED_JNI_DIR ${LIB_ANDROID_DIR}/build/generated/source/codegen/jni)
|
|
11
|
+
set(LIB_ANDROID_GENERATED_COMPONENTS_DIR ${LIB_ANDROID_GENERATED_JNI_DIR}/react/renderer/components/${LIB_LITERAL})
|
|
12
|
+
|
|
13
|
+
add_compile_options(
|
|
14
|
+
-fexceptions
|
|
15
|
+
-frtti
|
|
16
|
+
-std=c++20
|
|
17
|
+
-Wall
|
|
18
|
+
-Wpedantic
|
|
19
|
+
-Wno-gnu-zero-variadic-macro-arguments
|
|
20
|
+
-Wno-dollar-in-identifier-extension
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
file(GLOB LIB_CUSTOM_SRCS CONFIGURE_DEPENDS *.cpp ${LIB_COMMON_COMPONENTS_DIR}/*.cpp)
|
|
24
|
+
file(GLOB LIB_CODEGEN_SRCS CONFIGURE_DEPENDS ${LIB_ANDROID_GENERATED_JNI_DIR}/*.cpp ${LIB_ANDROID_GENERATED_COMPONENTS_DIR}/*.cpp)
|
|
25
|
+
|
|
26
|
+
add_library(
|
|
27
|
+
${LIB_TARGET_NAME}
|
|
28
|
+
SHARED
|
|
29
|
+
${LIB_CUSTOM_SRCS}
|
|
30
|
+
${LIB_CODEGEN_SRCS}
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
target_include_directories(
|
|
34
|
+
${LIB_TARGET_NAME}
|
|
35
|
+
PUBLIC
|
|
36
|
+
.
|
|
37
|
+
${LIB_COMMON_DIR}
|
|
38
|
+
${LIB_ANDROID_GENERATED_JNI_DIR}
|
|
39
|
+
${LIB_ANDROID_GENERATED_COMPONENTS_DIR}
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
|
|
43
|
+
target_link_libraries(
|
|
44
|
+
${LIB_TARGET_NAME}
|
|
45
|
+
ReactAndroid::reactnative
|
|
46
|
+
ReactAndroid::jsi
|
|
47
|
+
fbjni::fbjni
|
|
48
|
+
)
|
|
49
|
+
else()
|
|
50
|
+
target_link_libraries(
|
|
51
|
+
${LIB_TARGET_NAME}
|
|
52
|
+
fbjni
|
|
53
|
+
folly_runtime
|
|
54
|
+
glog
|
|
55
|
+
jsi
|
|
56
|
+
react_codegen_rncore
|
|
57
|
+
react_debug
|
|
58
|
+
react_nativemodule_core
|
|
59
|
+
react_render_core
|
|
60
|
+
react_render_debug
|
|
61
|
+
react_render_graphics
|
|
62
|
+
react_render_mapbuffer
|
|
63
|
+
react_render_componentregistry
|
|
64
|
+
react_utils
|
|
65
|
+
rrc_view
|
|
66
|
+
turbomodulejsijni
|
|
67
|
+
yoga
|
|
68
|
+
)
|
|
69
|
+
endif()
|
|
70
|
+
|
|
71
|
+
target_compile_options(
|
|
72
|
+
${LIB_TARGET_NAME}
|
|
73
|
+
PRIVATE
|
|
74
|
+
-DLOG_TAG=\"ReactNative\"
|
|
75
|
+
-fexceptions
|
|
76
|
+
-frtti
|
|
77
|
+
-std=c++20
|
|
78
|
+
-Wall
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
target_include_directories(
|
|
82
|
+
${CMAKE_PROJECT_NAME}
|
|
83
|
+
PUBLIC
|
|
84
|
+
${CMAKE_CURRENT_SOURCE_DIR}
|
|
85
|
+
)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <ReactCommon/JavaTurboModule.h>
|
|
4
|
+
#include <ReactCommon/TurboModule.h>
|
|
5
|
+
#include <jsi/jsi.h>
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Note this import and that it is not present in autogenerated header file
|
|
9
|
+
* under android/build/generated/source/codegen/jni/reactnativekeyboardcontroller.h
|
|
10
|
+
*
|
|
11
|
+
* Here we are overriding autogenerated component descriptors by prioritizing our custom headers via include path setup.
|
|
12
|
+
*/
|
|
13
|
+
#include <react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardControllerViewComponentDescriptor.h>
|
|
14
|
+
#include <react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardGestureAreaComponentDescriptor.h>
|
|
15
|
+
#include <react/renderer/components/reactnativekeyboardcontroller/RNKCOverKeyboardViewComponentDescriptor.h>
|
|
16
|
+
|
|
17
|
+
#include <memory>
|
|
18
|
+
#include <string>
|
|
19
|
+
|
|
20
|
+
namespace facebook::react {
|
|
21
|
+
JSI_EXPORT
|
|
22
|
+
std::shared_ptr<TurboModule> reactnativekeyboardcontroller_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms);
|
|
23
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "RNKCKeyboardControllerViewShadowNode.h"
|
|
4
|
+
|
|
5
|
+
#include <react/debug/react_native_assert.h>
|
|
6
|
+
#include <react/renderer/components/reactnativekeyboardcontroller/Props.h>
|
|
7
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
8
|
+
|
|
9
|
+
namespace facebook::react {
|
|
10
|
+
|
|
11
|
+
class KeyboardControllerViewComponentDescriptor final
|
|
12
|
+
: public ConcreteComponentDescriptor<KeyboardControllerViewShadowNode> {
|
|
13
|
+
public:
|
|
14
|
+
using ConcreteComponentDescriptor::ConcreteComponentDescriptor;
|
|
15
|
+
void adopt(ShadowNode &shadowNode) const override {
|
|
16
|
+
react_native_assert(dynamic_cast<KeyboardControllerViewShadowNode *>(&shadowNode));
|
|
17
|
+
ConcreteComponentDescriptor::adopt(shadowNode);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "RNKCKeyboardControllerViewState.h"
|
|
4
|
+
|
|
5
|
+
#include <react/renderer/components/reactnativekeyboardcontroller/EventEmitters.h>
|
|
6
|
+
#include <react/renderer/components/reactnativekeyboardcontroller/Props.h>
|
|
7
|
+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
8
|
+
#include <jsi/jsi.h>
|
|
9
|
+
|
|
10
|
+
namespace facebook::react {
|
|
11
|
+
|
|
12
|
+
JSI_EXPORT extern const char KeyboardControllerViewComponentName[];
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* `ShadowNode` for <KeyboardControllerView> component.
|
|
16
|
+
*/
|
|
17
|
+
using KeyboardControllerViewShadowNode = ConcreteViewShadowNode<
|
|
18
|
+
KeyboardControllerViewComponentName,
|
|
19
|
+
KeyboardControllerViewProps,
|
|
20
|
+
KeyboardControllerViewEventEmitter,
|
|
21
|
+
KeyboardControllerViewState>;
|
|
22
|
+
|
|
23
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#ifdef ANDROID
|
|
4
|
+
#include <folly/dynamic.h>
|
|
5
|
+
#endif
|
|
6
|
+
|
|
7
|
+
namespace facebook::react {
|
|
8
|
+
|
|
9
|
+
class KeyboardControllerViewState {
|
|
10
|
+
public:
|
|
11
|
+
KeyboardControllerViewState() = default;
|
|
12
|
+
|
|
13
|
+
#ifdef ANDROID
|
|
14
|
+
KeyboardControllerViewState(KeyboardControllerViewState const &previousState, folly::dynamic data) {}
|
|
15
|
+
folly::dynamic getDynamic() const {
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
#endif
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "RNKCKeyboardGestureAreaShadowNode.h"
|
|
4
|
+
|
|
5
|
+
#include <react/debug/react_native_assert.h>
|
|
6
|
+
#include <react/renderer/components/reactnativekeyboardcontroller/Props.h>
|
|
7
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
8
|
+
|
|
9
|
+
namespace facebook::react {
|
|
10
|
+
class KeyboardGestureAreaComponentDescriptor final
|
|
11
|
+
: public ConcreteComponentDescriptor<KeyboardGestureAreaShadowNode> {
|
|
12
|
+
public:
|
|
13
|
+
using ConcreteComponentDescriptor::ConcreteComponentDescriptor;
|
|
14
|
+
void adopt(ShadowNode &shadowNode) const override {
|
|
15
|
+
react_native_assert(dynamic_cast<KeyboardGestureAreaShadowNode *>(&shadowNode));
|
|
16
|
+
ConcreteComponentDescriptor::adopt(shadowNode);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "RNKCKeyboardGestureAreaState.h"
|
|
4
|
+
|
|
5
|
+
#include <react/renderer/components/reactnativekeyboardcontroller/EventEmitters.h>
|
|
6
|
+
#include <react/renderer/components/reactnativekeyboardcontroller/Props.h>
|
|
7
|
+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
8
|
+
#include <jsi/jsi.h>
|
|
9
|
+
|
|
10
|
+
namespace facebook::react {
|
|
11
|
+
|
|
12
|
+
JSI_EXPORT extern const char KeyboardGestureAreaComponentName[];
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* `ShadowNode` for <KeyboardGestureArea> component.
|
|
16
|
+
*/
|
|
17
|
+
using KeyboardGestureAreaShadowNode = ConcreteViewShadowNode<
|
|
18
|
+
KeyboardGestureAreaComponentName,
|
|
19
|
+
KeyboardGestureAreaProps,
|
|
20
|
+
KeyboardGestureAreaEventEmitter,
|
|
21
|
+
KeyboardGestureAreaState>;
|
|
22
|
+
|
|
23
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#ifdef ANDROID
|
|
4
|
+
#include <folly/dynamic.h>
|
|
5
|
+
#endif
|
|
6
|
+
|
|
7
|
+
namespace facebook::react {
|
|
8
|
+
|
|
9
|
+
class KeyboardGestureAreaState {
|
|
10
|
+
public:
|
|
11
|
+
KeyboardGestureAreaState() = default;
|
|
12
|
+
|
|
13
|
+
#ifdef ANDROID
|
|
14
|
+
KeyboardGestureAreaState(KeyboardGestureAreaState const &previousState, folly::dynamic data) {}
|
|
15
|
+
folly::dynamic getDynamic() const {
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
#endif
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "RNKCOverKeyboardViewShadowNode.h"
|
|
4
|
+
|
|
5
|
+
#include <react/debug/react_native_assert.h>
|
|
6
|
+
#include <react/renderer/components/reactnativekeyboardcontroller/Props.h>
|
|
7
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
8
|
+
|
|
9
|
+
namespace facebook::react {
|
|
10
|
+
|
|
11
|
+
class OverKeyboardViewComponentDescriptor final
|
|
12
|
+
: public ConcreteComponentDescriptor<OverKeyboardViewShadowNode> {
|
|
13
|
+
public:
|
|
14
|
+
using ConcreteComponentDescriptor::ConcreteComponentDescriptor;
|
|
15
|
+
void adopt(ShadowNode &shadowNode) const override {
|
|
16
|
+
auto& layoutableShadowNode =
|
|
17
|
+
static_cast<YogaLayoutableShadowNode&>(shadowNode);
|
|
18
|
+
auto& stateData =
|
|
19
|
+
static_cast<const OverKeyboardViewShadowNode::ConcreteState&>(
|
|
20
|
+
*shadowNode.getState())
|
|
21
|
+
.getData();
|
|
22
|
+
|
|
23
|
+
layoutableShadowNode.setSize(
|
|
24
|
+
Size{stateData.screenSize.width, stateData.screenSize.height});
|
|
25
|
+
layoutableShadowNode.setPositionType(YGPositionTypeAbsolute);
|
|
26
|
+
|
|
27
|
+
ConcreteComponentDescriptor::adopt(shadowNode);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "RNKCOverKeyboardViewState.h"
|
|
4
|
+
|
|
5
|
+
#include <react/renderer/components/reactnativekeyboardcontroller/EventEmitters.h>
|
|
6
|
+
#include <react/renderer/components/reactnativekeyboardcontroller/Props.h>
|
|
7
|
+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
8
|
+
#include <jsi/jsi.h>
|
|
9
|
+
|
|
10
|
+
namespace facebook::react {
|
|
11
|
+
|
|
12
|
+
JSI_EXPORT extern const char OverKeyboardViewComponentName[];
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* `ShadowNode` for <OverKeyboardView> component.
|
|
16
|
+
*/
|
|
17
|
+
using OverKeyboardViewShadowNode = ConcreteViewShadowNode<
|
|
18
|
+
OverKeyboardViewComponentName,
|
|
19
|
+
OverKeyboardViewProps,
|
|
20
|
+
OverKeyboardViewEventEmitter,
|
|
21
|
+
OverKeyboardViewState>;
|
|
22
|
+
|
|
23
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#include "RNKCOverKeyboardViewState.h"
|
|
2
|
+
|
|
3
|
+
namespace facebook::react {
|
|
4
|
+
|
|
5
|
+
#ifdef ANDROID
|
|
6
|
+
folly::dynamic OverKeyboardViewState::getDynamic() const {
|
|
7
|
+
return folly::dynamic::object("screenWidth", screenSize.width)(
|
|
8
|
+
"screenHeight", screenSize.height);
|
|
9
|
+
}
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <react/renderer/core/graphicsConversions.h>
|
|
4
|
+
#include <react/renderer/graphics/Float.h>
|
|
5
|
+
|
|
6
|
+
#ifdef ANDROID
|
|
7
|
+
#include <folly/dynamic.h>
|
|
8
|
+
#endif
|
|
9
|
+
|
|
10
|
+
#include <memory>
|
|
11
|
+
|
|
12
|
+
namespace facebook::react {
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* State for <OverKeyboardViewState> component.
|
|
16
|
+
*/
|
|
17
|
+
class OverKeyboardViewState final {
|
|
18
|
+
public:
|
|
19
|
+
using Shared = std::shared_ptr<const OverKeyboardViewState>;
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
OverKeyboardViewState() {}
|
|
23
|
+
OverKeyboardViewState(Size screenSize_) : screenSize(screenSize_) {}
|
|
24
|
+
|
|
25
|
+
#ifdef ANDROID
|
|
26
|
+
OverKeyboardViewState(
|
|
27
|
+
const OverKeyboardViewState& previousState,
|
|
28
|
+
folly::dynamic data)
|
|
29
|
+
: screenSize(Size{
|
|
30
|
+
(Float)data["screenWidth"].getDouble(),
|
|
31
|
+
(Float)data["screenHeight"].getDouble()}) {}
|
|
32
|
+
#endif
|
|
33
|
+
|
|
34
|
+
const Size screenSize{};
|
|
35
|
+
|
|
36
|
+
#ifdef ANDROID
|
|
37
|
+
folly::dynamic getDynamic() const;
|
|
38
|
+
#endif
|
|
39
|
+
|
|
40
|
+
#pragma mark - Getters
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
} // namespace facebook::react
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
//
|
|
2
|
-
//
|
|
2
|
+
// UITextView+DelegateManager.h
|
|
3
3
|
// react-native-keyboard-controller
|
|
4
4
|
//
|
|
5
5
|
// Created by Kiryl Ziusko on 24/04/2024.
|
|
6
6
|
//
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
@interface RCTUITextView (DelegateManager)
|
|
8
|
+
@interface UITextView (DelegateManager)
|
|
11
9
|
|
|
12
10
|
- (void)setForceDelegate:(id<UITextViewDelegate>)delegate;
|
|
13
11
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
//
|
|
2
|
-
//
|
|
2
|
+
// UITextView+DelegateManager.m
|
|
3
3
|
// react-native-keyboard-controller
|
|
4
4
|
//
|
|
5
5
|
// Created by Kiryl Ziusko on 24/04/2024.
|
|
6
6
|
//
|
|
7
7
|
|
|
8
8
|
#import <objc/runtime.h>
|
|
9
|
-
#import "
|
|
9
|
+
#import "UITextView+DelegateManager.h"
|
|
10
10
|
|
|
11
|
-
@implementation
|
|
11
|
+
@implementation UITextView (DelegateManager)
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* We are aware that delegate is set by RN on mount and we can not re-define it
|
|
@@ -235,7 +235,7 @@ public class FocusedInputObserver: NSObject {
|
|
|
235
235
|
} else if let textView = input as? UITextView {
|
|
236
236
|
if !(textView.delegate is KCTextInputCompositeDelegate) {
|
|
237
237
|
delegate.setTextViewDelegate(delegate: textView.delegate)
|
|
238
|
-
|
|
238
|
+
textView.setForceDelegate(delegate)
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
241
|
// dispatch onSelectionChange on focus
|
|
@@ -248,7 +248,7 @@ public class FocusedInputObserver: NSObject {
|
|
|
248
248
|
if let textField = input as? UITextField, let oldDelegate = delegate.activeDelegate as? UITextFieldDelegate {
|
|
249
249
|
textField.delegate = oldDelegate
|
|
250
250
|
} else if let textView = input as? UITextView, let oldDelegate = delegate.activeDelegate as? UITextViewDelegate {
|
|
251
|
-
|
|
251
|
+
textView.setForceDelegate(oldDelegate)
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
#import <react_native_keyboard_controller/react_native_keyboard_controller-Swift.h>
|
|
21
21
|
#endif
|
|
22
22
|
|
|
23
|
-
#import <react/renderer/components/reactnativekeyboardcontroller/ComponentDescriptors.h>
|
|
24
23
|
#import <react/renderer/components/reactnativekeyboardcontroller/EventEmitters.h>
|
|
25
24
|
#import <react/renderer/components/reactnativekeyboardcontroller/Props.h>
|
|
26
25
|
#import <react/renderer/components/reactnativekeyboardcontroller/RCTComponentViewHelpers.h>
|
|
26
|
+
#import <react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardControllerViewComponentDescriptor.h>
|
|
27
27
|
|
|
28
28
|
#import "KeyboardControllerModule-Header.h"
|
|
29
29
|
#import "RCTFabricComponentsPlugins.h"
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
#endif
|
|
15
15
|
|
|
16
16
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
17
|
-
#import <react/renderer/components/reactnativekeyboardcontroller/ComponentDescriptors.h>
|
|
18
17
|
#import <react/renderer/components/reactnativekeyboardcontroller/EventEmitters.h>
|
|
19
18
|
#import <react/renderer/components/reactnativekeyboardcontroller/Props.h>
|
|
20
19
|
#import <react/renderer/components/reactnativekeyboardcontroller/RCTComponentViewHelpers.h>
|
|
20
|
+
#import <react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardGestureAreaComponentDescriptor.h>
|
|
21
21
|
|
|
22
22
|
#import "RCTFabricComponentsPlugins.h"
|
|
23
23
|
#endif
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
17
17
|
#import <React/RCTSurfaceTouchHandler.h>
|
|
18
18
|
|
|
19
|
-
#import <react/renderer/components/reactnativekeyboardcontroller/ComponentDescriptors.h>
|
|
20
19
|
#import <react/renderer/components/reactnativekeyboardcontroller/EventEmitters.h>
|
|
21
20
|
#import <react/renderer/components/reactnativekeyboardcontroller/Props.h>
|
|
22
21
|
#import <react/renderer/components/reactnativekeyboardcontroller/RCTComponentViewHelpers.h>
|
|
22
|
+
#import <react/renderer/components/reactnativekeyboardcontroller/RNKCOverKeyboardViewComponentDescriptor.h>
|
|
23
23
|
|
|
24
24
|
#import "RCTFabricComponentsPlugins.h"
|
|
25
25
|
#endif
|
package/jest/index.js
CHANGED
|
@@ -29,6 +29,18 @@ const focusedInput = {
|
|
|
29
29
|
set: jest.fn(),
|
|
30
30
|
},
|
|
31
31
|
};
|
|
32
|
+
const lastKeyboardEvent = {
|
|
33
|
+
height: 0,
|
|
34
|
+
duration: 0,
|
|
35
|
+
timestamp: 0,
|
|
36
|
+
target: 0,
|
|
37
|
+
type: "default",
|
|
38
|
+
appearance: "default",
|
|
39
|
+
};
|
|
40
|
+
const state = {
|
|
41
|
+
...lastKeyboardEvent,
|
|
42
|
+
isVisible: false,
|
|
43
|
+
};
|
|
32
44
|
|
|
33
45
|
const mock = {
|
|
34
46
|
// hooks
|
|
@@ -39,6 +51,7 @@ const mock = {
|
|
|
39
51
|
useGenericKeyboardHandler: jest.fn(),
|
|
40
52
|
useKeyboardHandler: jest.fn(),
|
|
41
53
|
useKeyboardContext: jest.fn().mockReturnValue(values),
|
|
54
|
+
useKeyboardState: jest.fn().mockReturnValue(state),
|
|
42
55
|
/// input
|
|
43
56
|
useReanimatedFocusedInput: jest.fn().mockReturnValue(focusedInput),
|
|
44
57
|
useFocusedInputHandler: jest.fn(),
|
|
@@ -55,7 +68,7 @@ const mock = {
|
|
|
55
68
|
dismiss: jest.fn().mockReturnValue(Promise.resolve()),
|
|
56
69
|
setFocusTo: jest.fn(),
|
|
57
70
|
isVisible: jest.fn().mockReturnValue(false),
|
|
58
|
-
state: jest.fn().mockReturnValue(
|
|
71
|
+
state: jest.fn().mockReturnValue(lastKeyboardEvent),
|
|
59
72
|
},
|
|
60
73
|
AndroidSoftInputModes: {
|
|
61
74
|
SOFT_INPUT_ADJUST_NOTHING: 48,
|
|
@@ -57,11 +57,11 @@ const KeyboardAvoidingView = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
57
57
|
const onLayoutWorklet = (0, _react.useCallback)(layout => {
|
|
58
58
|
"worklet";
|
|
59
59
|
|
|
60
|
-
if (keyboard.isClosed.value || initialFrame.value === null) {
|
|
60
|
+
if (keyboard.isClosed.value || initialFrame.value === null || behavior !== "height") {
|
|
61
61
|
// eslint-disable-next-line react-compiler/react-compiler
|
|
62
62
|
initialFrame.value = layout;
|
|
63
63
|
}
|
|
64
|
-
}, []);
|
|
64
|
+
}, [behavior]);
|
|
65
65
|
const onLayout = (0, _react.useCallback)(e => {
|
|
66
66
|
(0, _reactNativeReanimated.runOnUI)(onLayoutWorklet)(e.nativeEvent.layout);
|
|
67
67
|
onLayoutProps === null || onLayoutProps === void 0 || onLayoutProps(e);
|