@react-native-ohos/react-native-keyboard-controller 1.17.0-beta.2 → 1.17.1-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.
- 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 +852 -288
- package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewComponentInstance.h +170 -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 +90 -56
- 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 +92 -58
- 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 +443 -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,389 +1,443 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} from "
|
|
18
|
-
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
import
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
const
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const
|
|
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
|
-
const
|
|
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
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
//
|
|
364
|
-
// this
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
1
|
+
import React, {
|
|
2
|
+
forwardRef,
|
|
3
|
+
useCallback,
|
|
4
|
+
useEffect,
|
|
5
|
+
useImperativeHandle,
|
|
6
|
+
useMemo,
|
|
7
|
+
} from "react";
|
|
8
|
+
import Reanimated, {
|
|
9
|
+
interpolate,
|
|
10
|
+
runOnUI,
|
|
11
|
+
scrollTo,
|
|
12
|
+
useAnimatedReaction,
|
|
13
|
+
useAnimatedRef,
|
|
14
|
+
useAnimatedStyle,
|
|
15
|
+
useScrollViewOffset,
|
|
16
|
+
useSharedValue,
|
|
17
|
+
} from "react-native-reanimated";
|
|
18
|
+
|
|
19
|
+
import { KeyboardControllerNative } from "../../bindings";
|
|
20
|
+
import {
|
|
21
|
+
useFocusedInputHandler,
|
|
22
|
+
useReanimatedFocusedInput,
|
|
23
|
+
useWindowDimensions,
|
|
24
|
+
} from "../../hooks";
|
|
25
|
+
import { findNodeHandle } from "../../utils/findNodeHandle";
|
|
26
|
+
|
|
27
|
+
import { useSmoothKeyboardHandler } from "./useSmoothKeyboardHandler";
|
|
28
|
+
import { debounce, scrollDistanceWithRespectToSnapPoints } from "./utils";
|
|
29
|
+
|
|
30
|
+
import type {
|
|
31
|
+
LayoutChangeEvent,
|
|
32
|
+
ScrollView,
|
|
33
|
+
ScrollViewProps,
|
|
34
|
+
} from "react-native";
|
|
35
|
+
import type {
|
|
36
|
+
FocusedInputLayoutChangedEvent,
|
|
37
|
+
FocusedInputSelectionChangedEvent,
|
|
38
|
+
NativeEvent,
|
|
39
|
+
} from "..//../types";
|
|
40
|
+
|
|
41
|
+
export type KeyboardAwareScrollViewProps = {
|
|
42
|
+
/** The distance between keyboard and focused `TextInput` when keyboard is shown. Default is `0`. */
|
|
43
|
+
bottomOffset?: number;
|
|
44
|
+
/** Prevents automatic scrolling of the `ScrollView` when the keyboard gets hidden, maintaining the current screen position. Default is `false`. */
|
|
45
|
+
disableScrollOnKeyboardHide?: boolean;
|
|
46
|
+
/** Controls whether this `KeyboardAwareScrollView` instance should take effect. Default is `true` */
|
|
47
|
+
enabled?: boolean;
|
|
48
|
+
/** Adjusting the bottom spacing of KeyboardAwareScrollView. Default is `0` */
|
|
49
|
+
extraKeyboardSpace?: number;
|
|
50
|
+
/** Custom component for `ScrollView`. Default is `ScrollView` */
|
|
51
|
+
ScrollViewComponent?: React.ComponentType<ScrollViewProps>;
|
|
52
|
+
} & ScrollViewProps;
|
|
53
|
+
|
|
54
|
+
export type KeyboardAwareScrollViewRef = ScrollView & {
|
|
55
|
+
assureFocusedInputVisible: () => void;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/*
|
|
59
|
+
* Everything begins from `onStart` handler. This handler is called every time,
|
|
60
|
+
* when keyboard changes its size or when focused `TextInput` was changed. In
|
|
61
|
+
* this handler we are calculating/memoizing values which later will be used
|
|
62
|
+
* during layout movement. For that we calculate:
|
|
63
|
+
* - layout of focused field (`layout`) - to understand whether there will be overlap
|
|
64
|
+
* - initial keyboard size (`initialKeyboardSize`) - used in scroll interpolation
|
|
65
|
+
* - future keyboard height (`keyboardHeight`) - used in scroll interpolation
|
|
66
|
+
* - current scroll position (`scrollPosition`) - used to scroll from this point
|
|
67
|
+
*
|
|
68
|
+
* Once we've calculated all necessary variables - we can actually start to use them.
|
|
69
|
+
* It happens in `onMove` handler - this function simply calls `maybeScroll` with
|
|
70
|
+
* current keyboard frame height. This functions makes the smooth transition.
|
|
71
|
+
*
|
|
72
|
+
* When the transition has finished we go to `onEnd` handler. In this handler
|
|
73
|
+
* we verify, that the current field is not overlapped within a keyboard frame.
|
|
74
|
+
* For full `onStart`/`onMove`/`onEnd` flow it may look like a redundant thing,
|
|
75
|
+
* however there could be some cases, when `onMove` is not called:
|
|
76
|
+
* - on iOS when TextInput was changed - keyboard transition is instant
|
|
77
|
+
* - on Android when TextInput was changed and keyboard size wasn't changed
|
|
78
|
+
* So `onEnd` handler handle the case, when `onMove` wasn't triggered.
|
|
79
|
+
*
|
|
80
|
+
* ====================================================================================================================+
|
|
81
|
+
* -----------------------------------------------------Flow chart-----------------------------------------------------+
|
|
82
|
+
* ====================================================================================================================+
|
|
83
|
+
*
|
|
84
|
+
* +============================+ +============================+ +==================================+
|
|
85
|
+
* + User Press on TextInput + => + Keyboard starts showing + => + As keyboard moves frame by frame + =>
|
|
86
|
+
* + + + (run `onStart`) + + `onMove` is getting called +
|
|
87
|
+
* +============================+ +============================+ +==================================+
|
|
88
|
+
*
|
|
89
|
+
*
|
|
90
|
+
* +============================+ +============================+ +=====================================+
|
|
91
|
+
* + Keyboard is shown and we + => + User moved focus to + => + Only `onStart`/`onEnd` maybe called +
|
|
92
|
+
* + call `onEnd` handler + + another `TextInput` + + (without involving `onMove`) +
|
|
93
|
+
* +============================+ +============================+ +=====================================+
|
|
94
|
+
*
|
|
95
|
+
*/
|
|
96
|
+
const KeyboardAwareScrollView = forwardRef<
|
|
97
|
+
KeyboardAwareScrollViewRef,
|
|
98
|
+
React.PropsWithChildren<KeyboardAwareScrollViewProps>
|
|
99
|
+
>(
|
|
100
|
+
(
|
|
101
|
+
{
|
|
102
|
+
children,
|
|
103
|
+
onLayout,
|
|
104
|
+
bottomOffset = 0,
|
|
105
|
+
disableScrollOnKeyboardHide = false,
|
|
106
|
+
enabled = true,
|
|
107
|
+
extraKeyboardSpace = 0,
|
|
108
|
+
ScrollViewComponent = Reanimated.ScrollView,
|
|
109
|
+
...rest
|
|
110
|
+
},
|
|
111
|
+
ref,
|
|
112
|
+
) => {
|
|
113
|
+
const scrollViewAnimatedRef = useAnimatedRef<Reanimated.ScrollView>();
|
|
114
|
+
const scrollViewTarget = useSharedValue<number | null>(null);
|
|
115
|
+
const scrollPosition = useSharedValue(0);
|
|
116
|
+
const position = useScrollViewOffset(scrollViewAnimatedRef);
|
|
117
|
+
const currentKeyboardFrameHeight = useSharedValue(0);
|
|
118
|
+
const keyboardHeight = useSharedValue(0);
|
|
119
|
+
const keyboardWillAppear = useSharedValue(false);
|
|
120
|
+
const tag = useSharedValue(-1);
|
|
121
|
+
const initialKeyboardSize = useSharedValue(0);
|
|
122
|
+
const scrollBeforeKeyboardMovement = useSharedValue(0);
|
|
123
|
+
const { input } = useReanimatedFocusedInput();
|
|
124
|
+
const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);
|
|
125
|
+
const scrollViewPageY = useSharedValue(0);
|
|
126
|
+
|
|
127
|
+
const { height } = useWindowDimensions();
|
|
128
|
+
|
|
129
|
+
const onRef = useCallback((assignedRef: Reanimated.ScrollView) => {
|
|
130
|
+
scrollViewAnimatedRef(assignedRef);
|
|
131
|
+
}, []);
|
|
132
|
+
const onScrollViewLayout = useCallback(
|
|
133
|
+
async (e: LayoutChangeEvent) => {
|
|
134
|
+
const handle = findNodeHandle(scrollViewAnimatedRef.current);
|
|
135
|
+
|
|
136
|
+
scrollViewTarget.value = handle;
|
|
137
|
+
|
|
138
|
+
onLayout?.(e);
|
|
139
|
+
|
|
140
|
+
if (handle !== null) {
|
|
141
|
+
try {
|
|
142
|
+
const { y } =
|
|
143
|
+
await KeyboardControllerNative.viewPositionInWindow(handle);
|
|
144
|
+
|
|
145
|
+
scrollViewPageY.value = y;
|
|
146
|
+
} catch {
|
|
147
|
+
// Keep the previous top boundary when the view is not mounted yet.
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
[onLayout],
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Function that will scroll a ScrollView as keyboard gets moving
|
|
156
|
+
*/
|
|
157
|
+
const maybeScroll = useCallback(
|
|
158
|
+
(e: number, animated: boolean = false) => {
|
|
159
|
+
"worklet";
|
|
160
|
+
|
|
161
|
+
if (!enabled) {
|
|
162
|
+
return 0;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// input belongs to ScrollView
|
|
166
|
+
if (layout.value?.parentScrollViewTarget !== scrollViewTarget.value) {
|
|
167
|
+
return 0;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const visibleRect = height - keyboardHeight.value;
|
|
171
|
+
const absoluteY = layout.value?.layout.absoluteY || 0;
|
|
172
|
+
const inputHeight = layout.value?.layout.height || 0;
|
|
173
|
+
const point = absoluteY + inputHeight;
|
|
174
|
+
|
|
175
|
+
if (visibleRect - point <= bottomOffset) {
|
|
176
|
+
const relativeScrollTo =
|
|
177
|
+
keyboardHeight.value - (height - point) + bottomOffset;
|
|
178
|
+
const interpolatedScrollTo = interpolate(
|
|
179
|
+
e,
|
|
180
|
+
[initialKeyboardSize.value, keyboardHeight.value],
|
|
181
|
+
[
|
|
182
|
+
0,
|
|
183
|
+
scrollDistanceWithRespectToSnapPoints(
|
|
184
|
+
relativeScrollTo + scrollPosition.value,
|
|
185
|
+
rest.snapToOffsets,
|
|
186
|
+
) - scrollPosition.value,
|
|
187
|
+
],
|
|
188
|
+
);
|
|
189
|
+
const targetScrollY =
|
|
190
|
+
Math.max(interpolatedScrollTo, 0) + scrollPosition.value;
|
|
191
|
+
scrollTo(scrollViewAnimatedRef, 0, targetScrollY, animated);
|
|
192
|
+
|
|
193
|
+
return interpolatedScrollTo;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (point < scrollViewPageY.value) {
|
|
197
|
+
const positionOnScreen = visibleRect - bottomOffset;
|
|
198
|
+
const topOfScreen = scrollPosition.value + point;
|
|
199
|
+
|
|
200
|
+
scrollTo(
|
|
201
|
+
scrollViewAnimatedRef,
|
|
202
|
+
0,
|
|
203
|
+
topOfScreen - positionOnScreen,
|
|
204
|
+
animated,
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return 0;
|
|
209
|
+
},
|
|
210
|
+
[bottomOffset, enabled, height, rest.snapToOffsets],
|
|
211
|
+
);
|
|
212
|
+
const performScrollWithPositionRestoration = useCallback(
|
|
213
|
+
(newPosition: number) => {
|
|
214
|
+
"worklet";
|
|
215
|
+
|
|
216
|
+
const prevScrollPosition = scrollPosition.value;
|
|
217
|
+
|
|
218
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
219
|
+
scrollPosition.value = newPosition;
|
|
220
|
+
maybeScroll(keyboardHeight.value, true);
|
|
221
|
+
scrollPosition.value = prevScrollPosition;
|
|
222
|
+
},
|
|
223
|
+
[maybeScroll],
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
useEffect(() => {
|
|
227
|
+
// Recalculate from the pre-keyboard position to avoid accumulating an already applied offset.
|
|
228
|
+
runOnUI(performScrollWithPositionRestoration)(
|
|
229
|
+
scrollBeforeKeyboardMovement.value,
|
|
230
|
+
);
|
|
231
|
+
}, [bottomOffset]);
|
|
232
|
+
|
|
233
|
+
const syncKeyboardFrame = useCallback(
|
|
234
|
+
(e: NativeEvent) => {
|
|
235
|
+
"worklet";
|
|
236
|
+
|
|
237
|
+
const keyboardFrame = interpolate(
|
|
238
|
+
e.height,
|
|
239
|
+
[0, keyboardHeight.value],
|
|
240
|
+
[0, keyboardHeight.value + extraKeyboardSpace],
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
currentKeyboardFrameHeight.value = keyboardFrame;
|
|
244
|
+
},
|
|
245
|
+
[extraKeyboardSpace],
|
|
246
|
+
);
|
|
247
|
+
|
|
248
|
+
const scrollFromCurrentPosition = useCallback(
|
|
249
|
+
(customHeight?: number) => {
|
|
250
|
+
"worklet";
|
|
251
|
+
|
|
252
|
+
const prevLayout = layout.value;
|
|
253
|
+
|
|
254
|
+
if (!input.value?.layout) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
259
|
+
layout.value = {
|
|
260
|
+
...input.value,
|
|
261
|
+
layout: {
|
|
262
|
+
...input.value.layout,
|
|
263
|
+
height: customHeight ?? input.value.layout.height,
|
|
264
|
+
},
|
|
265
|
+
};
|
|
266
|
+
performScrollWithPositionRestoration(position.value);
|
|
267
|
+
layout.value = prevLayout;
|
|
268
|
+
},
|
|
269
|
+
[performScrollWithPositionRestoration],
|
|
270
|
+
);
|
|
271
|
+
const assureFocusedInputVisible = useCallback(() => {
|
|
272
|
+
runOnUI(scrollFromCurrentPosition)();
|
|
273
|
+
}, [scrollFromCurrentPosition]);
|
|
274
|
+
|
|
275
|
+
useImperativeHandle(
|
|
276
|
+
ref,
|
|
277
|
+
() => {
|
|
278
|
+
const current = scrollViewAnimatedRef.current;
|
|
279
|
+
if (current) {
|
|
280
|
+
Object.assign(current, { assureFocusedInputVisible });
|
|
281
|
+
return current as unknown as KeyboardAwareScrollViewRef;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return { assureFocusedInputVisible } as KeyboardAwareScrollViewRef;
|
|
285
|
+
},
|
|
286
|
+
[assureFocusedInputVisible],
|
|
287
|
+
);
|
|
288
|
+
const onChangeText = useCallback(() => {
|
|
289
|
+
"worklet";
|
|
290
|
+
|
|
291
|
+
// if typing a text caused layout shift, then we need to ignore this handler
|
|
292
|
+
// because this event will be handled in `useAnimatedReaction` below
|
|
293
|
+
if (layout.value?.layout.height !== input.value?.layout.height) {
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
scrollFromCurrentPosition();
|
|
298
|
+
}, [scrollFromCurrentPosition]);
|
|
299
|
+
const onSelectionChange = useCallback(
|
|
300
|
+
(e: FocusedInputSelectionChangedEvent) => {
|
|
301
|
+
"worklet";
|
|
302
|
+
|
|
303
|
+
if (e.selection.start.position !== e.selection.end.position) {
|
|
304
|
+
scrollFromCurrentPosition(e.selection.end.y);
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
[scrollFromCurrentPosition],
|
|
308
|
+
);
|
|
309
|
+
|
|
310
|
+
const onChangeTextHandler = useMemo(
|
|
311
|
+
() => debounce(onChangeText, 200),
|
|
312
|
+
[onChangeText],
|
|
313
|
+
);
|
|
314
|
+
|
|
315
|
+
useFocusedInputHandler(
|
|
316
|
+
{
|
|
317
|
+
onChangeText: onChangeTextHandler,
|
|
318
|
+
onSelectionChange: onSelectionChange,
|
|
319
|
+
},
|
|
320
|
+
[onChangeTextHandler, onSelectionChange],
|
|
321
|
+
);
|
|
322
|
+
|
|
323
|
+
useSmoothKeyboardHandler(
|
|
324
|
+
{
|
|
325
|
+
onStart: (e) => {
|
|
326
|
+
"worklet";
|
|
327
|
+
|
|
328
|
+
const keyboardWillChangeSize =
|
|
329
|
+
keyboardHeight.value !== e.height && e.height > 0;
|
|
330
|
+
keyboardWillAppear.value = e.height > 0 && keyboardHeight.value === 0;
|
|
331
|
+
const keyboardWillHide = e.height === 0;
|
|
332
|
+
const focusWasChanged =
|
|
333
|
+
(tag.value !== e.target && e.target !== -1) ||
|
|
334
|
+
keyboardWillChangeSize;
|
|
335
|
+
|
|
336
|
+
if (keyboardWillChangeSize) {
|
|
337
|
+
initialKeyboardSize.value = keyboardHeight.value;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
if (keyboardWillHide) {
|
|
341
|
+
// on back transition need to interpolate as [0, keyboardHeight]
|
|
342
|
+
initialKeyboardSize.value = 0;
|
|
343
|
+
scrollPosition.value = scrollBeforeKeyboardMovement.value;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
if (
|
|
347
|
+
keyboardWillAppear.value ||
|
|
348
|
+
keyboardWillChangeSize ||
|
|
349
|
+
focusWasChanged
|
|
350
|
+
) {
|
|
351
|
+
// persist scroll value
|
|
352
|
+
scrollPosition.value = position.value;
|
|
353
|
+
// just persist height - later will be used in interpolation
|
|
354
|
+
keyboardHeight.value = e.height;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// focus was changed
|
|
358
|
+
if (focusWasChanged) {
|
|
359
|
+
tag.value = e.target;
|
|
360
|
+
|
|
361
|
+
// save position of focused text input when keyboard starts to move
|
|
362
|
+
layout.value = input.value;
|
|
363
|
+
// save current scroll position - when keyboard will hide we'll reuse
|
|
364
|
+
// this value to achieve smooth hide effect
|
|
365
|
+
scrollBeforeKeyboardMovement.value = position.value;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
if (focusWasChanged && !keyboardWillAppear.value) {
|
|
369
|
+
// update position on scroll value, so `onEnd` handler
|
|
370
|
+
// will pick up correct values
|
|
371
|
+
position.value += maybeScroll(e.height, true);
|
|
372
|
+
}
|
|
373
|
+
},
|
|
374
|
+
onMove: (e) => {
|
|
375
|
+
"worklet";
|
|
376
|
+
|
|
377
|
+
syncKeyboardFrame(e);
|
|
378
|
+
|
|
379
|
+
// if the user has set disableScrollOnKeyboardHide, only auto-scroll when the keyboard opens
|
|
380
|
+
if (!disableScrollOnKeyboardHide || keyboardWillAppear.value) {
|
|
381
|
+
maybeScroll(e.height);
|
|
382
|
+
}
|
|
383
|
+
},
|
|
384
|
+
onEnd: (e) => {
|
|
385
|
+
"worklet";
|
|
386
|
+
|
|
387
|
+
keyboardHeight.value = e.height;
|
|
388
|
+
scrollPosition.value = position.value;
|
|
389
|
+
|
|
390
|
+
syncKeyboardFrame(e);
|
|
391
|
+
},
|
|
392
|
+
},
|
|
393
|
+
[maybeScroll, disableScrollOnKeyboardHide, syncKeyboardFrame],
|
|
394
|
+
);
|
|
395
|
+
|
|
396
|
+
useAnimatedReaction(
|
|
397
|
+
() => input.value,
|
|
398
|
+
(current, previous) => {
|
|
399
|
+
if (
|
|
400
|
+
current?.target === previous?.target &&
|
|
401
|
+
current?.layout.height !== previous?.layout.height
|
|
402
|
+
) {
|
|
403
|
+
const prevLayout = layout.value;
|
|
404
|
+
|
|
405
|
+
layout.value = input.value;
|
|
406
|
+
scrollPosition.value += maybeScroll(keyboardHeight.value, true);
|
|
407
|
+
layout.value = prevLayout;
|
|
408
|
+
}
|
|
409
|
+
},
|
|
410
|
+
[],
|
|
411
|
+
);
|
|
412
|
+
|
|
413
|
+
const view = useAnimatedStyle(
|
|
414
|
+
() =>
|
|
415
|
+
enabled
|
|
416
|
+
? {
|
|
417
|
+
// animations become choppy when scrolling to the end of the `ScrollView` (when the last input is focused)
|
|
418
|
+
// this happens because the layout recalculates on every frame. To avoid this we slightly increase padding
|
|
419
|
+
// by `+1`. In this way we assure, that `scrollTo` will never scroll to the end, because it uses interpolation
|
|
420
|
+
// from 0 to `keyboardHeight`, and here our padding is `keyboardHeight + 1`. It allows us not to re-run layout
|
|
421
|
+
// re-calculation on every animation frame and it helps to achieve smooth animation.
|
|
422
|
+
// see: https://github.com/kirillzyusko/react-native-keyboard-controller/pull/342
|
|
423
|
+
paddingBottom: currentKeyboardFrameHeight.value + 1,
|
|
424
|
+
}
|
|
425
|
+
: {},
|
|
426
|
+
[enabled],
|
|
427
|
+
);
|
|
428
|
+
|
|
429
|
+
return (
|
|
430
|
+
<ScrollViewComponent
|
|
431
|
+
ref={onRef}
|
|
432
|
+
{...rest}
|
|
433
|
+
onLayout={onScrollViewLayout}
|
|
434
|
+
scrollEventThrottle={16}
|
|
435
|
+
>
|
|
436
|
+
{children}
|
|
437
|
+
{enabled && <Reanimated.View style={view} />}
|
|
438
|
+
</ScrollViewComponent>
|
|
439
|
+
);
|
|
440
|
+
},
|
|
441
|
+
);
|
|
442
|
+
|
|
443
|
+
export default KeyboardAwareScrollView;
|