@react-native-ohos/react-native-keyboard-controller 1.16.6-rc.1

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.
Files changed (269) hide show
  1. package/LICENSE +21 -0
  2. package/README.OpenSource +11 -0
  3. package/README.md +19 -0
  4. package/harmony/keyboard_controller/BuildProfile.ets +17 -0
  5. package/harmony/keyboard_controller/Index.ets +7 -0
  6. package/harmony/keyboard_controller/ResourceTable.txt +1 -0
  7. package/harmony/keyboard_controller/build-profile.json5 +31 -0
  8. package/harmony/keyboard_controller/consumer-rules.txt +0 -0
  9. package/harmony/keyboard_controller/hvigorfile.ts +6 -0
  10. package/harmony/keyboard_controller/obfuscation-rules.txt +18 -0
  11. package/harmony/keyboard_controller/oh-package.json5 +11 -0
  12. package/harmony/keyboard_controller/src/main/cpp/CMakeLists.txt +7 -0
  13. package/harmony/keyboard_controller/src/main/cpp/EventEmitters.cpp +96 -0
  14. package/harmony/keyboard_controller/src/main/cpp/EventEmitters.h +90 -0
  15. package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewComponentDescriptor.h +73 -0
  16. package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewComponentInstance.cpp +172 -0
  17. package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewComponentInstance.h +76 -0
  18. package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewJSIBinder.h +44 -0
  19. package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentDescriptor.h +58 -0
  20. package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentInstance.cpp +87 -0
  21. package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentInstance.h +62 -0
  22. package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaJSIBinder.h +39 -0
  23. package/harmony/keyboard_controller/src/main/cpp/RNKeyboardController.cpp +25 -0
  24. package/harmony/keyboard_controller/src/main/cpp/RNKeyboardController.h +27 -0
  25. package/harmony/keyboard_controller/src/main/cpp/RNStatusBarManagerCompat.cpp +24 -0
  26. package/harmony/keyboard_controller/src/main/cpp/RNStatusBarManagerCompat.h +28 -0
  27. package/harmony/keyboard_controller/src/main/cpp/keyboardControllerPackage.cpp +43 -0
  28. package/harmony/keyboard_controller/src/main/cpp/keyboardControllerPackage.h +56 -0
  29. package/harmony/keyboard_controller/src/main/ets/Logger.ts +46 -0
  30. package/harmony/keyboard_controller/src/main/ets/RNKeyboardControllerPackage.ts +45 -0
  31. package/harmony/keyboard_controller/src/main/ets/RNKeyboardControllerTurboModule.ts +238 -0
  32. package/harmony/keyboard_controller/src/main/ets/RNStatusBarManagerCompatTurboModule.ts +98 -0
  33. package/harmony/keyboard_controller/src/main/ets/Type.ts +41 -0
  34. package/harmony/keyboard_controller/src/main/module.json5 +11 -0
  35. package/harmony/keyboard_controller/src/main/resources/base/element/string.json +8 -0
  36. package/harmony/keyboard_controller/src/main/resources/en_US/element/string.json +8 -0
  37. package/harmony/keyboard_controller/src/main/resources/zh_CN/element/string.json +8 -0
  38. package/harmony/keyboard_controller/ts.ts +9 -0
  39. package/harmony/keyboard_controller.har +0 -0
  40. package/lib/commonjs/animated.js +176 -0
  41. package/lib/commonjs/animated.js.map +1 -0
  42. package/lib/commonjs/bindings.js +39 -0
  43. package/lib/commonjs/bindings.js.map +1 -0
  44. package/lib/commonjs/bindings.native.js +39 -0
  45. package/lib/commonjs/bindings.native.js.map +1 -0
  46. package/lib/commonjs/components/KeyboardAvoidingView/hooks.js +126 -0
  47. package/lib/commonjs/components/KeyboardAvoidingView/hooks.js.map +1 -0
  48. package/lib/commonjs/components/KeyboardAvoidingView/index.js +120 -0
  49. package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -0
  50. package/lib/commonjs/components/KeyboardAwareScrollView/index.js +262 -0
  51. package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -0
  52. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +110 -0
  53. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -0
  54. package/lib/commonjs/components/KeyboardAwareScrollView/utils.js +37 -0
  55. package/lib/commonjs/components/KeyboardAwareScrollView/utils.js.map +1 -0
  56. package/lib/commonjs/components/KeyboardStickyView/index.js +41 -0
  57. package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -0
  58. package/lib/commonjs/components/KeyboardToolbar/Arrow.js +76 -0
  59. package/lib/commonjs/components/KeyboardToolbar/Arrow.js.map +1 -0
  60. package/lib/commonjs/components/KeyboardToolbar/Button.js +70 -0
  61. package/lib/commonjs/components/KeyboardToolbar/Button.js.map +1 -0
  62. package/lib/commonjs/components/KeyboardToolbar/colors.js +21 -0
  63. package/lib/commonjs/components/KeyboardToolbar/colors.js.map +1 -0
  64. package/lib/commonjs/components/KeyboardToolbar/colors.native.js +40 -0
  65. package/lib/commonjs/components/KeyboardToolbar/colors.native.js.map +1 -0
  66. package/lib/commonjs/components/KeyboardToolbar/index.js +161 -0
  67. package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -0
  68. package/lib/commonjs/components/KeyboardToolbar/types.js +6 -0
  69. package/lib/commonjs/components/KeyboardToolbar/types.js.map +1 -0
  70. package/lib/commonjs/components/hooks/useColorScheme.js +10 -0
  71. package/lib/commonjs/components/hooks/useColorScheme.js.map +1 -0
  72. package/lib/commonjs/components/index.js +42 -0
  73. package/lib/commonjs/components/index.js.map +1 -0
  74. package/lib/commonjs/constants.js +27 -0
  75. package/lib/commonjs/constants.js.map +1 -0
  76. package/lib/commonjs/context.js +45 -0
  77. package/lib/commonjs/context.js.map +1 -0
  78. package/lib/commonjs/hooks/index.js +104 -0
  79. package/lib/commonjs/hooks/index.js.map +1 -0
  80. package/lib/commonjs/hooks/useWindowDimensions/index.android.js +34 -0
  81. package/lib/commonjs/hooks/useWindowDimensions/index.android.js.map +1 -0
  82. package/lib/commonjs/hooks/useWindowDimensions/index.js +13 -0
  83. package/lib/commonjs/hooks/useWindowDimensions/index.js.map +1 -0
  84. package/lib/commonjs/index.js +136 -0
  85. package/lib/commonjs/index.js.map +1 -0
  86. package/lib/commonjs/internal.js +73 -0
  87. package/lib/commonjs/internal.js.map +1 -0
  88. package/lib/commonjs/module.js +47 -0
  89. package/lib/commonjs/module.js.map +1 -0
  90. package/lib/commonjs/monkey-patch.android.js +57 -0
  91. package/lib/commonjs/monkey-patch.android.js.map +1 -0
  92. package/lib/commonjs/monkey-patch.js +11 -0
  93. package/lib/commonjs/monkey-patch.js.map +1 -0
  94. package/lib/commonjs/reanimated.js +12 -0
  95. package/lib/commonjs/reanimated.js.map +1 -0
  96. package/lib/commonjs/reanimated.native.js +88 -0
  97. package/lib/commonjs/reanimated.native.js.map +1 -0
  98. package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js +10 -0
  99. package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -0
  100. package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js +12 -0
  101. package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js.map +1 -0
  102. package/lib/commonjs/specs/NativeKeyboardController.js +9 -0
  103. package/lib/commonjs/specs/NativeKeyboardController.js.map +1 -0
  104. package/lib/commonjs/specs/NativeStatusBarManagerCompat.js +9 -0
  105. package/lib/commonjs/specs/NativeStatusBarManagerCompat.js.map +1 -0
  106. package/lib/commonjs/specs/OverKeyboardViewNativeComponent.js +10 -0
  107. package/lib/commonjs/specs/OverKeyboardViewNativeComponent.js.map +1 -0
  108. package/lib/commonjs/types.js +6 -0
  109. package/lib/commonjs/types.js.map +1 -0
  110. package/lib/commonjs/utils.js +9 -0
  111. package/lib/commonjs/utils.js.map +1 -0
  112. package/lib/commonjs/views/OverKeyboardView/index.js +42 -0
  113. package/lib/commonjs/views/OverKeyboardView/index.js.map +1 -0
  114. package/lib/commonjs/views/index.js +14 -0
  115. package/lib/commonjs/views/index.js.map +1 -0
  116. package/lib/module/animated.js +168 -0
  117. package/lib/module/animated.js.map +1 -0
  118. package/lib/module/bindings.js +33 -0
  119. package/lib/module/bindings.js.map +1 -0
  120. package/lib/module/bindings.native.js +33 -0
  121. package/lib/module/bindings.native.js.map +1 -0
  122. package/lib/module/components/KeyboardAvoidingView/hooks.js +118 -0
  123. package/lib/module/components/KeyboardAvoidingView/hooks.js.map +1 -0
  124. package/lib/module/components/KeyboardAvoidingView/index.js +113 -0
  125. package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -0
  126. package/lib/module/components/KeyboardAwareScrollView/index.js +255 -0
  127. package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -0
  128. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +103 -0
  129. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -0
  130. package/lib/module/components/KeyboardAwareScrollView/utils.js +29 -0
  131. package/lib/module/components/KeyboardAwareScrollView/utils.js.map +1 -0
  132. package/lib/module/components/KeyboardStickyView/index.js +34 -0
  133. package/lib/module/components/KeyboardStickyView/index.js.map +1 -0
  134. package/lib/module/components/KeyboardToolbar/Arrow.js +68 -0
  135. package/lib/module/components/KeyboardToolbar/Arrow.js.map +1 -0
  136. package/lib/module/components/KeyboardToolbar/Button.js +62 -0
  137. package/lib/module/components/KeyboardToolbar/Button.js.map +1 -0
  138. package/lib/module/components/KeyboardToolbar/colors.js +15 -0
  139. package/lib/module/components/KeyboardToolbar/colors.js.map +1 -0
  140. package/lib/module/components/KeyboardToolbar/colors.native.js +34 -0
  141. package/lib/module/components/KeyboardToolbar/colors.native.js.map +1 -0
  142. package/lib/module/components/KeyboardToolbar/index.js +149 -0
  143. package/lib/module/components/KeyboardToolbar/index.js.map +1 -0
  144. package/lib/module/components/KeyboardToolbar/types.js +2 -0
  145. package/lib/module/components/KeyboardToolbar/types.js.map +1 -0
  146. package/lib/module/components/hooks/useColorScheme.js +4 -0
  147. package/lib/module/components/hooks/useColorScheme.js.map +1 -0
  148. package/lib/module/components/index.js +5 -0
  149. package/lib/module/components/index.js.map +1 -0
  150. package/lib/module/constants.js +21 -0
  151. package/lib/module/constants.js.map +1 -0
  152. package/lib/module/context.js +38 -0
  153. package/lib/module/context.js.map +1 -0
  154. package/lib/module/hooks/index.js +68 -0
  155. package/lib/module/hooks/index.js.map +1 -0
  156. package/lib/module/hooks/useWindowDimensions/index.android.js +27 -0
  157. package/lib/module/hooks/useWindowDimensions/index.android.js.map +1 -0
  158. package/lib/module/hooks/useWindowDimensions/index.js +2 -0
  159. package/lib/module/hooks/useWindowDimensions/index.js.map +1 -0
  160. package/lib/module/index.js +12 -0
  161. package/lib/module/index.js.map +1 -0
  162. package/lib/module/internal.js +66 -0
  163. package/lib/module/internal.js.map +1 -0
  164. package/lib/module/module.js +41 -0
  165. package/lib/module/module.js.map +1 -0
  166. package/lib/module/monkey-patch.android.js +47 -0
  167. package/lib/module/monkey-patch.android.js.map +1 -0
  168. package/lib/module/monkey-patch.js +5 -0
  169. package/lib/module/monkey-patch.js.map +1 -0
  170. package/lib/module/reanimated.js +6 -0
  171. package/lib/module/reanimated.js.map +1 -0
  172. package/lib/module/reanimated.native.js +78 -0
  173. package/lib/module/reanimated.native.js.map +1 -0
  174. package/lib/module/specs/KeyboardControllerViewNativeComponent.js +3 -0
  175. package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -0
  176. package/lib/module/specs/KeyboardGestureAreaNativeComponent.js +5 -0
  177. package/lib/module/specs/KeyboardGestureAreaNativeComponent.js.map +1 -0
  178. package/lib/module/specs/NativeKeyboardController.js +3 -0
  179. package/lib/module/specs/NativeKeyboardController.js.map +1 -0
  180. package/lib/module/specs/NativeStatusBarManagerCompat.js +3 -0
  181. package/lib/module/specs/NativeStatusBarManagerCompat.js.map +1 -0
  182. package/lib/module/specs/OverKeyboardViewNativeComponent.js +3 -0
  183. package/lib/module/specs/OverKeyboardViewNativeComponent.js.map +1 -0
  184. package/lib/module/types.js +2 -0
  185. package/lib/module/types.js.map +1 -0
  186. package/lib/module/utils.js +2 -0
  187. package/lib/module/utils.js.map +1 -0
  188. package/lib/module/views/OverKeyboardView/index.js +35 -0
  189. package/lib/module/views/OverKeyboardView/index.js.map +1 -0
  190. package/lib/module/views/index.js +2 -0
  191. package/lib/module/views/index.js.map +1 -0
  192. package/lib/typescript/animated.d.ts +39 -0
  193. package/lib/typescript/bindings.d.ts +12 -0
  194. package/lib/typescript/bindings.native.d.ts +12 -0
  195. package/lib/typescript/components/KeyboardAvoidingView/hooks.d.ts +10 -0
  196. package/lib/typescript/components/KeyboardAvoidingView/index.d.ts +40 -0
  197. package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +29 -0
  198. package/lib/typescript/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.d.ts +6 -0
  199. package/lib/typescript/components/KeyboardAwareScrollView/utils.d.ts +2 -0
  200. package/lib/typescript/components/KeyboardStickyView/index.d.ts +39 -0
  201. package/lib/typescript/components/KeyboardToolbar/Arrow.d.ts +9 -0
  202. package/lib/typescript/components/KeyboardToolbar/Button.d.ts +16 -0
  203. package/lib/typescript/components/KeyboardToolbar/colors.d.ts +2 -0
  204. package/lib/typescript/components/KeyboardToolbar/colors.native.d.ts +2 -0
  205. package/lib/typescript/components/KeyboardToolbar/index.d.ts +52 -0
  206. package/lib/typescript/components/KeyboardToolbar/types.d.ts +18 -0
  207. package/lib/typescript/components/hooks/useColorScheme.d.ts +2 -0
  208. package/lib/typescript/components/index.d.ts +8 -0
  209. package/lib/typescript/constants.d.ts +16 -0
  210. package/lib/typescript/context.d.ts +23 -0
  211. package/lib/typescript/hooks/index.d.ts +17 -0
  212. package/lib/typescript/hooks/useWindowDimensions/index.android.d.ts +2 -0
  213. package/lib/typescript/hooks/useWindowDimensions/index.d.ts +1 -0
  214. package/lib/typescript/index.d.ts +10 -0
  215. package/lib/typescript/internal.d.ts +30 -0
  216. package/lib/typescript/module.d.ts +2 -0
  217. package/lib/typescript/monkey-patch.android.d.ts +2 -0
  218. package/lib/typescript/monkey-patch.d.ts +2 -0
  219. package/lib/typescript/reanimated.d.ts +5 -0
  220. package/lib/typescript/reanimated.native.d.ts +7 -0
  221. package/lib/typescript/specs/KeyboardControllerViewNativeComponent.d.ts +54 -0
  222. package/lib/typescript/specs/KeyboardGestureAreaNativeComponent.d.ts +12 -0
  223. package/lib/typescript/specs/NativeKeyboardController.d.ts +12 -0
  224. package/lib/typescript/specs/NativeStatusBarManagerCompat.d.ts +10 -0
  225. package/lib/typescript/specs/OverKeyboardViewNativeComponent.d.ts +7 -0
  226. package/lib/typescript/types.d.ts +161 -0
  227. package/lib/typescript/utils.d.ts +1 -0
  228. package/lib/typescript/views/OverKeyboardView/index.d.ts +5 -0
  229. package/lib/typescript/views/index.d.ts +1 -0
  230. package/package.json +173 -0
  231. package/react-native-keyboard-controller.podspec +61 -0
  232. package/src/animated.tsx +256 -0
  233. package/src/bindings.native.ts +62 -0
  234. package/src/bindings.ts +42 -0
  235. package/src/components/KeyboardAvoidingView/hooks.ts +123 -0
  236. package/src/components/KeyboardAvoidingView/index.tsx +188 -0
  237. package/src/components/KeyboardAwareScrollView/index.tsx +389 -0
  238. package/src/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.ts +133 -0
  239. package/src/components/KeyboardAwareScrollView/utils.ts +41 -0
  240. package/src/components/KeyboardStickyView/index.tsx +66 -0
  241. package/src/components/KeyboardToolbar/Arrow.tsx +80 -0
  242. package/src/components/KeyboardToolbar/Button.tsx +98 -0
  243. package/src/components/KeyboardToolbar/colors.native.ts +37 -0
  244. package/src/components/KeyboardToolbar/colors.ts +16 -0
  245. package/src/components/KeyboardToolbar/index.tsx +223 -0
  246. package/src/components/KeyboardToolbar/types.ts +40 -0
  247. package/src/components/hooks/useColorScheme.ts +5 -0
  248. package/src/components/index.ts +11 -0
  249. package/src/constants.ts +19 -0
  250. package/src/context.ts +68 -0
  251. package/src/hooks/index.ts +90 -0
  252. package/src/hooks/useWindowDimensions/index.android.ts +38 -0
  253. package/src/hooks/useWindowDimensions/index.ts +1 -0
  254. package/src/index.ts +23 -0
  255. package/src/internal.ts +84 -0
  256. package/src/module.ts +52 -0
  257. package/src/monkey-patch.android.ts +44 -0
  258. package/src/monkey-patch.ts +4 -0
  259. package/src/reanimated.native.ts +132 -0
  260. package/src/reanimated.ts +29 -0
  261. package/src/specs/KeyboardControllerViewNativeComponent.ts +71 -0
  262. package/src/specs/KeyboardGestureAreaNativeComponent.ts +20 -0
  263. package/src/specs/NativeKeyboardController.ts +19 -0
  264. package/src/specs/NativeStatusBarManagerCompat.ts +14 -0
  265. package/src/specs/OverKeyboardViewNativeComponent.ts +12 -0
  266. package/src/types.ts +243 -0
  267. package/src/utils.ts +1 -0
  268. package/src/views/OverKeyboardView/index.tsx +43 -0
  269. package/src/views/index.ts +1 -0
@@ -0,0 +1,76 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ #ifndef KEYBOARDCONTROLLERVIEWCOMPONENTINSTANCE_H
8
+ #define KEYBOARDCONTROLLERVIEWCOMPONENTINSTANCE_H
9
+
10
+ #ifndef TESTER_HARMONY_KEYBOARD_CONTROLLER_SRC_MAIN_CPP_KEYBOARDCONTROLLERVIEWCOMPONENTINSTANCE_H
11
+ #define TESTER_HARMONY_KEYBOARD_CONTROLLER_SRC_MAIN_CPP_KEYBOARDCONTROLLERVIEWCOMPONENTINSTANCE_H
12
+
13
+ #include <any>
14
+ #include "RNOH/CppComponentInstance.h"
15
+ #include "KeyboardControllerViewComponentDescriptor.h"
16
+ #include "RNOHCorePackage/ComponentInstances/TextInputComponentInstance.h"
17
+ #include "RNOH/arkui/CustomNode.h"
18
+ #include "RNOH/ArkTSMessageHub.h"
19
+ #include "RNOH/arkui/TextInputNode.h"
20
+ #include "RNOH/arkui/TextAreaNode.h"
21
+
22
+ namespace rnoh {
23
+ enum KeyboardControllerStatus { HIDE = 0, SHOW = 1 };
24
+ class KeyboardControllerViewComponentInstance
25
+ : public CppComponentInstance<facebook::react::KeyboardControllerViewShadowNode>,
26
+ public CustomNodeDelegate,
27
+ public TextAreaNodeDelegate,
28
+ public TextInputNodeDelegate,
29
+ public ArkTSMessageHub::Observer {
30
+ public:
31
+ KeyboardControllerViewComponentInstance(Context context);
32
+ void onKeyboardMoveStart();
33
+ void onKeyboardMove();
34
+ void onKeyboardMoveEnd();
35
+ void onKeyboardMoveInteractive();
36
+ void onFocusedInputLayoutChanged();
37
+ void onFocusedInputTextChanged();
38
+ void onFocusedInputSelectionChanged();
39
+
40
+ void onChildInserted(ComponentInstance::Shared const &childComponentInstance, std::size_t index) override;
41
+ void onChildRemoved(ComponentInstance::Shared const &childComponentInstance) override;
42
+ void onPropsChanged(SharedConcreteProps const &props) override;
43
+ void onCommandReceived(std::string const &commandName, folly::dynamic const &args) override;
44
+ void onMessageReceived(ArkTSMessage const &message) override;
45
+ ArkUINode &getLocalRootArkUINode() override;
46
+ void onClick() override;
47
+ // textArea textInput delegate
48
+ void onChange(std::string text) override;
49
+ void onBlur() override;
50
+ void onFocus() override;
51
+ void onTextSelectionChange(int32_t location, int32_t length) override;
52
+
53
+ protected:
54
+ private:
55
+ bool enabled;
56
+ bool statusBarTranslucent;
57
+ bool navigationBarTranslucent;
58
+ bool preserveEdgeToEdge = true;
59
+ double keyboardHeight;
60
+ std::map<std::string, std::any> dictionary;
61
+ int keyboardStatus;
62
+ std::vector<TextInputComponentInstance::Shared> textInputVector{};
63
+ CustomNode m_customNode{};
64
+ ComponentInstance::Shared currentResponder;
65
+ void findTextInputComponents(ComponentInstance::Shared const &parentComponentInstance);
66
+ void setWindowSystemBarEnable();
67
+ void startKeyboardObserver();
68
+ void closeKeyboardObserver();
69
+ void keyboardHeightChangeHandle();
70
+ void setWindowLayoutFullScreen();
71
+ };
72
+ } // namespace rnoh
73
+
74
+ #endif
75
+
76
+ #endif
@@ -0,0 +1,44 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ #ifndef TESTER_HARMONY_KEYBOARD_CONTROLLER_SRC_MAIN_CPP_KEYBOARDCONTROLLERVIEWJSIBINDER_H
8
+ #define TESTER_HARMONY_KEYBOARD_CONTROLLER_SRC_MAIN_CPP_KEYBOARDCONTROLLERVIEWJSIBINDER_H
9
+
10
+ #pragma once
11
+ #include "RNOHCorePackage/ComponentBinders/ViewComponentJSIBinder.h"
12
+ namespace rnoh {
13
+ class KeyboardControllerViewJSIBinder : public ViewComponentJSIBinder {
14
+ protected:
15
+ facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override {
16
+ auto object = ViewComponentJSIBinder::createNativeProps(rt);
17
+ object.setProperty(rt, "enabled", "bool");
18
+ object.setProperty(rt, "statusBarTranslucent", "bool");
19
+ object.setProperty(rt, "navigationBarTranslucent", "bool");
20
+ object.setProperty(rt, "preserveEdgeToEdge", "bool");
21
+ return object;
22
+ }
23
+
24
+ facebook::jsi::Object createBubblingEventTypes(facebook::jsi::Runtime &rt) override {
25
+ facebook::jsi::Object events(rt);
26
+ return events;
27
+ }
28
+
29
+ facebook::jsi::Object createDirectEventTypes(facebook::jsi::Runtime &rt) override {
30
+ facebook::jsi::Object events(rt);
31
+ events.setProperty(rt, "topKeyboardMoveStart", createDirectEvent(rt, "onKeyboardMoveStart"));
32
+ events.setProperty(rt, "topKeyboardMove", createDirectEvent(rt, "onKeyboardMove"));
33
+ events.setProperty(rt, "topKeyboardMoveEnd", createDirectEvent(rt, "onKeyboardMoveEnd"));
34
+ events.setProperty(rt, "topKeyboardMoveInteractive", createDirectEvent(rt, "onKeyboardMoveInteractive"));
35
+ events.setProperty(rt, "topFocusedInputLayoutChanged", createDirectEvent(rt, "onFocusedInputLayoutChanged"));
36
+ events.setProperty(rt, "topFocusedInputTextChanged", createDirectEvent(rt, "onFocusedInputTextChanged"));
37
+ events.setProperty(rt, "topFocusedInputSelectionChanged",
38
+ createDirectEvent(rt, "onFocusedInputSelectionChanged"));
39
+ return events;
40
+ }
41
+ };
42
+ } // namespace rnoh
43
+
44
+ #endif
@@ -0,0 +1,58 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ #ifndef TESTER_HARMONY_KEYBOARD_CONTROLLER_SRC_MAIN_CPP_KEYBOARDGESTUREAREACOMPONENTDESCRIPTOR_H
8
+ #define TESTER_HARMONY_KEYBOARD_CONTROLLER_SRC_MAIN_CPP_KEYBOARDGESTUREAREACOMPONENTDESCRIPTOR_H
9
+
10
+ #ifndef KEYBOARDGESTUREAREACOMPONENTDESCRIPTOR_H
11
+ #define KEYBOARDGESTUREAREACOMPONENTDESCRIPTOR_H
12
+
13
+
14
+ #pragma once
15
+
16
+
17
+ #include <react/renderer/core/ConcreteComponentDescriptor.h>
18
+ #include <react/renderer/components/view/ConcreteViewShadowNode.h>
19
+ #include <react/renderer/components/view/ViewShadowNode.h>
20
+ #include <react/renderer/core/propsConversions.h>
21
+ #include "EventEmitters.h"
22
+
23
+ namespace facebook {
24
+ namespace react {
25
+
26
+ inline const char KeyboardGestureAreaComponentName[] = "RNKeyboardGestureArea";
27
+
28
+ class KeyboardGestureAreaProps : public ViewProps {
29
+ public:
30
+ bool showOnSwipeUp;
31
+ bool enableSwipeToDismiss;
32
+ std::string interpolator;
33
+ KeyboardGestureAreaProps() = default;
34
+
35
+ KeyboardGestureAreaProps(const PropsParserContext &context, const KeyboardGestureAreaProps &sourceProps,
36
+ const RawProps &rawProps)
37
+ : ViewProps(context, sourceProps, rawProps),
38
+ showOnSwipeUp(convertRawProp(context, rawProps, "showOnSwipeUp", sourceProps.showOnSwipeUp, {false})),
39
+ enableSwipeToDismiss(convertRawProp(context, rawProps, "enableSwipeToDismiss",
40
+ sourceProps.enableSwipeToDismiss, {false})),
41
+ interpolator(convertRawProp(context, rawProps, "interpolator", sourceProps.interpolator, {"linear"})) {}
42
+ };
43
+
44
+ using KeyboardGestureAreaShadowNode =
45
+ ConcreteViewShadowNode<KeyboardGestureAreaComponentName, KeyboardGestureAreaProps, ViewEventEmitter>;
46
+
47
+ class KeyboardGestureAreaComponentDescriptor final : public ConcreteComponentDescriptor<KeyboardGestureAreaShadowNode> {
48
+ public:
49
+ KeyboardGestureAreaComponentDescriptor(ComponentDescriptorParameters const &parameters)
50
+ : ConcreteComponentDescriptor(parameters) {}
51
+ };
52
+
53
+ } // namespace react
54
+ } // namespace facebook
55
+
56
+ #endif
57
+
58
+ #endif
@@ -0,0 +1,87 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ #include "KeyboardGestureAreaComponentInstance.h"
8
+ #include <folly/dynamic.h>
9
+
10
+
11
+ namespace rnoh {
12
+ KeyboardGestureAreaComponentInstance::KeyboardGestureAreaComponentInstance(Context context)
13
+ : CppComponentInstance(std::move(context)) {
14
+ DLOG(INFO) << "KeyboardGestureAreaComponentInstance";
15
+ ArkUINodeRegistry::getInstance().registerTouchHandler(&m_stackNode, this);
16
+ }
17
+ void KeyboardGestureAreaComponentInstance::onTouchEvent(ArkUI_UIInputEvent *e) {
18
+ auto action = OH_ArkUI_UIInputEvent_GetAction(e);
19
+ DLOG(INFO) << "KeyboardGestureAreaComponentInstance onTouchEvent" << action;
20
+ if (action == UI_TOUCH_EVENT_ACTION_DOWN) {
21
+ this->swipeToDismiss();
22
+ }
23
+ if (action == UI_TOUCH_EVENT_ACTION_UP) {
24
+ this->swipeToUp();
25
+ }
26
+ }
27
+ void KeyboardGestureAreaComponentInstance::onChildInserted(ComponentInstance::Shared const &childComponentInstance,
28
+ std::size_t index) {
29
+ CppComponentInstance::onChildInserted(childComponentInstance, index);
30
+ m_stackNode.insertChild(childComponentInstance->getLocalRootArkUINode(), index + 1);
31
+ }
32
+
33
+ void KeyboardGestureAreaComponentInstance::onChildRemoved(ComponentInstance::Shared const &childComponentInstance) {
34
+ CppComponentInstance::onChildRemoved(childComponentInstance);
35
+ m_stackNode.removeChild(childComponentInstance->getLocalRootArkUINode());
36
+ }
37
+ ArkUINode &KeyboardGestureAreaComponentInstance::getLocalRootArkUINode() { return m_stackNode; }
38
+ void KeyboardGestureAreaComponentInstance::onPropsChanged(SharedConcreteProps const &props) {
39
+ DLOG(INFO) << "###onPropsChanged";
40
+ CppComponentInstance::onPropsChanged(props);
41
+ this->showOnSwipeUp = props->showOnSwipeUp;
42
+ this->enableSwipeToDismiss = props->enableSwipeToDismiss;
43
+ this->interpolator = props->interpolator;
44
+ }
45
+
46
+ void KeyboardGestureAreaComponentInstance::onCommandReceived(std::string const &commandName,
47
+ folly::dynamic const &args) {
48
+ CppComponentInstance::onCommandReceived(commandName, args);
49
+ }
50
+
51
+ void KeyboardGestureAreaComponentInstance::handleTouchEvent(ArkUI_UIInputEvent *e) {
52
+ auto action = OH_ArkUI_UIInputEvent_GetAction(e);
53
+ if (action == UI_TOUCH_EVENT_ACTION_DOWN) {
54
+ this->swipeToDismiss();
55
+ }
56
+ if (action == UI_TOUCH_EVENT_ACTION_UP) {
57
+ this->swipeToUp();
58
+ }
59
+ }
60
+ void KeyboardGestureAreaComponentInstance::swipeToDismiss() {
61
+ if (!this->enableSwipeToDismiss) {
62
+ return;
63
+ }
64
+ auto rnInstancePtr = this->m_deps->rnInstance.lock();
65
+ if (rnInstancePtr != nullptr) {
66
+ auto turboModule = rnInstancePtr->getTurboModule("KeyboardController");
67
+ auto arkTsTurboModule = std::dynamic_pointer_cast<rnoh::ArkTSTurboModule>(turboModule);
68
+ arkTsTurboModule->callSync("dismiss", {false});
69
+ }
70
+ }
71
+ void KeyboardGestureAreaComponentInstance::swipeToUp() {
72
+ if (!this->showOnSwipeUp) {
73
+ return;
74
+ }
75
+ auto rnInstancePtr = this->m_deps->rnInstance.lock();
76
+ if (rnInstancePtr != nullptr) {
77
+ auto turboModule = rnInstancePtr->getTurboModule("KeyboardController");
78
+ auto arkTsTurboModule = std::dynamic_pointer_cast<rnoh::ArkTSTurboModule>(turboModule);
79
+ arkTsTurboModule->callSync("show", {});
80
+ }
81
+ }
82
+ void KeyboardGestureAreaComponentInstance::executeInterpolator() {
83
+ // to do
84
+ }
85
+
86
+ } // namespace rnoh
87
+ // namespace rnoh
@@ -0,0 +1,62 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ #ifndef KEYBOARDGESTUREAREACOMPONENTINSTANCE_H
8
+ #define KEYBOARDGESTUREAREACOMPONENTINSTANCE_H
9
+
10
+ #ifndef TESTER_HARMONY_KEYBOARD_CONTROLLER_SRC_MAIN_CPP_KEYBOARDGESTUREAREACOMPONENTINSTANCE_H
11
+ #define TESTER_HARMONY_KEYBOARD_CONTROLLER_SRC_MAIN_CPP_KEYBOARDGESTUREAREACOMPONENTINSTANCE_H
12
+
13
+ #include <iostream>
14
+ #include <deque>
15
+ #include "RNOH/CppComponentInstance.h"
16
+ #include "KeyboardGestureAreaComponentDescriptor.h"
17
+ #include "RNOH/arkui/StackNode.h"
18
+ #include "RNOH/arkui/ArkUINodeRegistry.h"
19
+ namespace rnoh {
20
+
21
+ class KeyboardGestureAreaComponentInstance
22
+ : public CppComponentInstance<facebook::react::KeyboardGestureAreaShadowNode>,
23
+ public TouchEventHandler {
24
+ public:
25
+ KeyboardGestureAreaComponentInstance(Context context);
26
+ ~KeyboardGestureAreaComponentInstance()
27
+ {
28
+ // Clean-up code here
29
+ std::cout << "KeyboardGestureAreaComponentInstance destroyed." << std::endl;
30
+ ArkUINodeRegistry::getInstance().unregisterTouchHandler(&m_stackNode);
31
+ }
32
+ void onTouchEvent(ArkUI_UIInputEvent *e) override;
33
+ void onChildInserted(ComponentInstance::Shared const &childComponentInstance, std::size_t index) override;
34
+ void onChildRemoved(ComponentInstance::Shared const &childComponentInstance) override;
35
+ void onPropsChanged(SharedConcreteProps const &props) override;
36
+ void onCommandReceived(std::string const &commandName, folly::dynamic const &args) override;
37
+ ArkUINode &getLocalRootArkUINode() override;
38
+ protected:
39
+ private:
40
+ bool showOnSwipeUp;
41
+ bool enableSwipeToDismiss;
42
+ std::string interpolator;
43
+ double keyboardHeight;
44
+ size_t maxSize;
45
+ std::deque<folly::dynamic> buffer;
46
+ StackNode m_stackNode;
47
+ struct TouchPoint {
48
+ facebook::react::Float pointerId;
49
+ facebook::react::Float windowX;
50
+ facebook::react::Float windowY;
51
+ };
52
+ folly::dynamic convertNodeTouchPointToDynamic(ArkUI_UIInputEvent *e, int32_t index);
53
+ void swipeToUp();
54
+ void swipeToDismiss();
55
+ void executeInterpolator();
56
+ void handleTouchEvent(ArkUI_UIInputEvent *e);
57
+ };
58
+ } // namespace rnoh
59
+
60
+ #endif
61
+
62
+ #endif
@@ -0,0 +1,39 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ #ifndef TESTER_HARMONY_KEYBOARD_CONTROLLER_SRC_MAIN_CPP_KEYBOARDGESTUREAREAJSIBINDER_H
8
+ #define TESTER_HARMONY_KEYBOARD_CONTROLLER_SRC_MAIN_CPP_KEYBOARDGESTUREAREAJSIBINDER_H
9
+
10
+ #pragma once
11
+ #include "RNOHCorePackage/ComponentBinders/ViewComponentJSIBinder.h"
12
+
13
+ namespace rnoh {
14
+ class KeyboardGestureAreaJSIBinder : public ViewComponentJSIBinder {
15
+ protected:
16
+ facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override
17
+ {
18
+ auto object = ViewComponentJSIBinder::createNativeProps(rt);
19
+ object.setProperty(rt, "interpolator", "String");
20
+ object.setProperty(rt, "showOnSwipeUp", "bool");
21
+ object.setProperty(rt, "enableSwipeToDismiss", "bool");
22
+ return object;
23
+ }
24
+
25
+ facebook::jsi::Object createBubblingEventTypes(facebook::jsi::Runtime &rt) override
26
+ {
27
+ facebook::jsi::Object events(rt);
28
+ return events;
29
+ }
30
+
31
+ facebook::jsi::Object createDirectEventTypes(facebook::jsi::Runtime &rt) override
32
+ {
33
+ facebook::jsi::Object events(rt);
34
+ return events;
35
+ }
36
+ };
37
+ } // namespace rnoh
38
+
39
+ #endif
@@ -0,0 +1,25 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+
8
+ #include "RNKeyboardController.h"
9
+
10
+ namespace rnoh {
11
+ using namespace facebook;
12
+ KeyboardController::KeyboardController(const ArkTSTurboModule::Context ctx, const std::string name) : ArkTSTurboModule(ctx, name)
13
+ {
14
+ methodMap_ = {
15
+ ARK_METHOD_METADATA(getConstants, 0),
16
+ ARK_METHOD_METADATA(setInputMode, 1),
17
+ ARK_METHOD_METADATA(setDefaultMode, 0),
18
+ ARK_METHOD_METADATA(dismiss, 1),
19
+ ARK_METHOD_METADATA(setFocusTo, 1),
20
+ ARK_METHOD_METADATA(addListener, 1),
21
+ ARK_METHOD_METADATA(removeListeners, 1),
22
+ };
23
+ }
24
+
25
+ } // namespace rnoh
@@ -0,0 +1,27 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ #ifndef TESTER_HARMONY_KEYBOARD_CONTROLLER_SRC_MAIN_CPP_RNKEYBOARDCONTROLLER_H
8
+ #define TESTER_HARMONY_KEYBOARD_CONTROLLER_SRC_MAIN_CPP_RNKEYBOARDCONTROLLER_H
9
+
10
+ #ifndef RNKEYBOARDCONTROLLER_H
11
+ #define RNKEYBOARDCONTROLLER_H
12
+ #pragma once
13
+
14
+ #include "RNOH/ArkTSTurboModule.h"
15
+
16
+ namespace rnoh {
17
+
18
+ class JSI_EXPORT KeyboardController : public ArkTSTurboModule {
19
+ public:
20
+ KeyboardController(const ArkTSTurboModule::Context ctx, const std::string name);
21
+ };
22
+
23
+ } // namespace rnoh
24
+
25
+ #endif
26
+
27
+ #endif
@@ -0,0 +1,24 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+
8
+ #include "RNStatusBarManagerCompat.h"
9
+
10
+ namespace rnoh {
11
+ using namespace facebook;
12
+
13
+ StatusBarManagerCompat::StatusBarManagerCompat(const ArkTSTurboModule::Context ctx, const std::string name) : ArkTSTurboModule(ctx, name)
14
+ {
15
+ methodMap_ = {
16
+ ARK_METHOD_METADATA(getConstants, 0),
17
+ ARK_METHOD_METADATA(setHidden, 1),
18
+ ARK_METHOD_METADATA(setColor, 2),
19
+ ARK_METHOD_METADATA(setTranslucent, 1),
20
+ ARK_METHOD_METADATA(setStyle, 1),
21
+ };
22
+ }
23
+
24
+ } // namespace rnoh
@@ -0,0 +1,28 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ #ifndef TESTER_HARMONY_KEYBOARD_CONTROLLER_SRC_MAIN_CPP_RNSTATUSBARMANAGERCOMPAT_H
8
+ #define TESTER_HARMONY_KEYBOARD_CONTROLLER_SRC_MAIN_CPP_RNSTATUSBARMANAGERCOMPAT_H
9
+
10
+ #ifndef RNSTATUSBARMANAGERCOMPAT_H
11
+ #define RNSTATUSBARMANAGERCOMPAT_H
12
+
13
+ #pragma once
14
+
15
+ #include "RNOH/ArkTSTurboModule.h"
16
+
17
+ namespace rnoh {
18
+
19
+ class JSI_EXPORT StatusBarManagerCompat : public ArkTSTurboModule {
20
+ public:
21
+ StatusBarManagerCompat(const ArkTSTurboModule::Context ctx, const std::string name);
22
+ };
23
+
24
+ } // namespace rnoh
25
+
26
+ #endif
27
+
28
+ #endif
@@ -0,0 +1,43 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ #include "keyboardControllerPackage.h"
8
+ #include "KeyboardControllerViewJSIBinder.h"
9
+ #include "KeyboardGestureAreaJSIBinder.h"
10
+
11
+
12
+ using namespace facebook;
13
+ using namespace rnoh;
14
+
15
+ std::vector<facebook::react::ComponentDescriptorProvider>
16
+ KeyboardControllerPackage::createComponentDescriptorProviders() {
17
+ return {facebook::react::concreteComponentDescriptorProvider<
18
+ facebook::react::KeyboardControllerViewComponentDescriptor>(),
19
+ facebook::react::concreteComponentDescriptorProvider<
20
+ facebook::react::KeyboardGestureAreaComponentDescriptor>()};
21
+ }
22
+ ComponentJSIBinderByString KeyboardControllerPackage::createComponentJSIBinderByName() {
23
+ return {{"RNKeyboardControllerView", std::make_shared<KeyboardControllerViewJSIBinder>()},
24
+ {"RNKeyboardGestureArea", std::make_shared<KeyboardGestureAreaJSIBinder>()}};
25
+ }
26
+
27
+ std::unique_ptr<TurboModuleFactoryDelegate> KeyboardControllerPackage::createTurboModuleFactoryDelegate() {
28
+ return std::make_unique<KeyboardControllerTurboModuleFactoryDelegate>();
29
+ }
30
+
31
+ ComponentInstanceFactoryDelegate::Shared KeyboardControllerPackage::createComponentInstanceFactoryDelegate() {
32
+ return std::make_shared<KeyboardControllerComponentInstanceFactoryDelegate>();
33
+ };
34
+
35
+ ComponentInstance::Shared KeyboardControllerPackage::createComponentInstance(const ComponentInstance::Context &ctx) {
36
+ if (ctx.componentName == "RNKeyboardControllerView") {
37
+ return std::make_shared<KeyboardControllerViewComponentInstance>(ctx);
38
+ }
39
+ if (ctx.componentName == "RNKeyboardGestureArea") {
40
+ return std::make_shared<KeyboardGestureAreaComponentInstance>(ctx);
41
+ }
42
+ return nullptr;
43
+ };
@@ -0,0 +1,56 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ #ifndef TESTER_HARMONY_KEYBOARD_CONTROLLER_SRC_MAIN_CPP_KEYBOARDCONTROLLERPACKAGE_H
8
+ #define TESTER_HARMONY_KEYBOARD_CONTROLLER_SRC_MAIN_CPP_KEYBOARDCONTROLLERPACKAGE_H
9
+
10
+ #ifndef KEYBOARDCONTROLLERPACKAGE_H
11
+ #define KEYBOARDCONTROLLERPACKAGE_H
12
+
13
+ #include "KeyboardGestureAreaComponentInstance.h"
14
+ #include "RNOH/Package.h"
15
+ #include "RNKeyboardController.h"
16
+ #include "RNStatusBarManagerCompat.h"
17
+ #include "KeyboardControllerViewComponentInstance.h"
18
+ namespace rnoh {
19
+ class KeyboardControllerComponentInstanceFactoryDelegate : public ComponentInstanceFactoryDelegate {
20
+ public:
21
+ ComponentInstance::Shared create(ComponentInstance::Context ctx) override {
22
+ if (ctx.componentName == "RNKeyboardControllerView") {
23
+ return std::make_shared<KeyboardControllerViewComponentInstance>(ctx);
24
+ }
25
+ if (ctx.componentName == "RNKeyboardGestureArea") {
26
+ return std::make_shared<KeyboardGestureAreaComponentInstance>(ctx);
27
+ }
28
+ return nullptr;
29
+ }
30
+ };
31
+ class KeyboardControllerTurboModuleFactoryDelegate : public TurboModuleFactoryDelegate {
32
+ public:
33
+ SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override {
34
+ if (name == "KeyboardController") {
35
+ return std::make_shared<KeyboardController>(ctx, name);
36
+ }
37
+ if (name == "StatusBarManagerCompat") {
38
+ return std::make_shared<StatusBarManagerCompat>(ctx, name);
39
+ }
40
+ return nullptr;
41
+ };
42
+ };
43
+ class KeyboardControllerPackage : public Package{
44
+ public:
45
+ KeyboardControllerPackage(Package::Context ctx) : Package(ctx) {}
46
+ std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override;
47
+ std::vector<facebook::react::ComponentDescriptorProvider> createComponentDescriptorProviders() override;
48
+ ComponentJSIBinderByString createComponentJSIBinderByName() override;
49
+ ComponentInstance::Shared createComponentInstance(const ComponentInstance::Context &ctx) override;
50
+ ComponentInstanceFactoryDelegate::Shared createComponentInstanceFactoryDelegate() override;
51
+ };
52
+ } // namespace rnoh
53
+
54
+ #endif
55
+
56
+ #endif
@@ -0,0 +1,46 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ import hilog from '@ohos.hilog';
8
+
9
+ class Logger {
10
+ private domain: number;
11
+ private prefix: string;
12
+ private format: string = '%{public}s, %{public}s';
13
+ private isDebug: boolean;
14
+
15
+ /**
16
+ * constructor.
17
+ *
18
+ * @param Prefix Identifies the log tag.
19
+ * @param domain Domain Indicates the service domain, which is a hexadecimal integer ranging from 0x0 to 0xFFFFF.
20
+ */
21
+ constructor(prefix: string = 'MyApp', domain: number = 0xFF00, isDebug = false) {
22
+ this.prefix = prefix;
23
+ this.domain = domain;
24
+ this.isDebug = isDebug;
25
+ }
26
+
27
+ debug(...args: string[]): void {
28
+ if(this.isDebug) {
29
+ hilog.debug(this.domain, this.prefix, this.format, args);
30
+ }
31
+ }
32
+
33
+ info(...args: string[]): void {
34
+ hilog.info(this.domain, this.prefix, this.format, args);
35
+ }
36
+
37
+ warn(...args: string[]): void {
38
+ hilog.warn(this.domain, this.prefix, this.format, args);
39
+ }
40
+
41
+ error(...args: string[]): void {
42
+ hilog.error(this.domain, this.prefix, this.format, args);
43
+ }
44
+ }
45
+
46
+ export default new Logger('KeyboardController', 0xFF00, false)
@@ -0,0 +1,45 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ import {RNPackage,TurboModulesFactory} from '@rnoh/react-native-openharmony/ts';
8
+ import type { TurboModule, TurboModuleContext, } from '@rnoh/react-native-openharmony/ts';
9
+ import {RNKeyboardControllerTurboModule} from './RNKeyboardControllerTurboModule';
10
+ import {RNStatusBarManagerCompatTurboModule} from './RNStatusBarManagerCompatTurboModule';
11
+
12
+ class RNKeyboardControllerTurboModuleFactory extends TurboModulesFactory {
13
+ createTurboModule(name: string): TurboModule | null {
14
+ if (this.hasTurboModule(name)) {
15
+ return new RNKeyboardControllerTurboModule(this.ctx);
16
+ }
17
+ return null;
18
+ }
19
+ hasTurboModule(name: string): boolean {
20
+ return name === 'KeyboardController';
21
+ }
22
+
23
+ }
24
+ class RNStatusBarManagerCompatTurboModuleFactory extends TurboModulesFactory {
25
+ createTurboModule(name: string): TurboModule | null {
26
+ if(this.hasTurboModule(name)){
27
+ return new RNStatusBarManagerCompatTurboModule(this.ctx);
28
+ }
29
+ return null;
30
+ }
31
+ hasTurboModule(name: string): boolean {
32
+ return name === 'StatusBarManagerCompat';
33
+ }
34
+ }
35
+
36
+ export class RNKeyboardControllerPackage extends RNPackage {
37
+ createTurboModulesFactory(ctx: TurboModuleContext): TurboModulesFactory {
38
+ return new RNKeyboardControllerTurboModuleFactory(ctx);
39
+ }
40
+ }
41
+ export class RNStatusBarManagerCompatPackage extends RNPackage {
42
+ createTurboModulesFactory(ctx: TurboModuleContext): TurboModulesFactory {
43
+ return new RNStatusBarManagerCompatTurboModuleFactory(ctx);
44
+ }
45
+ }