react-native-keyboard-controller 1.12.7 → 1.13.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/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardGestureAreaViewManager.kt +5 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/ReactContext.kt +13 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/ThemedReactContext.kt +0 -10
- package/android/src/main/java/com/reactnativekeyboardcontroller/interactive/interpolators/Interpolator.kt +2 -1
- package/android/src/main/java/com/reactnativekeyboardcontroller/interactive/interpolators/IosInterpolator.kt +2 -1
- package/android/src/main/java/com/reactnativekeyboardcontroller/interactive/interpolators/LinearInterpolator.kt +1 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/FocusedInputObserver.kt +13 -8
- package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt +71 -59
- package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardGestureAreaViewManagerImpl.kt +4 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/modal/ModalAttachedWatcher.kt +80 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/modules/StatusBarManagerCompatModuleImpl.kt +6 -12
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/EdgeToEdgeReactViewGroup.kt +47 -13
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/KeyboardGestureAreaReactViewGroup.kt +7 -0
- package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardGestureAreaViewManager.kt +5 -0
- package/ios/extensions/UIView.swift +10 -0
- package/ios/observers/KeyboardMovementObserver.swift +7 -5
- package/ios/views/KeyboardControllerView.mm +30 -39
- package/lib/commonjs/animated.js +15 -30
- package/lib/commonjs/animated.js.map +1 -1
- package/lib/commonjs/bindings.js.map +1 -1
- package/lib/commonjs/bindings.native.js.map +1 -1
- package/lib/commonjs/components/KeyboardAvoidingView/hooks.js +2 -14
- package/lib/commonjs/components/KeyboardAvoidingView/hooks.js.map +1 -1
- package/lib/commonjs/components/KeyboardAvoidingView/index.js +4 -4
- package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js +7 -6
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/utils.js.map +1 -1
- package/lib/commonjs/components/KeyboardStickyView/index.js +2 -2
- package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/Arrow.js +2 -2
- package/lib/commonjs/components/KeyboardToolbar/Arrow.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/Button.js +12 -12
- package/lib/commonjs/components/KeyboardToolbar/Button.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/index.js +33 -27
- package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -1
- package/lib/commonjs/components/index.js +2 -2
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/context.js +3 -2
- package/lib/commonjs/context.js.map +1 -1
- package/lib/commonjs/event-handler.d.js +6 -0
- package/lib/commonjs/event-handler.d.js.map +1 -0
- package/lib/commonjs/event-handler.js +19 -0
- package/lib/commonjs/event-handler.js.map +1 -0
- package/lib/commonjs/event-handler.web.js +10 -0
- package/lib/commonjs/event-handler.web.js.map +1 -0
- package/lib/commonjs/event-mappings.js +9 -0
- package/lib/commonjs/event-mappings.js.map +1 -0
- package/lib/commonjs/hooks/index.js +8 -21
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useSyncEffect/index.js +37 -0
- package/lib/commonjs/hooks/useSyncEffect/index.js.map +1 -0
- package/lib/commonjs/internal.js +20 -44
- package/lib/commonjs/internal.js.map +1 -1
- package/lib/commonjs/monkey-patch.android.js +1 -1
- package/lib/commonjs/monkey-patch.android.js.map +1 -1
- package/lib/commonjs/monkey-patch.js.map +1 -1
- package/lib/commonjs/reanimated.js +1 -3
- package/lib/commonjs/reanimated.js.map +1 -1
- package/lib/commonjs/reanimated.native.js +1 -35
- package/lib/commonjs/reanimated.native.js.map +1 -1
- package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js +1 -1
- package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
- package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js +1 -1
- package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/animated.js +16 -32
- package/lib/module/animated.js.map +1 -1
- package/lib/module/bindings.js.map +1 -1
- package/lib/module/bindings.native.js.map +1 -1
- package/lib/module/components/KeyboardAvoidingView/hooks.js +2 -14
- package/lib/module/components/KeyboardAvoidingView/hooks.js.map +1 -1
- package/lib/module/components/KeyboardAvoidingView/index.js +3 -3
- package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/index.js +6 -5
- package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/utils.js.map +1 -1
- package/lib/module/components/KeyboardStickyView/index.js +1 -1
- package/lib/module/components/KeyboardToolbar/Button.js +10 -10
- package/lib/module/components/KeyboardToolbar/Button.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/index.js +31 -25
- package/lib/module/components/KeyboardToolbar/index.js.map +1 -1
- package/lib/module/context.js +3 -2
- package/lib/module/context.js.map +1 -1
- package/lib/module/event-handler.d.js +2 -0
- package/lib/module/event-handler.d.js.map +1 -0
- package/lib/module/event-handler.js +14 -0
- package/lib/module/event-handler.js.map +1 -0
- package/lib/module/event-handler.web.js +5 -0
- package/lib/module/event-handler.web.js.map +1 -0
- package/lib/module/event-mappings.js +3 -0
- package/lib/module/event-mappings.js.map +1 -0
- package/lib/module/hooks/index.js +7 -21
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useSyncEffect/index.js +31 -0
- package/lib/module/hooks/useSyncEffect/index.js.map +1 -0
- package/lib/module/internal.js +21 -45
- package/lib/module/internal.js.map +1 -1
- package/lib/module/monkey-patch.js.map +1 -1
- package/lib/module/reanimated.js +0 -2
- package/lib/module/reanimated.js.map +1 -1
- package/lib/module/reanimated.native.js +0 -32
- package/lib/module/reanimated.native.js.map +1 -1
- package/lib/module/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/components/KeyboardToolbar/Button.d.ts +2 -2
- package/lib/typescript/components/KeyboardToolbar/index.d.ts +4 -3
- package/lib/typescript/context.d.ts +3 -3
- package/lib/typescript/event-mappings.d.ts +2 -0
- package/lib/typescript/hooks/index.d.ts +1 -1
- package/lib/typescript/hooks/useSyncEffect/index.d.ts +14 -0
- package/lib/typescript/internal.d.ts +5 -19
- package/lib/typescript/reanimated.d.ts +1 -3
- package/lib/typescript/reanimated.native.d.ts +1 -3
- package/lib/typescript/specs/KeyboardGestureAreaNativeComponent.d.ts +2 -1
- package/lib/typescript/types.d.ts +6 -0
- package/package.json +11 -7
- package/src/animated.tsx +20 -43
- package/src/bindings.native.ts +1 -0
- package/src/bindings.ts +1 -0
- package/src/components/KeyboardAvoidingView/hooks.ts +2 -13
- package/src/components/KeyboardAvoidingView/index.tsx +1 -1
- package/src/components/KeyboardAwareScrollView/index.tsx +8 -3
- package/src/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.ts +1 -0
- package/src/components/KeyboardAwareScrollView/utils.ts +1 -0
- package/src/components/KeyboardToolbar/Button.tsx +11 -11
- package/src/components/KeyboardToolbar/index.tsx +45 -25
- package/src/context.ts +8 -6
- package/src/event-handler.d.ts +8 -0
- package/src/event-handler.js +15 -0
- package/src/event-handler.web.js +5 -0
- package/src/event-mappings.ts +14 -0
- package/src/hooks/index.ts +9 -16
- package/src/hooks/useSyncEffect/index.ts +36 -0
- package/src/internal.ts +34 -54
- package/src/monkey-patch.ts +1 -0
- package/src/reanimated.native.ts +0 -50
- package/src/reanimated.ts +1 -12
- package/src/specs/KeyboardGestureAreaNativeComponent.ts +5 -1
- package/src/types.ts +6 -0
- package/lib/commonjs/utils.js +0 -9
- package/lib/commonjs/utils.js.map +0 -1
- package/lib/module/utils.js +0 -2
- package/lib/module/utils.js.map +0 -1
- package/lib/typescript/utils.d.ts +0 -1
- package/src/utils.ts +0 -1
package/lib/module/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {\n EmitterSubscription,\n NativeSyntheticEvent,\n ViewProps,\n} from \"react-native\";\n\n// DirectEventHandler events declaration\nexport type NativeEvent = {\n progress: number;\n height: number;\n duration: number;\n target: number;\n};\nexport type FocusedInputLayoutChangedEvent = {\n target: number;\n parentScrollViewTarget: number;\n layout: {\n x: number;\n y: number;\n width: number;\n height: number;\n absoluteX: number;\n absoluteY: number;\n };\n};\nexport type FocusedInputTextChangedEvent = {\n text: string;\n};\nexport type FocusedInputSelectionChangedEvent = {\n target: number;\n selection: {\n start: {\n x: number;\n y: number;\n position: number;\n };\n end: {\n x: number;\n y: number;\n position: number;\n };\n };\n};\nexport type EventWithName<T> = {\n eventName: string;\n} & T;\n\n// native View/Module declarations\nexport type KeyboardControllerProps = {\n // callback props\n onKeyboardMoveStart?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onKeyboardMove?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onKeyboardMoveEnd?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onKeyboardMoveInteractive?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onFocusedInputLayoutChanged?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputLayoutChangedEvent>>,\n ) => void;\n onFocusedInputTextChanged?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputTextChangedEvent>>,\n ) => void;\n onFocusedInputSelectionChanged?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputSelectionChangedEvent>>,\n ) => void;\n // fake props used to activate reanimated bindings\n onKeyboardMoveReanimated?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onFocusedInputLayoutChangedReanimated?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputLayoutChangedEvent>>,\n ) => void;\n onFocusedInputTextChangedReanimated?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputTextChangedEvent>>,\n ) => void;\n onFocusedInputSelectionChangedReanimated?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputSelectionChangedEvent>>,\n ) => void;\n // props\n statusBarTranslucent?: boolean;\n navigationBarTranslucent?: boolean;\n enabled?: boolean;\n} & ViewProps;\n\nexport type KeyboardGestureAreaProps = {\n interpolator: \"ios\" | \"linear\";\n /**\n * Whether to allow to show a keyboard from dismissed state by swipe up.\n * Default to `false`.\n */\n showOnSwipeUp?: boolean;\n /**\n * Whether to allow to control a keyboard by gestures. The strategy how\n * it should be controlled is determined by `interpolator` property.\n * Defaults to `true`.\n */\n enableSwipeToDismiss?: boolean;\n} & ViewProps;\n\nexport type Direction = \"next\" | \"prev\" | \"current\";\nexport type KeyboardControllerModule = {\n // android only\n setDefaultMode: () => void;\n setInputMode: (mode: number) => void;\n // all platforms\n dismiss: () => void;\n setFocusTo: (direction: Direction) => void;\n // native event module stuff\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n};\n\n// Event module declarations\nexport type KeyboardControllerEvents =\n | \"keyboardWillShow\"\n | \"keyboardDidShow\"\n | \"keyboardWillHide\"\n | \"keyboardDidHide\";\nexport type KeyboardEventData = {\n height: number;\n duration: number;\n timestamp: number;\n target: number;\n};\nexport type KeyboardEventsModule = {\n addListener: (\n name: KeyboardControllerEvents,\n cb: (e: KeyboardEventData) => void,\n ) => EmitterSubscription;\n};\nexport type FocusedInputAvailableEvents = \"focusDidSet\";\nexport type FocusedInputEventData = {\n current: number;\n count: number;\n};\nexport type FocusedInputEventsModule = {\n addListener: (\n name: FocusedInputAvailableEvents,\n cb: (e: FocusedInputEventData) => void,\n ) => EmitterSubscription;\n};\nexport type WindowDimensionsAvailableEvents = \"windowDidResize\";\nexport type WindowDimensionsEventData = {\n width: number;\n height: number;\n};\nexport type WindowDimensionsEventsModule = {\n addListener: (\n name: WindowDimensionsAvailableEvents,\n cb: (e: WindowDimensionsEventData) => void,\n ) => EmitterSubscription;\n};\n\n// reanimated hook declaration\nexport type KeyboardHandlerHook<TContext, Event> = (\n handlers: {\n onKeyboardMoveStart?: (e: NativeEvent, context: TContext) => void;\n onKeyboardMove?: (e: NativeEvent, context: TContext) => void;\n onKeyboardMoveEnd?: (e: NativeEvent, context: TContext) => void;\n onKeyboardMoveInteractive?: (e: NativeEvent, context: TContext) => void;\n },\n dependencies?: unknown[],\n) => (e: NativeSyntheticEvent<Event>) => void;\nexport type FocusedInputLayoutHandlerHook<TContext, Event> = (\n handlers: {\n onFocusedInputLayoutChanged?: (\n e: FocusedInputLayoutChangedEvent,\n context: TContext,\n ) => void;\n },\n dependencies?: unknown[],\n) => (e: NativeSyntheticEvent<Event>) => void;\nexport type FocusedInputTextHandlerHook<TContext, Event> = (\n handlers: {\n onFocusedInputTextChanged?: (\n e: FocusedInputTextChangedEvent,\n context: TContext,\n ) => void;\n },\n dependencies?: unknown[],\n) => (e: NativeSyntheticEvent<Event>) => void;\nexport type FocusedInputSelectionHandlerHook<TContext, Event> = (\n handlers: {\n onFocusedInputSelectionChanged?: (\n e: FocusedInputSelectionChangedEvent,\n context: TContext,\n ) => void;\n },\n dependencies?: unknown[],\n) => (e: NativeSyntheticEvent<Event>) => void;\n\n// package types\nexport type Handlers<T> = Record<string, T | undefined>;\nexport type KeyboardHandler = Partial<{\n onStart: (e: NativeEvent) => void;\n onMove: (e: NativeEvent) => void;\n onEnd: (e: NativeEvent) => void;\n onInteractive: (e: NativeEvent) => void;\n}>;\nexport type KeyboardHandlers = Handlers<KeyboardHandler>;\nexport type FocusedInputHandler = Partial<{\n onChangeText: (e: FocusedInputTextChangedEvent) => void;\n onSelectionChange: (e: FocusedInputSelectionChangedEvent) => void;\n}>;\nexport type FocusedInputHandlers = Handlers<FocusedInputHandler>;\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {\n EmitterSubscription,\n NativeSyntheticEvent,\n ViewProps,\n} from \"react-native\";\n\n// DirectEventHandler events declaration\nexport type NativeEvent = {\n progress: number;\n height: number;\n duration: number;\n target: number;\n};\nexport type FocusedInputLayoutChangedEvent = {\n target: number;\n parentScrollViewTarget: number;\n layout: {\n x: number;\n y: number;\n width: number;\n height: number;\n absoluteX: number;\n absoluteY: number;\n };\n};\nexport type FocusedInputTextChangedEvent = {\n text: string;\n};\nexport type FocusedInputSelectionChangedEvent = {\n target: number;\n selection: {\n start: {\n x: number;\n y: number;\n position: number;\n };\n end: {\n x: number;\n y: number;\n position: number;\n };\n };\n};\nexport type EventWithName<T> = {\n eventName: string;\n} & T;\n\n// native View/Module declarations\nexport type KeyboardControllerProps = {\n //ref prop\n ref?: React.Ref<React.Component<KeyboardControllerProps>>;\n // callback props\n onKeyboardMoveStart?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onKeyboardMove?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onKeyboardMoveEnd?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onKeyboardMoveInteractive?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onFocusedInputLayoutChanged?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputLayoutChangedEvent>>,\n ) => void;\n onFocusedInputTextChanged?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputTextChangedEvent>>,\n ) => void;\n onFocusedInputSelectionChanged?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputSelectionChangedEvent>>,\n ) => void;\n // fake props used to activate reanimated bindings\n onKeyboardMoveReanimated?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onFocusedInputLayoutChangedReanimated?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputLayoutChangedEvent>>,\n ) => void;\n onFocusedInputTextChangedReanimated?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputTextChangedEvent>>,\n ) => void;\n onFocusedInputSelectionChangedReanimated?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputSelectionChangedEvent>>,\n ) => void;\n // props\n statusBarTranslucent?: boolean;\n navigationBarTranslucent?: boolean;\n enabled?: boolean;\n} & ViewProps;\n\nexport type KeyboardGestureAreaProps = {\n interpolator: \"ios\" | \"linear\";\n /**\n * Whether to allow to show a keyboard from dismissed state by swipe up.\n * Default to `false`.\n */\n showOnSwipeUp?: boolean;\n /**\n * Whether to allow to control a keyboard by gestures. The strategy how\n * it should be controlled is determined by `interpolator` property.\n * Defaults to `true`.\n */\n enableSwipeToDismiss?: boolean;\n /**\n * Extra distance to the keyboard.\n */\n offset?: number;\n} & ViewProps;\n\nexport type Direction = \"next\" | \"prev\" | \"current\";\nexport type KeyboardControllerModule = {\n // android only\n setDefaultMode: () => void;\n setInputMode: (mode: number) => void;\n // all platforms\n dismiss: () => void;\n setFocusTo: (direction: Direction) => void;\n // native event module stuff\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n};\n\n// Event module declarations\nexport type KeyboardControllerEvents =\n | \"keyboardWillShow\"\n | \"keyboardDidShow\"\n | \"keyboardWillHide\"\n | \"keyboardDidHide\";\nexport type KeyboardEventData = {\n height: number;\n duration: number;\n timestamp: number;\n target: number;\n};\nexport type KeyboardEventsModule = {\n addListener: (\n name: KeyboardControllerEvents,\n cb: (e: KeyboardEventData) => void,\n ) => EmitterSubscription;\n};\nexport type FocusedInputAvailableEvents = \"focusDidSet\";\nexport type FocusedInputEventData = {\n current: number;\n count: number;\n};\nexport type FocusedInputEventsModule = {\n addListener: (\n name: FocusedInputAvailableEvents,\n cb: (e: FocusedInputEventData) => void,\n ) => EmitterSubscription;\n};\nexport type WindowDimensionsAvailableEvents = \"windowDidResize\";\nexport type WindowDimensionsEventData = {\n width: number;\n height: number;\n};\nexport type WindowDimensionsEventsModule = {\n addListener: (\n name: WindowDimensionsAvailableEvents,\n cb: (e: WindowDimensionsEventData) => void,\n ) => EmitterSubscription;\n};\n\n// reanimated hook declaration\nexport type KeyboardHandlerHook<TContext, Event> = (\n handlers: {\n onKeyboardMoveStart?: (e: NativeEvent, context: TContext) => void;\n onKeyboardMove?: (e: NativeEvent, context: TContext) => void;\n onKeyboardMoveEnd?: (e: NativeEvent, context: TContext) => void;\n onKeyboardMoveInteractive?: (e: NativeEvent, context: TContext) => void;\n },\n dependencies?: unknown[],\n) => (e: NativeSyntheticEvent<Event>) => void;\nexport type FocusedInputLayoutHandlerHook<TContext, Event> = (\n handlers: {\n onFocusedInputLayoutChanged?: (\n e: FocusedInputLayoutChangedEvent,\n context: TContext,\n ) => void;\n },\n dependencies?: unknown[],\n) => (e: NativeSyntheticEvent<Event>) => void;\nexport type FocusedInputTextHandlerHook<TContext, Event> = (\n handlers: {\n onFocusedInputTextChanged?: (\n e: FocusedInputTextChangedEvent,\n context: TContext,\n ) => void;\n },\n dependencies?: unknown[],\n) => (e: NativeSyntheticEvent<Event>) => void;\nexport type FocusedInputSelectionHandlerHook<TContext, Event> = (\n handlers: {\n onFocusedInputSelectionChanged?: (\n e: FocusedInputSelectionChangedEvent,\n context: TContext,\n ) => void;\n },\n dependencies?: unknown[],\n) => (e: NativeSyntheticEvent<Event>) => void;\n\n// package types\nexport type Handlers<T> = Record<string, T | undefined>;\nexport type KeyboardHandler = Partial<{\n onStart: (e: NativeEvent) => void;\n onMove: (e: NativeEvent) => void;\n onEnd: (e: NativeEvent) => void;\n onInteractive: (e: NativeEvent) => void;\n}>;\nexport type KeyboardHandlers = Handlers<KeyboardHandler>;\nexport type FocusedInputHandler = Partial<{\n onChangeText: (e: FocusedInputTextChangedEvent) => void;\n onSelectionChange: (e: FocusedInputSelectionChangedEvent) => void;\n}>;\nexport type FocusedInputHandlers = Handlers<FocusedInputHandler>;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { KeyboardToolbarTheme } from "./types";
|
|
3
|
-
import type { ViewStyle } from "react-native";
|
|
3
|
+
import type { GestureResponderEvent, ViewStyle } from "react-native";
|
|
4
4
|
type ButtonProps = {
|
|
5
5
|
disabled?: boolean;
|
|
6
|
-
onPress: () => void;
|
|
6
|
+
onPress: (event: GestureResponderEvent) => void;
|
|
7
7
|
accessibilityLabel: string;
|
|
8
8
|
accessibilityHint: string;
|
|
9
9
|
testID: string;
|
|
@@ -4,6 +4,7 @@ import Button from "./Button";
|
|
|
4
4
|
import { colors } from "./colors";
|
|
5
5
|
import type { HEX, KeyboardToolbarTheme } from "./types";
|
|
6
6
|
import type { ReactNode } from "react";
|
|
7
|
+
import type { GestureResponderEvent } from "react-native";
|
|
7
8
|
export type KeyboardToolbarProps = {
|
|
8
9
|
/** An element that is shown in the middle of the toolbar. */
|
|
9
10
|
content?: JSX.Element | null;
|
|
@@ -23,15 +24,15 @@ export type KeyboardToolbarProps = {
|
|
|
23
24
|
/**
|
|
24
25
|
* A callback that is called when the user presses the next button along with the default action.
|
|
25
26
|
*/
|
|
26
|
-
onNextCallback?: () => void;
|
|
27
|
+
onNextCallback?: (event: GestureResponderEvent) => void;
|
|
27
28
|
/**
|
|
28
29
|
* A callback that is called when the user presses the previous button along with the default action.
|
|
29
30
|
*/
|
|
30
|
-
onPrevCallback?: () => void;
|
|
31
|
+
onPrevCallback?: (event: GestureResponderEvent) => void;
|
|
31
32
|
/**
|
|
32
33
|
* A callback that is called when the user presses the done button along with the default action.
|
|
33
34
|
*/
|
|
34
|
-
onDoneCallback?: () => void;
|
|
35
|
+
onDoneCallback?: (event: GestureResponderEvent) => void;
|
|
35
36
|
/**
|
|
36
37
|
* A component that applies blur effect to the toolbar.
|
|
37
38
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Animated } from "react-native";
|
|
2
|
-
import type {
|
|
2
|
+
import type { FocusedInputHandler, FocusedInputLayoutChangedEvent, KeyboardHandler } from "./types";
|
|
3
3
|
import type React from "react";
|
|
4
4
|
import type { SharedValue } from "react-native-reanimated";
|
|
5
5
|
export type AnimatedContext = {
|
|
@@ -15,8 +15,8 @@ export type KeyboardAnimationContext = {
|
|
|
15
15
|
animated: AnimatedContext;
|
|
16
16
|
reanimated: ReanimatedContext;
|
|
17
17
|
layout: SharedValue<FocusedInputLayoutChangedEvent | null>;
|
|
18
|
-
setKeyboardHandlers: (handlers:
|
|
19
|
-
setInputHandlers: (handlers:
|
|
18
|
+
setKeyboardHandlers: (handlers: KeyboardHandler) => () => void;
|
|
19
|
+
setInputHandlers: (handlers: FocusedInputHandler) => () => void;
|
|
20
20
|
setEnabled: React.Dispatch<React.SetStateAction<boolean>>;
|
|
21
21
|
};
|
|
22
22
|
export declare const KeyboardContext: React.Context<KeyboardAnimationContext>;
|
|
@@ -13,5 +13,5 @@ export declare function useKeyboardController(): {
|
|
|
13
13
|
export declare function useReanimatedFocusedInput(): {
|
|
14
14
|
input: import("react-native-reanimated").SharedValue<import("../types").FocusedInputLayoutChangedEvent | null>;
|
|
15
15
|
};
|
|
16
|
-
export declare function useFocusedInputHandler(handler
|
|
16
|
+
export declare function useFocusedInputHandler(handler: FocusedInputHandler, deps?: DependencyList): void;
|
|
17
17
|
export * from "./useWindowDimensions";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* @description
|
|
4
|
+
* Equivalent to `useEffect` but will run the effect synchronously, i. e. before render.
|
|
5
|
+
*
|
|
6
|
+
* @param {effect} - imperative function
|
|
7
|
+
* @param {deps} - if present, effect will only activate if the values in the list change
|
|
8
|
+
*
|
|
9
|
+
* @author Kiryl Ziusko
|
|
10
|
+
* @since 1.13.0
|
|
11
|
+
* @version 1.0.0
|
|
12
|
+
*/
|
|
13
|
+
declare const useSyncEffect: typeof useEffect;
|
|
14
|
+
export default useSyncEffect;
|
|
@@ -1,22 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
type
|
|
4
|
-
type
|
|
5
|
-
|
|
6
|
-
<K extends keyof T>(type: K, event: Parameters<T[K]>[0]) => void
|
|
7
|
-
];
|
|
8
|
-
/**
|
|
9
|
-
* Hook for storing worklet handlers (objects with keys, where values are worklets).
|
|
10
|
-
* Returns methods for setting handlers and broadcasting events in them.
|
|
11
|
-
*
|
|
12
|
-
* T is a generic that looks like:
|
|
13
|
-
* @example
|
|
14
|
-
* {
|
|
15
|
-
* onEvent: () => {},
|
|
16
|
-
* onEvent2: () => {},
|
|
17
|
-
* }
|
|
18
|
-
*/
|
|
19
|
-
export declare function useSharedHandlers<T extends UntypedHandler>(): SharedHandlersReturnType<T>;
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Animated, findNodeHandle } from "react-native";
|
|
3
|
+
type EventHandler = (event: never) => void;
|
|
4
|
+
type ComponentOrHandle = Parameters<typeof findNodeHandle>[0];
|
|
5
|
+
export declare function useEventHandlerRegistration<H extends Partial<Record<string, EventHandler>>>(map: Map<keyof H, string>, viewTagRef: React.MutableRefObject<ComponentOrHandle>): (handler: H) => () => void;
|
|
20
6
|
/**
|
|
21
7
|
* TS variant of `useAnimatedValue` hook which is added in RN 0.71
|
|
22
8
|
* A better alternative of storing animated values in refs, since
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { EventWithName, FocusedInputLayoutChangedEvent, FocusedInputLayoutHandlerHook,
|
|
1
|
+
import type { EventWithName, FocusedInputLayoutChangedEvent, FocusedInputLayoutHandlerHook, KeyboardHandlerHook, NativeEvent } from "./types";
|
|
2
2
|
export declare const useAnimatedKeyboardHandler: KeyboardHandlerHook<Record<string, unknown>, EventWithName<NativeEvent>>;
|
|
3
3
|
export declare const useFocusedInputLayoutHandler: FocusedInputLayoutHandlerHook<Record<string, unknown>, EventWithName<FocusedInputLayoutChangedEvent>>;
|
|
4
|
-
export declare const useFocusedInputTextHandler: FocusedInputTextHandlerHook<Record<string, unknown>, EventWithName<FocusedInputTextChangedEvent>>;
|
|
5
|
-
export declare const useFocusedInputSelectionHandler: FocusedInputSelectionHandlerHook<Record<string, unknown>, EventWithName<FocusedInputSelectionChangedEvent>>;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import type { EventWithName, FocusedInputLayoutChangedEvent, FocusedInputLayoutHandlerHook,
|
|
1
|
+
import type { EventWithName, FocusedInputLayoutChangedEvent, FocusedInputLayoutHandlerHook, KeyboardHandlerHook, NativeEvent } from "./types";
|
|
2
2
|
type EventContext = Record<string, unknown>;
|
|
3
3
|
export declare const useAnimatedKeyboardHandler: KeyboardHandlerHook<EventContext, EventWithName<NativeEvent>>;
|
|
4
4
|
export declare const useFocusedInputLayoutHandler: FocusedInputLayoutHandlerHook<EventContext, EventWithName<FocusedInputLayoutChangedEvent>>;
|
|
5
|
-
export declare const useFocusedInputTextHandler: FocusedInputTextHandlerHook<EventContext, EventWithName<FocusedInputTextChangedEvent>>;
|
|
6
|
-
export declare const useFocusedInputSelectionHandler: FocusedInputSelectionHandlerHook<EventContext, EventWithName<FocusedInputSelectionChangedEvent>>;
|
|
7
5
|
export {};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { HostComponent } from "react-native";
|
|
2
2
|
import type { ViewProps } from "react-native/Libraries/Components/View/ViewPropTypes";
|
|
3
|
-
import type { WithDefault } from "react-native/Libraries/Types/CodegenTypes";
|
|
3
|
+
import type { Double, WithDefault } from "react-native/Libraries/Types/CodegenTypes";
|
|
4
4
|
export interface NativeProps extends ViewProps {
|
|
5
5
|
interpolator?: WithDefault<"linear" | "ios", "linear">;
|
|
6
6
|
showOnSwipeUp?: boolean;
|
|
7
7
|
enableSwipeToDismiss?: boolean;
|
|
8
|
+
offset?: Double;
|
|
8
9
|
}
|
|
9
10
|
declare const _default: HostComponent<NativeProps>;
|
|
10
11
|
export default _default;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import type { EmitterSubscription, NativeSyntheticEvent, ViewProps } from "react-native";
|
|
2
3
|
export type NativeEvent = {
|
|
3
4
|
progress: number;
|
|
@@ -39,6 +40,7 @@ export type EventWithName<T> = {
|
|
|
39
40
|
eventName: string;
|
|
40
41
|
} & T;
|
|
41
42
|
export type KeyboardControllerProps = {
|
|
43
|
+
ref?: React.Ref<React.Component<KeyboardControllerProps>>;
|
|
42
44
|
onKeyboardMoveStart?: (e: NativeSyntheticEvent<EventWithName<NativeEvent>>) => void;
|
|
43
45
|
onKeyboardMove?: (e: NativeSyntheticEvent<EventWithName<NativeEvent>>) => void;
|
|
44
46
|
onKeyboardMoveEnd?: (e: NativeSyntheticEvent<EventWithName<NativeEvent>>) => void;
|
|
@@ -67,6 +69,10 @@ export type KeyboardGestureAreaProps = {
|
|
|
67
69
|
* Defaults to `true`.
|
|
68
70
|
*/
|
|
69
71
|
enableSwipeToDismiss?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Extra distance to the keyboard.
|
|
74
|
+
*/
|
|
75
|
+
offset?: number;
|
|
70
76
|
} & ViewProps;
|
|
71
77
|
export type Direction = "next" | "prev" | "current";
|
|
72
78
|
export type KeyboardControllerModule = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-keyboard-controller",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.1",
|
|
4
4
|
"description": "Keyboard manager which works in identical way on both iOS and Android",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -42,8 +42,9 @@
|
|
|
42
42
|
"keywords": [
|
|
43
43
|
"react-native",
|
|
44
44
|
"keyboard",
|
|
45
|
-
"
|
|
45
|
+
"interactive",
|
|
46
46
|
"dismiss",
|
|
47
|
+
"animation",
|
|
47
48
|
"focused input",
|
|
48
49
|
"text changed",
|
|
49
50
|
"selection changed",
|
|
@@ -70,8 +71,9 @@
|
|
|
70
71
|
},
|
|
71
72
|
"devDependencies": {
|
|
72
73
|
"@commitlint/config-conventional": "^11.0.0",
|
|
73
|
-
"@react-native/eslint-config": "^0.
|
|
74
|
+
"@react-native/eslint-config": "^0.75.0-rc.6",
|
|
74
75
|
"@release-it/conventional-changelog": "^2.0.0",
|
|
76
|
+
"@testing-library/react-hooks": "^8.0.1",
|
|
75
77
|
"@types/jest": "^29.2.1",
|
|
76
78
|
"@types/react": "^18.2.6",
|
|
77
79
|
"@typescript-eslint/eslint-plugin": "^6.7.4",
|
|
@@ -86,21 +88,23 @@
|
|
|
86
88
|
"eslint-plugin-jest": "^26.5.3",
|
|
87
89
|
"eslint-plugin-prettier": "^4.2.1",
|
|
88
90
|
"eslint-plugin-react-compiler": "^0.0.0-experimental-0998c1e-20240625",
|
|
91
|
+
"eslint-plugin-react-perf": "^3.3.2",
|
|
89
92
|
"husky": "^6.0.0",
|
|
90
93
|
"jest": "^29.6.3",
|
|
91
94
|
"pod-install": "^0.1.0",
|
|
92
95
|
"prettier": "^2.8.8",
|
|
93
|
-
"react": "18.
|
|
94
|
-
"react-native": "0.
|
|
96
|
+
"react": "18.3.1",
|
|
97
|
+
"react-native": "0.75.0-rc.6",
|
|
95
98
|
"react-native-builder-bob": "^0.18.0",
|
|
96
|
-
"react-native-reanimated": "3.
|
|
99
|
+
"react-native-reanimated": "3.15.0",
|
|
100
|
+
"react-test-renderer": "18.2.0",
|
|
97
101
|
"release-it": "^14.2.2",
|
|
98
102
|
"typescript": "5.0.4"
|
|
99
103
|
},
|
|
100
104
|
"peerDependencies": {
|
|
101
105
|
"react": "*",
|
|
102
106
|
"react-native": "*",
|
|
103
|
-
"react-native-reanimated": ">=
|
|
107
|
+
"react-native-reanimated": ">=3.0.0"
|
|
104
108
|
},
|
|
105
109
|
"jest": {
|
|
106
110
|
"preset": "react-native",
|
package/src/animated.tsx
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint react/jsx-sort-props: off */
|
|
2
|
+
import React, { useEffect, useMemo, useRef, useState } from "react";
|
|
2
3
|
import { Animated, Platform, StyleSheet } from "react-native";
|
|
3
4
|
import Reanimated, { useSharedValue } from "react-native-reanimated";
|
|
4
5
|
|
|
5
6
|
import { KeyboardControllerView } from "./bindings";
|
|
6
7
|
import { KeyboardContext } from "./context";
|
|
7
|
-
import {
|
|
8
|
+
import { focusedInputEventsMap, keyboardEventsMap } from "./event-mappings";
|
|
9
|
+
import { useAnimatedValue, useEventHandlerRegistration } from "./internal";
|
|
8
10
|
import { applyMonkeyPatch, revertMonkeyPatch } from "./monkey-patch";
|
|
9
11
|
import {
|
|
10
12
|
useAnimatedKeyboardHandler,
|
|
11
13
|
useFocusedInputLayoutHandler,
|
|
12
|
-
useFocusedInputSelectionHandler,
|
|
13
|
-
useFocusedInputTextHandler,
|
|
14
14
|
} from "./reanimated";
|
|
15
15
|
|
|
16
16
|
import type { KeyboardAnimationContext } from "./context";
|
|
@@ -24,9 +24,7 @@ import type {
|
|
|
24
24
|
import type { ViewStyle } from "react-native";
|
|
25
25
|
|
|
26
26
|
const KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(
|
|
27
|
-
Animated.createAnimatedComponent(
|
|
28
|
-
KeyboardControllerView,
|
|
29
|
-
) as React.FC<KeyboardControllerProps>,
|
|
27
|
+
Animated.createAnimatedComponent(KeyboardControllerView),
|
|
30
28
|
);
|
|
31
29
|
|
|
32
30
|
type Styles = {
|
|
@@ -83,6 +81,8 @@ export const KeyboardProvider = ({
|
|
|
83
81
|
navigationBarTranslucent,
|
|
84
82
|
enabled: initiallyEnabled = true,
|
|
85
83
|
}: KeyboardProviderProps) => {
|
|
84
|
+
// ref
|
|
85
|
+
const viewTagRef = useRef<React.Component<KeyboardControllerProps>>(null);
|
|
86
86
|
// state
|
|
87
87
|
const [enabled, setEnabled] = useState(initiallyEnabled);
|
|
88
88
|
// animated values
|
|
@@ -92,10 +92,14 @@ export const KeyboardProvider = ({
|
|
|
92
92
|
const progressSV = useSharedValue(0);
|
|
93
93
|
const heightSV = useSharedValue(0);
|
|
94
94
|
const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
const setKeyboardHandlers = useEventHandlerRegistration<KeyboardHandler>(
|
|
96
|
+
keyboardEventsMap,
|
|
97
|
+
viewTagRef,
|
|
98
|
+
);
|
|
99
|
+
const setInputHandlers = useEventHandlerRegistration<FocusedInputHandler>(
|
|
100
|
+
focusedInputEventsMap,
|
|
101
|
+
viewTagRef,
|
|
102
|
+
);
|
|
99
103
|
// memo
|
|
100
104
|
const context = useMemo<KeyboardAnimationContext>(
|
|
101
105
|
() => ({
|
|
@@ -146,25 +150,17 @@ export const KeyboardProvider = ({
|
|
|
146
150
|
onKeyboardMoveStart: (event: NativeEvent) => {
|
|
147
151
|
"worklet";
|
|
148
152
|
|
|
149
|
-
broadcastKeyboardEvents("onStart", event);
|
|
150
153
|
updateSharedValues(event, ["ios"]);
|
|
151
154
|
},
|
|
152
155
|
onKeyboardMove: (event: NativeEvent) => {
|
|
153
156
|
"worklet";
|
|
154
157
|
|
|
155
|
-
broadcastKeyboardEvents("onMove", event);
|
|
156
158
|
updateSharedValues(event, ["android"]);
|
|
157
159
|
},
|
|
158
|
-
onKeyboardMoveEnd: (event: NativeEvent) => {
|
|
159
|
-
"worklet";
|
|
160
|
-
|
|
161
|
-
broadcastKeyboardEvents("onEnd", event);
|
|
162
|
-
},
|
|
163
160
|
onKeyboardMoveInteractive: (event: NativeEvent) => {
|
|
164
161
|
"worklet";
|
|
165
162
|
|
|
166
163
|
updateSharedValues(event, ["android", "ios"]);
|
|
167
|
-
broadcastKeyboardEvents("onInteractive", event);
|
|
168
164
|
},
|
|
169
165
|
},
|
|
170
166
|
[],
|
|
@@ -183,26 +179,7 @@ export const KeyboardProvider = ({
|
|
|
183
179
|
},
|
|
184
180
|
[],
|
|
185
181
|
);
|
|
186
|
-
const inputTextHandler = useFocusedInputTextHandler(
|
|
187
|
-
{
|
|
188
|
-
onFocusedInputTextChanged: (e) => {
|
|
189
|
-
"worklet";
|
|
190
|
-
|
|
191
|
-
broadcastInputEvents("onChangeText", e);
|
|
192
|
-
},
|
|
193
|
-
},
|
|
194
|
-
[],
|
|
195
|
-
);
|
|
196
|
-
const inputSelectionHandler = useFocusedInputSelectionHandler(
|
|
197
|
-
{
|
|
198
|
-
onFocusedInputSelectionChanged: (e) => {
|
|
199
|
-
"worklet";
|
|
200
182
|
|
|
201
|
-
broadcastInputEvents("onSelectionChange", e);
|
|
202
|
-
},
|
|
203
|
-
},
|
|
204
|
-
[],
|
|
205
|
-
);
|
|
206
183
|
// effects
|
|
207
184
|
useEffect(() => {
|
|
208
185
|
if (enabled) {
|
|
@@ -215,17 +192,17 @@ export const KeyboardProvider = ({
|
|
|
215
192
|
return (
|
|
216
193
|
<KeyboardContext.Provider value={context}>
|
|
217
194
|
<KeyboardControllerViewAnimated
|
|
195
|
+
ref={viewTagRef}
|
|
218
196
|
enabled={enabled}
|
|
197
|
+
navigationBarTranslucent={navigationBarTranslucent}
|
|
198
|
+
statusBarTranslucent={statusBarTranslucent}
|
|
199
|
+
style={styles.container}
|
|
200
|
+
// on*Reanimated prop must precede animated handlers to work correctly
|
|
219
201
|
onKeyboardMoveReanimated={keyboardHandler}
|
|
220
202
|
onKeyboardMoveStart={OS === "ios" ? onKeyboardMove : undefined}
|
|
221
203
|
onKeyboardMove={OS === "android" ? onKeyboardMove : undefined}
|
|
222
204
|
onKeyboardMoveInteractive={onKeyboardMove}
|
|
223
205
|
onFocusedInputLayoutChangedReanimated={inputLayoutHandler}
|
|
224
|
-
onFocusedInputTextChangedReanimated={inputTextHandler}
|
|
225
|
-
onFocusedInputSelectionChangedReanimated={inputSelectionHandler}
|
|
226
|
-
navigationBarTranslucent={navigationBarTranslucent}
|
|
227
|
-
statusBarTranslucent={statusBarTranslucent}
|
|
228
|
-
style={styles.container}
|
|
229
206
|
>
|
|
230
207
|
{children}
|
|
231
208
|
</KeyboardControllerViewAnimated>
|
package/src/bindings.native.ts
CHANGED
package/src/bindings.ts
CHANGED
|
@@ -34,19 +34,8 @@ export const useKeyboardAnimation = () => {
|
|
|
34
34
|
|
|
35
35
|
isClosed.value = e.height === 0;
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// wasn't called (i. e. duration === 0)
|
|
40
|
-
//
|
|
41
|
-
// we can not call this code without condition below
|
|
42
|
-
// because in some corner cases (iOS with `secureTextEntry`)
|
|
43
|
-
// `onEnd` can be emitted before `onMove` and in this case
|
|
44
|
-
// it may lead to choppy/glitchy/jumpy UI
|
|
45
|
-
// see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/327
|
|
46
|
-
if (e.duration === 0) {
|
|
47
|
-
progress.value = e.progress;
|
|
48
|
-
height.value = e.height;
|
|
49
|
-
}
|
|
37
|
+
height.value = e.height;
|
|
38
|
+
progress.value = e.progress;
|
|
50
39
|
},
|
|
51
40
|
},
|
|
52
41
|
[],
|
|
@@ -90,6 +90,7 @@ const KeyboardAwareScrollView = forwardRef<
|
|
|
90
90
|
disableScrollOnKeyboardHide = false,
|
|
91
91
|
enabled = true,
|
|
92
92
|
extraKeyboardSpace = 0,
|
|
93
|
+
snapToOffsets,
|
|
93
94
|
...rest
|
|
94
95
|
},
|
|
95
96
|
ref,
|
|
@@ -158,12 +159,13 @@ const KeyboardAwareScrollView = forwardRef<
|
|
|
158
159
|
0,
|
|
159
160
|
scrollDistanceWithRespectToSnapPoints(
|
|
160
161
|
relativeScrollTo + scrollPosition.value,
|
|
161
|
-
|
|
162
|
+
snapToOffsets,
|
|
162
163
|
) - scrollPosition.value,
|
|
163
164
|
],
|
|
164
165
|
);
|
|
165
166
|
const targetScrollY =
|
|
166
167
|
Math.max(interpolatedScrollTo, 0) + scrollPosition.value;
|
|
168
|
+
|
|
167
169
|
scrollTo(scrollViewAnimatedRef, 0, targetScrollY, animated);
|
|
168
170
|
|
|
169
171
|
return interpolatedScrollTo;
|
|
@@ -183,7 +185,7 @@ const KeyboardAwareScrollView = forwardRef<
|
|
|
183
185
|
|
|
184
186
|
return 0;
|
|
185
187
|
},
|
|
186
|
-
[bottomOffset, enabled, height,
|
|
188
|
+
[bottomOffset, enabled, height, snapToOffsets],
|
|
187
189
|
);
|
|
188
190
|
|
|
189
191
|
const scrollFromCurrentPosition = useCallback(
|
|
@@ -254,7 +256,9 @@ const KeyboardAwareScrollView = forwardRef<
|
|
|
254
256
|
|
|
255
257
|
const keyboardWillChangeSize =
|
|
256
258
|
keyboardHeight.value !== e.height && e.height > 0;
|
|
259
|
+
|
|
257
260
|
keyboardWillAppear.value = e.height > 0 && keyboardHeight.value === 0;
|
|
261
|
+
|
|
258
262
|
const keyboardWillHide = e.height === 0;
|
|
259
263
|
const focusWasChanged =
|
|
260
264
|
(tag.value !== e.target && e.target !== -1) ||
|
|
@@ -306,6 +310,7 @@ const KeyboardAwareScrollView = forwardRef<
|
|
|
306
310
|
[0, keyboardHeight.value],
|
|
307
311
|
[0, keyboardHeight.value + extraKeyboardSpace],
|
|
308
312
|
);
|
|
313
|
+
|
|
309
314
|
currentKeyboardFrameHeight.value = keyboardFrame;
|
|
310
315
|
|
|
311
316
|
// if the user has set disableScrollOnKeyboardHide, only auto-scroll when the keyboard opens
|
|
@@ -360,8 +365,8 @@ const KeyboardAwareScrollView = forwardRef<
|
|
|
360
365
|
<Reanimated.ScrollView
|
|
361
366
|
ref={onRef}
|
|
362
367
|
{...rest}
|
|
363
|
-
onLayout={onScrollViewLayout}
|
|
364
368
|
scrollEventThrottle={16}
|
|
369
|
+
onLayout={onScrollViewLayout}
|
|
365
370
|
>
|
|
366
371
|
{children}
|
|
367
372
|
<Reanimated.View style={view} />
|
|
@@ -10,11 +10,11 @@ import useColorScheme from "../hooks/useColorScheme";
|
|
|
10
10
|
|
|
11
11
|
import type { KeyboardToolbarTheme } from "./types";
|
|
12
12
|
import type { PropsWithChildren } from "react";
|
|
13
|
-
import type { ViewStyle } from "react-native";
|
|
13
|
+
import type { GestureResponderEvent, ViewStyle } from "react-native";
|
|
14
14
|
|
|
15
15
|
type ButtonProps = {
|
|
16
16
|
disabled?: boolean;
|
|
17
|
-
onPress: () => void;
|
|
17
|
+
onPress: (event: GestureResponderEvent) => void;
|
|
18
18
|
accessibilityLabel: string;
|
|
19
19
|
accessibilityHint: string;
|
|
20
20
|
testID: string;
|
|
@@ -41,13 +41,13 @@ const ButtonIOS = ({
|
|
|
41
41
|
|
|
42
42
|
return (
|
|
43
43
|
<Container
|
|
44
|
-
accessibilityState={accessibilityState}
|
|
45
|
-
accessibilityRole="button"
|
|
46
|
-
accessibilityLabel={accessibilityLabel}
|
|
47
44
|
accessibilityHint={accessibilityHint}
|
|
48
|
-
|
|
45
|
+
accessibilityLabel={accessibilityLabel}
|
|
46
|
+
accessibilityRole="button"
|
|
47
|
+
accessibilityState={accessibilityState}
|
|
49
48
|
style={style}
|
|
50
49
|
testID={testID}
|
|
50
|
+
onPress={onPress}
|
|
51
51
|
>
|
|
52
52
|
{children}
|
|
53
53
|
</Container>
|
|
@@ -78,14 +78,14 @@ const ButtonAndroid = ({
|
|
|
78
78
|
|
|
79
79
|
return (
|
|
80
80
|
<TouchableNativeFeedback
|
|
81
|
-
accessibilityState={accessibilityState}
|
|
82
|
-
accessibilityRole="button"
|
|
83
|
-
accessibilityLabel={accessibilityLabel}
|
|
84
81
|
accessibilityHint={accessibilityHint}
|
|
85
|
-
|
|
82
|
+
accessibilityLabel={accessibilityLabel}
|
|
83
|
+
accessibilityRole="button"
|
|
84
|
+
accessibilityState={accessibilityState}
|
|
86
85
|
background={ripple}
|
|
87
|
-
testID={testID}
|
|
88
86
|
style={style}
|
|
87
|
+
testID={testID}
|
|
88
|
+
onPress={onPress}
|
|
89
89
|
>
|
|
90
90
|
<View style={style}>{children}</View>
|
|
91
91
|
</TouchableNativeFeedback>
|