@react-native-ohos/react-native-keyboard-controller 1.17.0-beta.2 → 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/LICENSE +21 -21
- package/README.OpenSource +11 -11
- package/README.md +686 -19
- package/harmony/keyboard_controller/BuildProfile.ets +16 -16
- package/harmony/keyboard_controller/Index.ets +29 -28
- package/harmony/keyboard_controller/build-profile.json5 +31 -31
- package/harmony/keyboard_controller/hvigorfile.ts +6 -6
- package/harmony/keyboard_controller/obfuscation-rules.txt +17 -17
- package/harmony/keyboard_controller/oh-package-lock.json5 +28 -18
- package/harmony/keyboard_controller/oh-package.json5 +10 -10
- package/harmony/keyboard_controller/src/main/cpp/CMakeLists.txt +7 -7
- package/harmony/keyboard_controller/src/main/cpp/ClippingScrollViewComponentDescriptor.h +86 -0
- package/harmony/keyboard_controller/src/main/cpp/ClippingScrollViewComponentInstance.cpp +104 -0
- package/harmony/keyboard_controller/src/main/cpp/ClippingScrollViewComponentInstance.h +64 -0
- package/harmony/keyboard_controller/src/main/cpp/ClippingScrollViewJSIBinder.h +60 -0
- package/harmony/keyboard_controller/src/main/cpp/EventEmitters.cpp +119 -96
- package/harmony/keyboard_controller/src/main/cpp/EventEmitters.h +111 -111
- package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewComponentDescriptor.h +94 -94
- package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewComponentInstance.cpp +840 -288
- package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewComponentInstance.h +169 -103
- package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewJSIBinder.h +65 -65
- package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentDescriptor.h +79 -79
- package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentInstance.cpp +108 -108
- package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentInstance.h +83 -83
- package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaJSIBinder.h +60 -60
- package/harmony/keyboard_controller/src/main/cpp/KeyboardToolbarGroupViewComponentDescriptor.h +46 -0
- package/harmony/keyboard_controller/src/main/cpp/KeyboardToolbarGroupViewComponentInstance.cpp +37 -0
- package/harmony/keyboard_controller/src/main/cpp/KeyboardToolbarGroupViewComponentInstance.h +32 -0
- package/harmony/keyboard_controller/src/main/cpp/KeyboardToolbarGroupViewJSIBinder.h +23 -0
- package/harmony/keyboard_controller/src/main/cpp/RNKeyboardController.cpp +103 -46
- package/harmony/keyboard_controller/src/main/cpp/RNKeyboardController.h +48 -48
- package/harmony/keyboard_controller/src/main/cpp/RNKeyboardControllerPackage.h +20 -0
- package/harmony/keyboard_controller/src/main/cpp/RNStatusBarManagerCompat.cpp +45 -45
- package/harmony/keyboard_controller/src/main/cpp/RNStatusBarManagerCompat.h +49 -49
- package/harmony/keyboard_controller/src/main/cpp/ViewHierarchyNavigator.cpp +207 -186
- package/harmony/keyboard_controller/src/main/cpp/ViewHierarchyNavigator.h +131 -112
- package/harmony/keyboard_controller/src/main/cpp/keyboardControllerPackage.cpp +77 -64
- package/harmony/keyboard_controller/src/main/cpp/keyboardControllerPackage.h +85 -77
- package/harmony/keyboard_controller/src/main/ets/Logger.ts +66 -66
- package/harmony/keyboard_controller/src/main/ets/{RNKeyboardControllerPackage.ts → RNKeyboardControllerPackage.ets} +70 -66
- package/harmony/keyboard_controller/src/main/ets/RNKeyboardControllerTurboModule.ts +465 -273
- package/harmony/keyboard_controller/src/main/ets/RNStatusBarManagerCompatTurboModule.ts +128 -119
- package/harmony/keyboard_controller/src/main/ets/Type.ts +63 -62
- package/harmony/keyboard_controller/src/main/module.json5 +11 -11
- package/harmony/keyboard_controller/src/main/resources/base/element/string.json +8 -8
- package/harmony/keyboard_controller/src/main/resources/en_US/element/string.json +8 -8
- package/harmony/keyboard_controller/src/main/resources/zh_CN/element/string.json +8 -8
- package/harmony/keyboard_controller/{ts.ts → ts.ets} +29 -29
- package/harmony/keyboard_controller.har +0 -0
- package/lib/commonjs/animated.js +22 -11
- package/lib/commonjs/animated.js.map +1 -1
- package/lib/commonjs/architecture.js +8 -0
- package/lib/commonjs/architecture.js.map +1 -0
- package/lib/commonjs/bindings.js +40 -5
- package/lib/commonjs/bindings.js.map +1 -1
- package/lib/commonjs/bindings.native.js +28 -5
- package/lib/commonjs/bindings.native.js.map +1 -1
- package/lib/commonjs/compat.js +50 -0
- package/lib/commonjs/compat.js.map +1 -0
- package/lib/commonjs/components/KeyboardAvoidingView/hooks.js +21 -15
- package/lib/commonjs/components/KeyboardAvoidingView/hooks.js.map +1 -1
- package/lib/commonjs/components/KeyboardAvoidingView/index.js +39 -14
- package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js +94 -57
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +5 -5
- package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/utils.js.map +1 -1
- package/lib/commonjs/components/KeyboardChatScrollView/hooks.js +13 -0
- package/lib/commonjs/components/KeyboardChatScrollView/hooks.js.map +1 -0
- package/lib/commonjs/components/KeyboardChatScrollView/index.js +122 -0
- package/lib/commonjs/components/KeyboardChatScrollView/index.js.map +1 -0
- package/lib/commonjs/components/KeyboardChatScrollView/types.js +6 -0
- package/lib/commonjs/components/KeyboardChatScrollView/types.js.map +1 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/helpers.js +221 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/helpers.js.map +1 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js +149 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js.map +1 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.js +240 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.js.map +1 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/types.js +6 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/types.js.map +1 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useEndVisible.js +40 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useEndVisible.js.map +1 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js +92 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js.map +1 -0
- package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/Arrow.js +2 -3
- package/lib/commonjs/components/KeyboardToolbar/Arrow.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/Button.js +2 -3
- package/lib/commonjs/components/KeyboardToolbar/Button.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/colors.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/colors.native.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/compound/components/Background.js +13 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/Background.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/Content.js +25 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/Content.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/Done.js +58 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/Done.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/Next.js +49 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/Next.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/Prev.js +49 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/Prev.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/index.js +42 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/index.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/types.js +6 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/types.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/context.js +17 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/context.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/constants.js +17 -0
- package/lib/commonjs/components/KeyboardToolbar/constants.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/index.js +98 -87
- package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/types.js.map +1 -1
- package/lib/commonjs/components/ScrollViewWithBottomPadding/index.js +120 -0
- package/lib/commonjs/components/ScrollViewWithBottomPadding/index.js.map +1 -0
- package/lib/commonjs/components/ScrollViewWithBottomPadding/styles.js +15 -0
- package/lib/commonjs/components/ScrollViewWithBottomPadding/styles.js.map +1 -0
- package/lib/commonjs/components/hooks/useColorScheme.js.map +1 -1
- package/lib/commonjs/components/hooks/useCombinedRef.js +24 -0
- package/lib/commonjs/components/hooks/useCombinedRef.js.map +1 -0
- package/lib/commonjs/components/hooks/useScrollState.js +62 -0
- package/lib/commonjs/components/hooks/useScrollState.js.map +1 -0
- package/lib/commonjs/components/index.js +7 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/constants.js +3 -1
- package/lib/commonjs/constants.js.map +1 -1
- package/lib/commonjs/context.js +1 -0
- package/lib/commonjs/context.js.map +1 -1
- package/lib/commonjs/hooks/index.js +14 -1
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useKeyboardState/index.js +39 -0
- package/lib/commonjs/hooks/useKeyboardState/index.js.map +1 -0
- package/lib/commonjs/hooks/useWindowDimensions/index.android.js.map +1 -1
- package/lib/commonjs/hooks/useWindowDimensions/index.js.map +1 -1
- package/lib/commonjs/index.js +27 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/internal.js +54 -18
- package/lib/commonjs/internal.js.map +1 -1
- package/lib/commonjs/module.js +21 -12
- package/lib/commonjs/module.js.map +1 -1
- package/lib/commonjs/reanimated.js.map +1 -1
- package/lib/commonjs/reanimated.native.js.map +1 -1
- package/lib/commonjs/specs/ClippingScrollViewDecoratorViewNativeComponent.js +12 -0
- package/lib/commonjs/specs/ClippingScrollViewDecoratorViewNativeComponent.js.map +1 -0
- package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js +8 -2
- package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
- package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js +2 -1
- package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
- package/lib/commonjs/specs/KeyboardToolbarGroupViewNativeComponent.js +12 -0
- package/lib/commonjs/specs/KeyboardToolbarGroupViewNativeComponent.js.map +1 -0
- package/lib/commonjs/specs/NativeKeyboardController.js.map +1 -1
- package/lib/commonjs/specs/NativeStatusBarManagerCompat.js.map +1 -1
- package/lib/commonjs/specs/OverKeyboardViewNativeComponent.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/utils/findNodeHandle/index.js +9 -0
- package/lib/commonjs/utils/findNodeHandle/index.js.map +1 -0
- package/lib/commonjs/utils/findNodeHandle/index.native.js +13 -0
- package/lib/commonjs/utils/findNodeHandle/index.native.js.map +1 -0
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/views/KeyboardExtender/index.js +30 -0
- package/lib/commonjs/views/KeyboardExtender/index.js.map +1 -0
- package/lib/commonjs/views/OverKeyboardView/index.js.map +1 -1
- package/lib/commonjs/views/index.js +7 -0
- package/lib/commonjs/views/index.js.map +1 -1
- package/lib/module/animated.js +24 -13
- package/lib/module/animated.js.map +1 -1
- package/lib/module/architecture.js +2 -0
- package/lib/module/architecture.js.map +1 -0
- package/lib/module/bindings.js +39 -5
- package/lib/module/bindings.js.map +1 -1
- package/lib/module/bindings.native.js +27 -5
- package/lib/module/bindings.native.js.map +1 -1
- package/lib/module/compat.js +43 -0
- package/lib/module/compat.js.map +1 -0
- package/lib/module/components/KeyboardAvoidingView/hooks.js +22 -16
- package/lib/module/components/KeyboardAvoidingView/hooks.js.map +1 -1
- package/lib/module/components/KeyboardAvoidingView/index.js +38 -14
- package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/index.js +97 -60
- package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +5 -5
- package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/utils.js.map +1 -1
- package/lib/module/components/KeyboardChatScrollView/hooks.js +2 -0
- package/lib/module/components/KeyboardChatScrollView/hooks.js.map +1 -0
- package/lib/module/components/KeyboardChatScrollView/index.js +115 -0
- package/lib/module/components/KeyboardChatScrollView/index.js.map +1 -0
- package/lib/module/components/KeyboardChatScrollView/types.js +2 -0
- package/lib/module/components/KeyboardChatScrollView/types.js.map +1 -0
- package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/helpers.js +207 -0
- package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/helpers.js.map +1 -0
- package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js +143 -0
- package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js.map +1 -0
- package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.js +234 -0
- package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.js.map +1 -0
- package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/types.js +2 -0
- package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/types.js.map +1 -0
- package/lib/module/components/KeyboardChatScrollView/useEndVisible.js +33 -0
- package/lib/module/components/KeyboardChatScrollView/useEndVisible.js.map +1 -0
- package/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js +87 -0
- package/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js.map +1 -0
- package/lib/module/components/KeyboardStickyView/index.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/Arrow.js +2 -2
- package/lib/module/components/KeyboardToolbar/Arrow.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/Button.js +2 -2
- package/lib/module/components/KeyboardToolbar/Button.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/colors.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/colors.native.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/compound/components/Background.js +6 -0
- package/lib/module/components/KeyboardToolbar/compound/components/Background.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/compound/components/Content.js +18 -0
- package/lib/module/components/KeyboardToolbar/compound/components/Content.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/compound/components/Done.js +50 -0
- package/lib/module/components/KeyboardToolbar/compound/components/Done.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/compound/components/Next.js +41 -0
- package/lib/module/components/KeyboardToolbar/compound/components/Next.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/compound/components/Prev.js +41 -0
- package/lib/module/components/KeyboardToolbar/compound/components/Prev.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/compound/components/index.js +6 -0
- package/lib/module/components/KeyboardToolbar/compound/components/index.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/compound/components/types.js +2 -0
- package/lib/module/components/KeyboardToolbar/compound/components/types.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/compound/context.js +10 -0
- package/lib/module/components/KeyboardToolbar/compound/context.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/constants.js +11 -0
- package/lib/module/components/KeyboardToolbar/constants.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/index.js +98 -88
- package/lib/module/components/KeyboardToolbar/index.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/types.js.map +1 -1
- package/lib/module/components/ScrollViewWithBottomPadding/index.js +112 -0
- package/lib/module/components/ScrollViewWithBottomPadding/index.js.map +1 -0
- package/lib/module/components/ScrollViewWithBottomPadding/styles.js +9 -0
- package/lib/module/components/ScrollViewWithBottomPadding/styles.js.map +1 -0
- package/lib/module/components/hooks/useColorScheme.js.map +1 -1
- package/lib/module/components/hooks/useCombinedRef.js +18 -0
- package/lib/module/components/hooks/useCombinedRef.js.map +1 -0
- package/lib/module/components/hooks/useScrollState.js +56 -0
- package/lib/module/components/hooks/useScrollState.js.map +1 -0
- package/lib/module/components/index.js +1 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/constants.js +3 -0
- package/lib/module/constants.js.map +1 -1
- package/lib/module/context.js +1 -0
- package/lib/module/context.js.map +1 -1
- package/lib/module/hooks/index.js +3 -1
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useKeyboardState/index.js +33 -0
- package/lib/module/hooks/useKeyboardState/index.js.map +1 -0
- package/lib/module/hooks/useWindowDimensions/index.android.js.map +1 -1
- package/lib/module/hooks/useWindowDimensions/index.js.map +1 -1
- package/lib/module/index.js +3 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal.js +53 -18
- package/lib/module/internal.js.map +1 -1
- package/lib/module/module.js +21 -12
- package/lib/module/module.js.map +1 -1
- package/lib/module/reanimated.js.map +1 -1
- package/lib/module/reanimated.native.js.map +1 -1
- package/lib/module/specs/ClippingScrollViewDecoratorViewNativeComponent.js +6 -0
- package/lib/module/specs/ClippingScrollViewDecoratorViewNativeComponent.js.map +1 -0
- package/lib/module/specs/KeyboardControllerViewNativeComponent.js +7 -1
- package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
- package/lib/module/specs/KeyboardGestureAreaNativeComponent.js +2 -1
- package/lib/module/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
- package/lib/module/specs/KeyboardToolbarGroupViewNativeComponent.js +5 -0
- package/lib/module/specs/KeyboardToolbarGroupViewNativeComponent.js.map +1 -0
- package/lib/module/specs/NativeKeyboardController.js.map +1 -1
- package/lib/module/specs/NativeStatusBarManagerCompat.js.map +1 -1
- package/lib/module/specs/OverKeyboardViewNativeComponent.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/findNodeHandle/index.js +2 -0
- package/lib/module/utils/findNodeHandle/index.js.map +1 -0
- package/lib/module/utils/findNodeHandle/index.native.js +3 -0
- package/lib/module/utils/findNodeHandle/index.native.js.map +1 -0
- package/lib/module/utils.js.map +1 -1
- package/lib/module/views/KeyboardExtender/index.js +23 -0
- package/lib/module/views/KeyboardExtender/index.js.map +1 -0
- package/lib/module/views/OverKeyboardView/index.js.map +1 -1
- package/lib/module/views/index.js +1 -0
- package/lib/module/views/index.js.map +1 -1
- package/lib/typescript/animated.d.ts +2 -38
- package/lib/typescript/architecture.d.ts +1 -0
- package/lib/typescript/bindings.d.ts +15 -1
- package/lib/typescript/bindings.native.d.ts +10 -1
- package/lib/typescript/compat.d.ts +12 -0
- package/lib/typescript/components/KeyboardAvoidingView/index.d.ts +5 -0
- package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +4 -1
- package/lib/typescript/components/KeyboardChatScrollView/hooks.d.ts +2 -0
- package/lib/typescript/components/KeyboardChatScrollView/index.d.ts +17 -0
- package/lib/typescript/components/KeyboardChatScrollView/types.d.ts +113 -0
- package/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/helpers.d.ts +132 -0
- package/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/index.d.ts +18 -0
- package/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/index.ios.d.ts +21 -0
- package/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/types.d.ts +37 -0
- package/lib/typescript/components/KeyboardChatScrollView/useEndVisible.d.ts +17 -0
- package/lib/typescript/components/KeyboardChatScrollView/useExtraContentPadding/index.d.ts +45 -0
- package/lib/typescript/components/KeyboardToolbar/Button.d.ts +2 -2
- package/lib/typescript/components/KeyboardToolbar/compound/components/Background.d.ts +6 -0
- package/lib/typescript/components/KeyboardToolbar/compound/components/Content.d.ts +7 -0
- package/lib/typescript/components/KeyboardToolbar/compound/components/Done.d.ts +7 -0
- package/lib/typescript/components/KeyboardToolbar/compound/components/Next.d.ts +4 -0
- package/lib/typescript/components/KeyboardToolbar/compound/components/Prev.d.ts +4 -0
- package/lib/typescript/components/KeyboardToolbar/compound/components/index.d.ts +5 -0
- package/lib/typescript/components/KeyboardToolbar/compound/components/types.d.ts +14 -0
- package/lib/typescript/components/KeyboardToolbar/compound/context.d.ts +9 -0
- package/lib/typescript/components/KeyboardToolbar/constants.d.ts +10 -0
- package/lib/typescript/components/KeyboardToolbar/index.d.ts +12 -45
- package/lib/typescript/components/KeyboardToolbar/types.d.ts +24 -1
- package/lib/typescript/components/ScrollViewWithBottomPadding/index.d.ts +30 -0
- package/lib/typescript/components/ScrollViewWithBottomPadding/styles.d.ts +7 -0
- package/lib/typescript/components/hooks/useCombinedRef.d.ts +3 -0
- package/lib/typescript/components/hooks/useScrollState.d.ts +17 -0
- package/lib/typescript/components/index.d.ts +3 -0
- package/lib/typescript/constants.d.ts +1 -0
- package/lib/typescript/context.d.ts +1 -0
- package/lib/typescript/hooks/index.d.ts +2 -0
- package/lib/typescript/hooks/useKeyboardState/index.d.ts +4 -0
- package/lib/typescript/index.d.ts +4 -3
- package/lib/typescript/internal.d.ts +4 -0
- package/lib/typescript/specs/ClippingScrollViewDecoratorViewNativeComponent.d.ts +10 -0
- package/lib/typescript/specs/KeyboardControllerViewNativeComponent.d.ts +4 -0
- package/lib/typescript/specs/KeyboardToolbarGroupViewNativeComponent.d.ts +6 -0
- package/lib/typescript/specs/NativeKeyboardController.d.ts +6 -2
- package/lib/typescript/types.d.ts +81 -5
- package/lib/typescript/utils/findNodeHandle/index.d.ts +4 -0
- package/lib/typescript/utils/findNodeHandle/index.native.d.ts +2 -0
- package/lib/typescript/views/KeyboardExtender/index.d.ts +5 -0
- package/lib/typescript/views/index.d.ts +1 -0
- package/package.json +183 -174
- package/src/animated.tsx +248 -255
- package/src/architecture.ts +1 -0
- package/src/bindings.native.ts +97 -62
- package/src/bindings.ts +81 -42
- package/src/compat.ts +44 -0
- package/src/components/KeyboardAvoidingView/hooks.ts +130 -123
- package/src/components/KeyboardAvoidingView/index.tsx +232 -188
- package/src/components/KeyboardAwareScrollView/index.tsx +452 -389
- package/src/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.ts +133 -133
- package/src/components/KeyboardAwareScrollView/utils.ts +41 -41
- package/src/components/KeyboardChatScrollView/hooks.ts +2 -0
- package/src/components/KeyboardChatScrollView/index.tsx +164 -0
- package/src/components/KeyboardChatScrollView/types.ts +117 -0
- package/src/components/KeyboardChatScrollView/useChatKeyboard/helpers.ts +268 -0
- package/src/components/KeyboardChatScrollView/useChatKeyboard/index.ios.ts +260 -0
- package/src/components/KeyboardChatScrollView/useChatKeyboard/index.ts +374 -0
- package/src/components/KeyboardChatScrollView/useChatKeyboard/types.ts +39 -0
- package/src/components/KeyboardChatScrollView/useEndVisible.ts +66 -0
- package/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts +149 -0
- package/src/components/KeyboardStickyView/index.tsx +66 -66
- package/src/components/KeyboardToolbar/Arrow.tsx +80 -80
- package/src/components/KeyboardToolbar/Button.tsx +98 -98
- package/src/components/KeyboardToolbar/colors.native.ts +37 -37
- package/src/components/KeyboardToolbar/colors.ts +16 -16
- package/src/components/KeyboardToolbar/compound/components/Background.tsx +9 -0
- package/src/components/KeyboardToolbar/compound/components/Content.tsx +25 -0
- package/src/components/KeyboardToolbar/compound/components/Done.tsx +57 -0
- package/src/components/KeyboardToolbar/compound/components/Next.tsx +49 -0
- package/src/components/KeyboardToolbar/compound/components/Prev.tsx +49 -0
- package/src/components/KeyboardToolbar/compound/components/index.ts +5 -0
- package/src/components/KeyboardToolbar/compound/components/types.ts +15 -0
- package/src/components/KeyboardToolbar/compound/context.ts +25 -0
- package/src/components/KeyboardToolbar/constants.ts +14 -0
- package/src/components/KeyboardToolbar/index.tsx +220 -223
- package/src/components/KeyboardToolbar/types.ts +72 -40
- package/src/components/ScrollViewWithBottomPadding/index.tsx +216 -0
- package/src/components/ScrollViewWithBottomPadding/styles.ts +10 -0
- package/src/components/hooks/useColorScheme.ts +6 -6
- package/src/components/hooks/useCombinedRef.ts +22 -0
- package/src/components/hooks/useScrollState.ts +81 -0
- package/src/components/index.ts +14 -11
- package/src/constants.ts +23 -19
- package/src/context.ts +70 -68
- package/src/hooks/index.ts +91 -90
- package/src/hooks/useKeyboardState/index.ts +52 -0
- package/src/hooks/useWindowDimensions/index.android.ts +38 -38
- package/src/hooks/useWindowDimensions/index.ts +1 -1
- package/src/index.ts +27 -23
- package/src/internal.ts +146 -84
- package/src/module.ts +64 -52
- package/src/reanimated.native.ts +132 -132
- package/src/reanimated.ts +29 -29
- package/src/specs/ClippingScrollViewDecoratorViewNativeComponent.ts +19 -0
- package/src/specs/KeyboardControllerViewNativeComponent.ts +82 -71
- package/src/specs/KeyboardGestureAreaNativeComponent.ts +21 -20
- package/src/specs/KeyboardToolbarGroupViewNativeComponent.ts +10 -0
- package/src/specs/NativeKeyboardController.ts +23 -19
- package/src/specs/NativeStatusBarManagerCompat.ts +14 -14
- package/src/specs/OverKeyboardViewNativeComponent.ts +12 -12
- package/src/types.ts +330 -243
- package/src/utils/findNodeHandle/index.native.ts +3 -0
- package/src/utils/findNodeHandle/index.ts +6 -0
- package/src/utils.ts +1 -1
- package/src/views/KeyboardExtender/index.tsx +30 -0
- package/src/views/OverKeyboardView/index.tsx +43 -43
- package/src/views/index.ts +2 -1
- package/lib/commonjs/monkey-patch.android.js +0 -57
- package/lib/commonjs/monkey-patch.android.js.map +0 -1
- package/lib/commonjs/monkey-patch.js +0 -11
- package/lib/commonjs/monkey-patch.js.map +0 -1
- package/lib/module/monkey-patch.android.js +0 -47
- package/lib/module/monkey-patch.android.js.map +0 -1
- package/lib/module/monkey-patch.js +0 -5
- package/lib/module/monkey-patch.js.map +0 -1
- package/lib/typescript/monkey-patch.android.d.ts +0 -2
- package/lib/typescript/monkey-patch.d.ts +0 -2
- package/src/monkey-patch.android.ts +0 -44
- package/src/monkey-patch.ts +0 -4
|
@@ -1,273 +1,465 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* MIT License
|
|
6
|
-
*
|
|
7
|
-
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
|
8
|
-
*
|
|
9
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
11
|
-
* in the Software without restriction, including without limitation the rights
|
|
12
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
14
|
-
* furnished to do so, subject to the following conditions:
|
|
15
|
-
*
|
|
16
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
17
|
-
* copies or substantial portions of the Software.
|
|
18
|
-
*
|
|
19
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
-
* SOFTWARE.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
import { TurboModule } from "@rnoh/react-native-openharmony/ts";
|
|
29
|
-
import common from '@ohos.app.ability.common';
|
|
30
|
-
import window from '@ohos.window';
|
|
31
|
-
import inputMethod from '@ohos.inputMethod';
|
|
32
|
-
import Logger from './Logger';
|
|
33
|
-
import { KeyboardControllerEventName, KeyboardStatusType } from './Type';
|
|
34
|
-
import { BusinessError } from '@kit.BasicServicesKit';
|
|
35
|
-
import { JSON } from '@kit.ArkTS';
|
|
36
|
-
import { ConfigurationConstant } from '@kit.AbilityKit';
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if (
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* MIT License
|
|
6
|
+
*
|
|
7
|
+
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
* in the Software without restriction, including without limitation the rights
|
|
12
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
* furnished to do so, subject to the following conditions:
|
|
15
|
+
*
|
|
16
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
* copies or substantial portions of the Software.
|
|
18
|
+
*
|
|
19
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
* SOFTWARE.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import { TurboModule } from "@rnoh/react-native-openharmony/ts";
|
|
29
|
+
import common from '@ohos.app.ability.common';
|
|
30
|
+
import window from '@ohos.window';
|
|
31
|
+
import inputMethod from '@ohos.inputMethod';
|
|
32
|
+
import Logger from './Logger';
|
|
33
|
+
import { KeyboardControllerEventName, KeyboardStatusType } from './Type';
|
|
34
|
+
import { BusinessError, deviceInfo } from '@kit.BasicServicesKit';
|
|
35
|
+
import { JSON } from '@kit.ArkTS';
|
|
36
|
+
import { ConfigurationConstant } from '@kit.AbilityKit';
|
|
37
|
+
import { KeyboardAvoidMode } from '@kit.ArkUI';
|
|
38
|
+
|
|
39
|
+
declare function px2vp(px: number): number;
|
|
40
|
+
|
|
41
|
+
const NATIVE_KEYBOARD_WILL_EVENT_MIN_API = 20;
|
|
42
|
+
const LEGACY_KEYBOARD_ANIMATION_DURATION = 150;
|
|
43
|
+
const WINDOW_SESSION_MANAGER = 'SystemCapability.Window.SessionManager';
|
|
44
|
+
|
|
45
|
+
interface KeyboardControllerConstants {
|
|
46
|
+
keyboardBorderRadius: number;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface RNKeyboardControllerSpec {
|
|
50
|
+
getConstants(): KeyboardControllerConstants;
|
|
51
|
+
|
|
52
|
+
setInputMode(mode: number): void;
|
|
53
|
+
|
|
54
|
+
setDefaultMode(): void;
|
|
55
|
+
|
|
56
|
+
preload(): void;
|
|
57
|
+
|
|
58
|
+
dismiss(keepFocus: boolean, animated: boolean): void;
|
|
59
|
+
|
|
60
|
+
setFocusTo(direction: string): void;
|
|
61
|
+
|
|
62
|
+
addListener(eventName: string, listener: (event) => void,): void;
|
|
63
|
+
|
|
64
|
+
removeListeners(count: number): void;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export class RNKeyboardControllerTurboModule extends TurboModule implements RNKeyboardControllerSpec {
|
|
68
|
+
private context: common.UIAbilityContext;
|
|
69
|
+
private keyboardHeight: number = 0;
|
|
70
|
+
private keyboardStatus: KeyboardStatusType = KeyboardStatusType.HIDE;
|
|
71
|
+
// RN removes listeners by count only; event-name filtering remains in the JS emitter.
|
|
72
|
+
private listenerCount: number = 0;
|
|
73
|
+
private currentWindow: window.Window | undefined = undefined;
|
|
74
|
+
private enabled: boolean = false;
|
|
75
|
+
private cleanUpCallbacks: (() => void)[] = [];
|
|
76
|
+
private previousKeyboardAvoidMode: KeyboardAvoidMode | undefined = undefined;
|
|
77
|
+
private keyboardAvoidModeControlled: boolean = false;
|
|
78
|
+
private supportsNativeWillEvents: boolean = false;
|
|
79
|
+
private keyboardHeightListenerRegistered: boolean = false;
|
|
80
|
+
private nativeWillShowListenerRegistered: boolean = false;
|
|
81
|
+
private nativeWillHideListenerRegistered: boolean = false;
|
|
82
|
+
private observerGeneration: number = 0;
|
|
83
|
+
private focusedInputTarget: number = -1;
|
|
84
|
+
private focusedInputKeyboardType: string = 'default';
|
|
85
|
+
private currentKeyboardAnimationDuration: number = 0;
|
|
86
|
+
|
|
87
|
+
private readonly keyboardHeightChangeHandler = (_data: number): void => {
|
|
88
|
+
if (!this.enabled || !this.currentWindow) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
const keyboardAvoidArea = this.currentWindow.getWindowAvoidArea(window.AvoidAreaType.TYPE_KEYBOARD).bottomRect;
|
|
93
|
+
const height = Math.ceil(px2vp(keyboardAvoidArea.height));
|
|
94
|
+
if (this.keyboardHeight === height) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const wasVisible = this.keyboardHeight > 0;
|
|
98
|
+
const isVisible = height > 0;
|
|
99
|
+
this.keyboardStatus = height > 0 ? KeyboardStatusType.SHOW : KeyboardStatusType.HIDE;
|
|
100
|
+
this.keyboardHeight = height;
|
|
101
|
+
if (wasVisible !== isVisible) {
|
|
102
|
+
this.keyboardControllerEventHandle(this.keyboardStatus, height);
|
|
103
|
+
}
|
|
104
|
+
this.ctx.rnInstance.postMessageToCpp('keyboardHeightChange', height);
|
|
105
|
+
} catch (exception) {
|
|
106
|
+
Logger.error('Failed to handle keyboard height change. Cause: ' + JSON.stringify(exception));
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
private readonly keyboardWillShowHandler = (info: window.KeyboardInfo): void => {
|
|
111
|
+
if (!this.enabled) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const duration = this.getKeyboardDurationFromKeyboardInfo(info);
|
|
115
|
+
this.currentKeyboardAnimationDuration = duration;
|
|
116
|
+
const height = Math.ceil(px2vp(info.endRect.height));
|
|
117
|
+
this.emitKeyboardEvent(KeyboardControllerEventName.KEYBOARD_WILL_SHOW, height, duration);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
private readonly keyboardWillHideHandler = (info: window.KeyboardInfo): void => {
|
|
121
|
+
if (!this.enabled) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const duration = this.getKeyboardDurationFromKeyboardInfo(info);
|
|
125
|
+
this.currentKeyboardAnimationDuration = duration;
|
|
126
|
+
this.emitKeyboardEvent(KeyboardControllerEventName.KEYBOARD_WILL_HIDE, 0, duration);
|
|
127
|
+
};
|
|
128
|
+
constructor(ctx) {
|
|
129
|
+
super(ctx);
|
|
130
|
+
this.context = this.ctx.uiAbilityContext;
|
|
131
|
+
// 订阅 C++ 层发来的 focusDidSet 消息
|
|
132
|
+
this.cleanUpCallbacks.push(
|
|
133
|
+
this.ctx.rnInstance.cppEventEmitter.subscribe("focusDidSet", (payload: { current: number, count: number }) => {
|
|
134
|
+
Logger.info('###turboModule received focusDidSet from cpp', String(payload.current) + ',' + String(payload.count));
|
|
135
|
+
if (this.listenerCount > 0) {
|
|
136
|
+
this.ctx.rnInstance.emitDeviceEvent(KeyboardControllerEventName.FOCUS_DID_SET, {
|
|
137
|
+
current: payload.current,
|
|
138
|
+
count: payload.count
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
})
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
this.cleanUpCallbacks.push(
|
|
145
|
+
this.ctx.rnInstance.cppEventEmitter.subscribe("layoutDidSynchronize", () => {
|
|
146
|
+
if (this.listenerCount > 0) {
|
|
147
|
+
this.ctx.rnInstance.emitDeviceEvent(
|
|
148
|
+
KeyboardControllerEventName.LAYOUT_DID_SYNCHRONIZE,
|
|
149
|
+
{},
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
})
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
this.cleanUpCallbacks.push(
|
|
156
|
+
this.ctx.rnInstance.cppEventEmitter.subscribe(
|
|
157
|
+
'focusedInputChanged',
|
|
158
|
+
(payload: { target: number, type: string }) => {
|
|
159
|
+
this.focusedInputTarget = payload.target;
|
|
160
|
+
this.focusedInputKeyboardType = payload.type;
|
|
161
|
+
}
|
|
162
|
+
)
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
getConstants(): KeyboardControllerConstants {
|
|
167
|
+
return { keyboardBorderRadius: 0 };
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// set mode
|
|
171
|
+
setInputMode(mode: number): void {
|
|
172
|
+
Logger.info('harmonyOS not support setInputMode')
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
setDefaultMode(): void {
|
|
176
|
+
Logger.info('harmonyOS not support setDefaultMode')
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
preload(): void {
|
|
180
|
+
// Harmony IME runs outside the app process, so there is no iOS-equivalent UI to preload.
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* @description 键盘隐藏
|
|
185
|
+
* */
|
|
186
|
+
dismiss(keepFocus: boolean, animated: boolean): void {
|
|
187
|
+
let inputMethodController = inputMethod.getController();
|
|
188
|
+
inputMethodController.stopInputSession()
|
|
189
|
+
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* @description 键盘隐藏
|
|
193
|
+
* */
|
|
194
|
+
private show(): void {
|
|
195
|
+
let inputMethodController = inputMethod.getController();
|
|
196
|
+
inputMethodController.showSoftKeyboard()
|
|
197
|
+
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
setFocusTo(direction: string): void {
|
|
201
|
+
this.ctx.rnInstance.postMessageToCpp('setFocusTo', direction);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* @description 添加监听键盘事件
|
|
206
|
+
*/
|
|
207
|
+
addListener(eventName: KeyboardControllerEventName) {
|
|
208
|
+
const supportEvents = this.supportListeners();
|
|
209
|
+
if (supportEvents.includes(eventName)) {
|
|
210
|
+
this.listenerCount += 1;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* @description 删除监听事件
|
|
216
|
+
* */
|
|
217
|
+
removeListeners(count: number): void {
|
|
218
|
+
if (count > 0) {
|
|
219
|
+
this.listenerCount = Math.max(0, this.listenerCount - count);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
private supportListeners() {
|
|
224
|
+
return [
|
|
225
|
+
KeyboardControllerEventName.KEYBOARD_WILL_SHOW,
|
|
226
|
+
KeyboardControllerEventName.KEYBOARD_DID_SHOW,
|
|
227
|
+
KeyboardControllerEventName.KEYBOARD_WILL_HIDE,
|
|
228
|
+
KeyboardControllerEventName.KEYBOARD_DID_HIDE,
|
|
229
|
+
KeyboardControllerEventName.FOCUS_DID_SET,
|
|
230
|
+
KeyboardControllerEventName.LAYOUT_DID_SYNCHRONIZE
|
|
231
|
+
];
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
private async setWindowSystemBarEnable(statusBarTranslucent: boolean, navigationBarTranslucent: boolean) {
|
|
235
|
+
|
|
236
|
+
let windowInstance: window.Window | undefined = undefined;
|
|
237
|
+
windowInstance = await window.getLastWindow(this.context);
|
|
238
|
+
let systemBarProperty = windowInstance.getWindowSystemBarProperties();
|
|
239
|
+
let newSystemBarProperty: window.SystemBarProperties = {
|
|
240
|
+
...systemBarProperty,
|
|
241
|
+
statusBarColor: statusBarTranslucent ? "#00000000" : systemBarProperty.statusBarColor,
|
|
242
|
+
navigationBarColor: navigationBarTranslucent ? "#00000000" : systemBarProperty.navigationBarColor
|
|
243
|
+
};
|
|
244
|
+
try {
|
|
245
|
+
let promise = windowInstance.setWindowSystemBarProperties(newSystemBarProperty);
|
|
246
|
+
promise.then(() => {
|
|
247
|
+
Logger.info('Succeeded in setting the system bar properties.');
|
|
248
|
+
}).catch((err: BusinessError) => {
|
|
249
|
+
Logger.error(`Failed to set the system bar properties. Cause code: ${err.code}, message: ${err.message}`);
|
|
250
|
+
});
|
|
251
|
+
} catch (exception) {
|
|
252
|
+
Logger.error(`Failed to set the system bar properties. Cause code: ${exception.code}, message: ${exception.message}`);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
private keyboardControllerEventHandle(keyboardStatus: number, height: number) {
|
|
257
|
+
if (!this.enabled) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
const legacyDuration = deviceInfo.sdkApiVersion < NATIVE_KEYBOARD_WILL_EVENT_MIN_API
|
|
262
|
+
? LEGACY_KEYBOARD_ANIMATION_DURATION
|
|
263
|
+
: 0;
|
|
264
|
+
const duration = this.supportsNativeWillEvents ? this.currentKeyboardAnimationDuration : legacyDuration;
|
|
265
|
+
if (keyboardStatus === KeyboardStatusType.HIDE) {
|
|
266
|
+
if (!this.supportsNativeWillEvents) {
|
|
267
|
+
this.emitKeyboardEvent(KeyboardControllerEventName.KEYBOARD_WILL_HIDE, 0, duration);
|
|
268
|
+
}
|
|
269
|
+
this.emitKeyboardEvent(KeyboardControllerEventName.KEYBOARD_DID_HIDE, 0, duration);
|
|
270
|
+
this.currentKeyboardAnimationDuration = 0;
|
|
271
|
+
}
|
|
272
|
+
if (keyboardStatus === KeyboardStatusType.SHOW) {
|
|
273
|
+
if (!this.supportsNativeWillEvents) {
|
|
274
|
+
this.emitKeyboardEvent(KeyboardControllerEventName.KEYBOARD_WILL_SHOW, height, duration);
|
|
275
|
+
}
|
|
276
|
+
this.emitKeyboardEvent(KeyboardControllerEventName.KEYBOARD_DID_SHOW, height, duration);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
private emitKeyboardEvent(eventName: KeyboardControllerEventName, height: number, duration: number): void {
|
|
281
|
+
if (!this.enabled || this.listenerCount <= 0) {
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
this.ctx.rnInstance.emitDeviceEvent(eventName, {
|
|
285
|
+
height,
|
|
286
|
+
tag: this.focusedInputTarget,
|
|
287
|
+
duration,
|
|
288
|
+
timestamp: new Date().getTime(),
|
|
289
|
+
target: this.focusedInputTarget,
|
|
290
|
+
type: this.focusedInputKeyboardType,
|
|
291
|
+
appearance: this.getKeyboardAppearance(),
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
private async startKeyboardObserver(
|
|
296
|
+
open: boolean,
|
|
297
|
+
disableSystemKeyboardAvoidance: boolean = false
|
|
298
|
+
): Promise<void> {
|
|
299
|
+
const generation = ++this.observerGeneration;
|
|
300
|
+
this.enabled = open;
|
|
301
|
+
if (!open) {
|
|
302
|
+
this.stopKeyboardObserver();
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
let currentWindow: window.Window;
|
|
307
|
+
try {
|
|
308
|
+
currentWindow = await window.getLastWindow(this.context);
|
|
309
|
+
} catch (exception) {
|
|
310
|
+
Logger.error('Failed to get the current window. Cause: ' + JSON.stringify(exception));
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
if (!this.enabled || generation !== this.observerGeneration) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
this.currentWindow = currentWindow;
|
|
318
|
+
this.setKeyboardAvoidModeEnabled(disableSystemKeyboardAvoidance);
|
|
319
|
+
this.supportsNativeWillEvents =
|
|
320
|
+
deviceInfo.sdkApiVersion >= NATIVE_KEYBOARD_WILL_EVENT_MIN_API &&
|
|
321
|
+
canIUse(WINDOW_SESSION_MANAGER);
|
|
322
|
+
this.registerKeyboardHeightListener();
|
|
323
|
+
this.registerNativeWillListeners();
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
private stopKeyboardObserver(): void {
|
|
327
|
+
this.unregisterNativeWillListeners();
|
|
328
|
+
if (this.currentWindow && this.keyboardHeightListenerRegistered) {
|
|
329
|
+
try {
|
|
330
|
+
this.currentWindow.off('keyboardHeightChange', this.keyboardHeightChangeHandler);
|
|
331
|
+
} catch (exception) {
|
|
332
|
+
Logger.error('Failed to close keyboardHeightChange. Cause: ' + JSON.stringify(exception));
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
this.keyboardHeightListenerRegistered = false;
|
|
336
|
+
this.setKeyboardAvoidModeEnabled(false);
|
|
337
|
+
this.currentWindow = undefined;
|
|
338
|
+
this.keyboardHeight = 0;
|
|
339
|
+
this.keyboardStatus = KeyboardStatusType.HIDE;
|
|
340
|
+
this.currentKeyboardAnimationDuration = 0;
|
|
341
|
+
this.supportsNativeWillEvents = false;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
private registerKeyboardHeightListener(): void {
|
|
345
|
+
if (!this.currentWindow || this.keyboardHeightListenerRegistered) {
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
try {
|
|
349
|
+
this.currentWindow.on('keyboardHeightChange', this.keyboardHeightChangeHandler);
|
|
350
|
+
this.keyboardHeightListenerRegistered = true;
|
|
351
|
+
} catch (exception) {
|
|
352
|
+
Logger.error('Failed to enable keyboardHeightChange. Cause: ' + JSON.stringify(exception));
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
private registerNativeWillListeners(): void {
|
|
357
|
+
if (!this.currentWindow || !this.supportsNativeWillEvents ||
|
|
358
|
+
this.nativeWillShowListenerRegistered || this.nativeWillHideListenerRegistered) {
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
try {
|
|
363
|
+
this.currentWindow.on('keyboardWillShow', this.keyboardWillShowHandler);
|
|
364
|
+
this.nativeWillShowListenerRegistered = true;
|
|
365
|
+
this.currentWindow.on('keyboardWillHide', this.keyboardWillHideHandler);
|
|
366
|
+
this.nativeWillHideListenerRegistered = true;
|
|
367
|
+
} catch (exception) {
|
|
368
|
+
this.unregisterNativeWillListeners();
|
|
369
|
+
this.supportsNativeWillEvents = false;
|
|
370
|
+
Logger.error('Native keyboard will events unavailable; using confirmed-state fallback. Cause: ' +
|
|
371
|
+
JSON.stringify(exception));
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
private unregisterNativeWillListeners(): void {
|
|
376
|
+
if (!this.currentWindow) {
|
|
377
|
+
this.nativeWillShowListenerRegistered = false;
|
|
378
|
+
this.nativeWillHideListenerRegistered = false;
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
if (this.nativeWillShowListenerRegistered) {
|
|
382
|
+
try {
|
|
383
|
+
this.currentWindow.off('keyboardWillShow', this.keyboardWillShowHandler);
|
|
384
|
+
} catch (exception) {
|
|
385
|
+
Logger.error('Failed to close keyboardWillShow. Cause: ' + JSON.stringify(exception));
|
|
386
|
+
}
|
|
387
|
+
this.nativeWillShowListenerRegistered = false;
|
|
388
|
+
}
|
|
389
|
+
if (this.nativeWillHideListenerRegistered) {
|
|
390
|
+
try {
|
|
391
|
+
this.currentWindow.off('keyboardWillHide', this.keyboardWillHideHandler);
|
|
392
|
+
} catch (exception) {
|
|
393
|
+
Logger.error('Failed to close keyboardWillHide. Cause: ' + JSON.stringify(exception));
|
|
394
|
+
}
|
|
395
|
+
this.nativeWillHideListenerRegistered = false;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
private getKeyboardDurationFromKeyboardInfo(info: window.KeyboardInfo): number {
|
|
400
|
+
if (info.animated === false) {
|
|
401
|
+
return 0;
|
|
402
|
+
}
|
|
403
|
+
const duration = info.config?.duration;
|
|
404
|
+
return typeof duration === 'number' && duration >= 0 ? duration : 0;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
__onDestroy__(): void {
|
|
408
|
+
this.enabled = false;
|
|
409
|
+
++this.observerGeneration;
|
|
410
|
+
this.stopKeyboardObserver();
|
|
411
|
+
this.cleanUpCallbacks.forEach((callback) => callback());
|
|
412
|
+
this.cleanUpCallbacks = [];
|
|
413
|
+
super.__onDestroy__();
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
private setKeyboardAvoidModeEnabled(enabled: boolean): void {
|
|
417
|
+
if (!this.currentWindow) {
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
try {
|
|
421
|
+
const uiContext = this.currentWindow.getUIContext();
|
|
422
|
+
if (enabled) {
|
|
423
|
+
if (!this.keyboardAvoidModeControlled) {
|
|
424
|
+
this.previousKeyboardAvoidMode = uiContext.getKeyboardAvoidMode();
|
|
425
|
+
this.keyboardAvoidModeControlled = true;
|
|
426
|
+
}
|
|
427
|
+
uiContext.setKeyboardAvoidMode(KeyboardAvoidMode.NONE);
|
|
428
|
+
} else if (this.keyboardAvoidModeControlled) {
|
|
429
|
+
if (this.previousKeyboardAvoidMode !== undefined) {
|
|
430
|
+
uiContext.setKeyboardAvoidMode(this.previousKeyboardAvoidMode);
|
|
431
|
+
}
|
|
432
|
+
this.previousKeyboardAvoidMode = undefined;
|
|
433
|
+
this.keyboardAvoidModeControlled = false;
|
|
434
|
+
}
|
|
435
|
+
} catch (exception) {
|
|
436
|
+
Logger.error('Failed to update KeyboardAvoidMode. Cause: ' + JSON.stringify(exception));
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
private getKeyboardAppearance(): string {
|
|
441
|
+
const colorMode = this.context.config.colorMode;
|
|
442
|
+
if (colorMode == ConfigurationConstant.ColorMode.COLOR_MODE_DARK) {
|
|
443
|
+
return "dark";
|
|
444
|
+
}
|
|
445
|
+
else if (colorMode == ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT) {
|
|
446
|
+
return "light";
|
|
447
|
+
}
|
|
448
|
+
return "default";
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
private async setWindowLayoutFullScreen(preserveEdgeToEdge:boolean){
|
|
452
|
+
let windowInstance: window.Window | undefined = undefined;
|
|
453
|
+
windowInstance = await window.getLastWindow(this.context);
|
|
454
|
+
try {
|
|
455
|
+
let promise = windowInstance.setWindowLayoutFullScreen(preserveEdgeToEdge);
|
|
456
|
+
promise.then(() => {
|
|
457
|
+
Logger.info('Succeeded in setWindowLayoutFullScreen .' + preserveEdgeToEdge);
|
|
458
|
+
}).catch((err: BusinessError) => {
|
|
459
|
+
Logger.error(`Failed to setWindowLayoutFullScreen. Cause code: ${err.code}, message: ${err.message}`);
|
|
460
|
+
});
|
|
461
|
+
} catch (exception) {
|
|
462
|
+
Logger.error(`Failed to setWindowLayoutFullScreen. Cause code: ${exception.code}, message: ${exception.message}`);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
}
|