react-native-keyboard-controller 1.5.7 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +3 -1
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/StatusBarManagerCompatModule.kt +2 -1
- package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardAnimationCallback.kt +130 -18
- package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardAnimationController.kt +10 -2
- package/android/src/main/java/com/reactnativekeyboardcontroller/events/KeyboardTransitionEvent.kt +11 -2
- package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/ThemedReactContext.kt +7 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardControllerViewManagerImpl.kt +2 -1
- package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardGestureAreaViewManagerImpl.kt +1 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/modules/KeyboardControllerModuleImpl.kt +6 -1
- package/android/src/main/java/com/reactnativekeyboardcontroller/modules/StatusBarManagerCompatModuleImpl.kt +9 -3
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/EdgeToEdgeReactViewGroup.kt +44 -27
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/KeyboardGestureAreaReactViewGroup.kt +121 -85
- package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +6 -4
- package/android/src/paper/java/com/reactnativekeyboardcontroller/StatusBarManagerCompatModule.kt +2 -1
- package/ios/Extensions.swift +31 -0
- package/ios/KeyboardController-Bridging-Header.h +1 -0
- package/ios/KeyboardControllerView.mm +25 -6
- package/ios/KeyboardControllerViewManager.swift +4 -2
- package/ios/KeyboardMoveEvent.h +3 -1
- package/ios/KeyboardMoveEvent.m +8 -0
- package/ios/KeyboardMovementObserver.swift +64 -12
- package/lib/commonjs/animated.js +4 -3
- package/lib/commonjs/animated.js.map +1 -1
- package/lib/commonjs/bindings.js +26 -0
- package/lib/commonjs/bindings.js.map +1 -0
- package/lib/commonjs/bindings.native.js +33 -0
- package/lib/commonjs/bindings.native.js.map +1 -0
- package/lib/commonjs/{native.js → constants.js} +2 -29
- package/lib/commonjs/constants.js.map +1 -0
- package/lib/commonjs/context.js +9 -1
- package/lib/commonjs/context.js.map +1 -1
- package/lib/commonjs/hooks.js +7 -6
- package/lib/commonjs/hooks.js.map +1 -1
- package/lib/commonjs/index.js +15 -4
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/internal.js +0 -30
- package/lib/commonjs/internal.js.map +1 -1
- package/lib/commonjs/monkey-patch.android.js +34 -0
- package/lib/commonjs/monkey-patch.android.js.map +1 -0
- package/lib/commonjs/monkey-patch.js +1 -35
- package/lib/commonjs/monkey-patch.js.map +1 -1
- package/lib/commonjs/reanimated.js +9 -0
- package/lib/commonjs/reanimated.js.map +1 -0
- package/lib/commonjs/reanimated.native.js +37 -0
- package/lib/commonjs/reanimated.native.js.map +1 -0
- package/lib/commonjs/replicas.js +4 -3
- package/lib/commonjs/replicas.js.map +1 -1
- package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/animated.js +3 -2
- package/lib/module/animated.js.map +1 -1
- package/lib/module/bindings.js +16 -0
- package/lib/module/bindings.js.map +1 -0
- package/lib/module/bindings.native.js +23 -0
- package/lib/module/bindings.native.js.map +1 -0
- package/lib/module/{native.js → constants.js} +1 -24
- package/lib/module/constants.js.map +1 -0
- package/lib/module/context.js +8 -1
- package/lib/module/context.js.map +1 -1
- package/lib/module/hooks.js +7 -6
- package/lib/module/hooks.js.map +1 -1
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal.js +1 -30
- package/lib/module/internal.js.map +1 -1
- package/lib/module/monkey-patch.android.js +29 -0
- package/lib/module/monkey-patch.android.js.map +1 -0
- package/lib/module/monkey-patch.js +1 -31
- package/lib/module/monkey-patch.js.map +1 -1
- package/lib/module/reanimated.js +2 -0
- package/lib/module/reanimated.js.map +1 -0
- package/lib/module/reanimated.native.js +30 -0
- package/lib/module/reanimated.native.js.map +1 -0
- package/lib/module/replicas.js +2 -1
- package/lib/module/replicas.js.map +1 -1
- package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/bindings.d.ts +6 -0
- package/lib/typescript/bindings.native.d.ts +6 -0
- package/lib/typescript/constants.d.ts +16 -0
- package/lib/typescript/context.d.ts +1 -0
- package/lib/typescript/index.d.ts +2 -1
- package/lib/typescript/internal.d.ts +1 -7
- package/lib/typescript/monkey-patch.android.d.ts +1 -0
- package/lib/typescript/monkey-patch.d.ts +0 -1
- package/lib/typescript/reanimated.d.ts +2 -0
- package/lib/typescript/reanimated.native.d.ts +2 -0
- package/lib/typescript/specs/KeyboardControllerViewNativeComponent.d.ts +3 -1
- package/lib/typescript/types.d.ts +15 -1
- package/package.json +1 -1
- package/react-native-keyboard-controller.podspec +9 -1
- package/src/animated.tsx +3 -6
- package/src/{native.ts → bindings.native.ts} +4 -25
- package/src/bindings.ts +22 -0
- package/src/constants.ts +17 -0
- package/src/context.ts +12 -1
- package/src/hooks.ts +12 -7
- package/src/index.ts +2 -1
- package/src/internal.ts +2 -57
- package/src/monkey-patch.android.ts +33 -0
- package/src/monkey-patch.ts +1 -37
- package/src/reanimated.native.ts +51 -0
- package/src/reanimated.ts +6 -0
- package/src/replicas.ts +2 -1
- package/src/specs/KeyboardControllerViewNativeComponent.ts +3 -0
- package/src/types.ts +27 -5
- package/lib/commonjs/native.js.map +0 -1
- package/lib/module/native.js.map +0 -1
- package/lib/typescript/native.d.ts +0 -24
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["codegenNativeComponent"],"sources":["KeyboardControllerViewNativeComponent.ts"],"sourcesContent":["import type { HostComponent } from 'react-native';\nimport type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';\nimport type {\n DirectEventHandler,\n Double,\n} from 'react-native/Libraries/Types/CodegenTypes';\nimport codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';\n\ntype KeyboardMoveEvent = Readonly<{\n height: Double;\n progress: Double;\n}>;\n\nexport interface NativeProps extends ViewProps {\n // props\n statusBarTranslucent?: boolean;\n navigationBarTranslucent?: boolean;\n // callbacks\n onKeyboardMoveStart?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMove?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMoveEnd?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMoveInteractive?: DirectEventHandler<KeyboardMoveEvent>;\n}\n\nexport default codegenNativeComponent<NativeProps>(\n 'KeyboardControllerView'\n) as HostComponent<NativeProps>;\n"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"names":["codegenNativeComponent"],"sources":["KeyboardControllerViewNativeComponent.ts"],"sourcesContent":["import type { HostComponent } from 'react-native';\nimport type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';\nimport type {\n DirectEventHandler,\n Double,\n Int32,\n} from 'react-native/Libraries/Types/CodegenTypes';\nimport codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';\n\ntype KeyboardMoveEvent = Readonly<{\n height: Double;\n progress: Double;\n duration: Int32;\n target: Int32;\n}>;\n\nexport interface NativeProps extends ViewProps {\n // props\n statusBarTranslucent?: boolean;\n navigationBarTranslucent?: boolean;\n // callbacks\n onKeyboardMoveStart?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMove?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMoveEnd?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMoveInteractive?: DirectEventHandler<KeyboardMoveEvent>;\n}\n\nexport default codegenNativeComponent<NativeProps>(\n 'KeyboardControllerView'\n) as HostComponent<NativeProps>;\n"],"mappings":";;;;;;AAOA;AAA6F;AAAA,eAoB9E,IAAAA,+BAAsB,EACnC,wBAAwB,CACzB;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {
|
|
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 EventWithName<T> = {\n eventName: string;\n} & T;\n\n// native View/Module declarations\nexport type KeyboardControllerProps = {\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 // fake prop used to activate reanimated bindings\n onKeyboardMoveReanimated?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>\n ) => void;\n statusBarTranslucent?: boolean;\n navigationBarTranslucent?: 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 KeyboardControllerModule = {\n // android only\n setDefaultMode: () => void;\n setInputMode: (mode: number) => 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};\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?: ReadonlyArray<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>;\n"],"mappings":""}
|
package/lib/module/animated.js
CHANGED
|
@@ -2,8 +2,9 @@ import React, { useMemo } from 'react';
|
|
|
2
2
|
import { Animated, Platform, StyleSheet } from 'react-native';
|
|
3
3
|
import Reanimated, { useSharedValue } from 'react-native-reanimated';
|
|
4
4
|
import { KeyboardContext } from './context';
|
|
5
|
-
import {
|
|
6
|
-
import { KeyboardControllerView } from './
|
|
5
|
+
import { useSharedHandlers, useAnimatedValue } from './internal';
|
|
6
|
+
import { KeyboardControllerView } from './bindings';
|
|
7
|
+
import { useAnimatedKeyboardHandler } from './reanimated';
|
|
7
8
|
const KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(Animated.createAnimatedComponent(KeyboardControllerView));
|
|
8
9
|
const styles = StyleSheet.create({
|
|
9
10
|
container: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useMemo","Animated","Platform","StyleSheet","Reanimated","useSharedValue","KeyboardContext","
|
|
1
|
+
{"version":3,"names":["React","useMemo","Animated","Platform","StyleSheet","Reanimated","useSharedValue","KeyboardContext","useSharedHandlers","useAnimatedValue","KeyboardControllerView","useAnimatedKeyboardHandler","KeyboardControllerViewAnimated","createAnimatedComponent","styles","create","container","flex","hidden","display","position","KeyboardProvider","children","statusBarTranslucent","navigationBarTranslucent","progress","height","progressSV","heightSV","setHandlers","broadcast","context","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","OS","value","handler","onKeyboardMoveStart","onKeyboardMoveEnd","onKeyboardMoveInteractive","undefined"],"sources":["animated.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport { Animated, Platform, StyleSheet, ViewStyle } from 'react-native';\nimport Reanimated, { useSharedValue } from 'react-native-reanimated';\n\nimport { KeyboardContext } from './context';\nimport { useSharedHandlers, useAnimatedValue } from './internal';\nimport { KeyboardControllerView } from './bindings';\nimport { useAnimatedKeyboardHandler } from './reanimated';\n\nimport type {\n KeyboardControllerProps,\n KeyboardHandler,\n NativeEvent,\n} from './types';\n\nconst KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(\n Animated.createAnimatedComponent(\n KeyboardControllerView\n ) as React.FC<KeyboardControllerProps>\n);\n\ntype Styles = {\n container: ViewStyle;\n hidden: ViewStyle;\n};\n\nconst styles = StyleSheet.create<Styles>({\n container: {\n flex: 1,\n },\n hidden: {\n display: 'none',\n position: 'absolute',\n },\n});\n\ntype KeyboardProviderProps = {\n children: React.ReactNode;\n /**\n * Set the value to `true`, if you use translucent status bar on Android.\n * If you already control status bar translucency via `react-native-screens`\n * or `StatusBar` component from `react-native`, you can ignore it.\n * Defaults to `false`.\n *\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/14\n * @platform android\n */\n statusBarTranslucent?: boolean;\n /**\n * Set the value to `true`, if you use translucent navigation bar on Android.\n * Defaults to `false`.\n *\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/119\n * @platform android\n */\n navigationBarTranslucent?: boolean;\n};\n\nexport const KeyboardProvider = ({\n children,\n statusBarTranslucent,\n navigationBarTranslucent,\n}: KeyboardProviderProps) => {\n // animated values\n const progress = useAnimatedValue(0);\n const height = useAnimatedValue(0);\n // shared values\n const progressSV = useSharedValue(0);\n const heightSV = useSharedValue(0);\n const { setHandlers, broadcast } = useSharedHandlers<KeyboardHandler>();\n // memo\n const context = useMemo(\n () => ({\n animated: { progress: progress, height: Animated.multiply(height, -1) },\n reanimated: { progress: progressSV, height: heightSV },\n setHandlers,\n }),\n []\n );\n const style = useMemo(\n () => [\n styles.hidden,\n { transform: [{ translateX: height }, { translateY: progress }] },\n ],\n []\n );\n const onKeyboardMove = useMemo(\n () =>\n Animated.event(\n [\n {\n nativeEvent: {\n progress,\n height,\n },\n },\n ],\n { useNativeDriver: true }\n ),\n []\n );\n // handlers\n const updateSharedValues = (event: NativeEvent, platforms: string[]) => {\n 'worklet';\n\n if (platforms.includes(Platform.OS)) {\n progressSV.value = event.progress;\n heightSV.value = -event.height;\n }\n };\n const handler = useAnimatedKeyboardHandler(\n {\n onKeyboardMoveStart: (event: NativeEvent) => {\n 'worklet';\n\n broadcast('onStart', event);\n updateSharedValues(event, ['ios']);\n },\n onKeyboardMove: (event: NativeEvent) => {\n 'worklet';\n\n broadcast('onMove', event);\n updateSharedValues(event, ['android']);\n },\n onKeyboardMoveEnd: (event: NativeEvent) => {\n 'worklet';\n\n broadcast('onEnd', event);\n },\n onKeyboardMoveInteractive: (event: NativeEvent) => {\n 'worklet';\n\n updateSharedValues(event, ['android', 'ios']);\n broadcast('onInteractive', event);\n },\n },\n []\n );\n\n return (\n <KeyboardContext.Provider value={context}>\n <KeyboardControllerViewAnimated\n onKeyboardMoveReanimated={handler}\n onKeyboardMoveStart={Platform.OS === 'ios' ? onKeyboardMove : undefined}\n onKeyboardMove={Platform.OS === 'android' ? onKeyboardMove : undefined}\n onKeyboardMoveInteractive={onKeyboardMove}\n navigationBarTranslucent={navigationBarTranslucent}\n statusBarTranslucent={statusBarTranslucent}\n // @ts-expect-error will be fixed when migrate to REA 3.3.0\n style={styles.container}\n >\n {children}\n </KeyboardControllerViewAnimated>\n <Animated.View\n // we are using this small hack, because if the component (where\n // animated value has been used) is unmounted, then animation will\n // stop receiving events (seems like it's react-native optimization).\n // So we need to keep a reference to the animated value, to keep it's\n // always mounted (keep a reference to an animated value).\n //\n // To test why it's needed, try to open screen which consumes Animated.Value\n // then close it and open it again (for example 'Animated transition').\n style={style}\n />\n </KeyboardContext.Provider>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,OAAO,QAAQ,OAAO;AACtC,SAASC,QAAQ,EAAEC,QAAQ,EAAEC,UAAU,QAAmB,cAAc;AACxE,OAAOC,UAAU,IAAIC,cAAc,QAAQ,yBAAyB;AAEpE,SAASC,eAAe,QAAQ,WAAW;AAC3C,SAASC,iBAAiB,EAAEC,gBAAgB,QAAQ,YAAY;AAChE,SAASC,sBAAsB,QAAQ,YAAY;AACnD,SAASC,0BAA0B,QAAQ,cAAc;AAQzD,MAAMC,8BAA8B,GAAGP,UAAU,CAACQ,uBAAuB,CACvEX,QAAQ,CAACW,uBAAuB,CAC9BH,sBAAsB,CACvB,CACF;AAOD,MAAMI,MAAM,GAAGV,UAAU,CAACW,MAAM,CAAS;EACvCC,SAAS,EAAE;IACTC,IAAI,EAAE;EACR,CAAC;EACDC,MAAM,EAAE;IACNC,OAAO,EAAE,MAAM;IACfC,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC;AAwBF,OAAO,MAAMC,gBAAgB,GAAG,QAIH;EAAA,IAJI;IAC/BC,QAAQ;IACRC,oBAAoB;IACpBC;EACqB,CAAC;EACtB;EACA,MAAMC,QAAQ,GAAGhB,gBAAgB,CAAC,CAAC,CAAC;EACpC,MAAMiB,MAAM,GAAGjB,gBAAgB,CAAC,CAAC,CAAC;EAClC;EACA,MAAMkB,UAAU,GAAGrB,cAAc,CAAC,CAAC,CAAC;EACpC,MAAMsB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MAC3BG,kBAAkB,CAACH,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IACDD,cAAc,EAAGC,KAAkB,IAAK;MACtC,SAAS;;MAETV,SAAS,CAAC,QAAQ,EAAEU,KAAK,CAAC;MAC1BG,kBAAkB,CAACH,KAAK,EAAE,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;IACDU,iBAAiB,EAAGV,KAAkB,IAAK;MACzC,SAAS;;MAETV,SAAS,CAAC,OAAO,EAAEU,KAAK,CAAC;IAC3B,CAAC;IACDW,yBAAyB,EAAGX,KAAkB,IAAK;MACjD,SAAS;;MAETG,kBAAkB,CAACH,KAAK,EAAE,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;MAC7CV,SAAS,CAAC,eAAe,EAAEU,KAAK,CAAC;IACnC;EACF,CAAC,EACD,EAAE,CACH;EAED,oBACE,oBAAC,eAAe,CAAC,QAAQ;IAAC,KAAK,EAAET;EAAQ,gBACvC,oBAAC,8BAA8B;IAC7B,wBAAwB,EAAEiB,OAAQ;IAClC,mBAAmB,EAAE7C,QAAQ,CAAC2C,EAAE,KAAK,KAAK,GAAGP,cAAc,GAAGa,SAAU;IACxE,cAAc,EAAEjD,QAAQ,CAAC2C,EAAE,KAAK,SAAS,GAAGP,cAAc,GAAGa,SAAU;IACvE,yBAAyB,EAAEb,cAAe;IAC1C,wBAAwB,EAAEf,wBAAyB;IACnD,oBAAoB,EAAED;IACtB;IAAA;IACA,KAAK,EAAET,MAAM,CAACE;EAAU,GAEvBM,QAAQ,CACsB,eACjC,oBAAC,QAAQ,CAAC,IAAI;IACZ;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,KAAK,EAAEa;EAAM,EACb,CACuB;AAE/B,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { View } from 'react-native';
|
|
2
|
+
const NOOP = () => {};
|
|
3
|
+
export const KeyboardController = {
|
|
4
|
+
setDefaultMode: NOOP,
|
|
5
|
+
setInputMode: NOOP,
|
|
6
|
+
addListener: NOOP,
|
|
7
|
+
removeListeners: NOOP
|
|
8
|
+
};
|
|
9
|
+
export const KeyboardEvents = {
|
|
10
|
+
addListener: () => ({
|
|
11
|
+
remove: NOOP
|
|
12
|
+
})
|
|
13
|
+
};
|
|
14
|
+
export const KeyboardControllerView = View;
|
|
15
|
+
export const KeyboardGestureArea = View;
|
|
16
|
+
//# sourceMappingURL=bindings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["View","NOOP","KeyboardController","setDefaultMode","setInputMode","addListener","removeListeners","KeyboardEvents","remove","KeyboardControllerView","KeyboardGestureArea"],"sources":["bindings.ts"],"sourcesContent":["import { EmitterSubscription, View } from 'react-native';\nimport type {\n KeyboardControllerModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardGestureAreaProps,\n} from './types';\n\nconst NOOP = () => {};\nexport const KeyboardController: KeyboardControllerModule = {\n setDefaultMode: NOOP,\n setInputMode: NOOP,\n addListener: NOOP,\n removeListeners: NOOP,\n};\nexport const KeyboardEvents: KeyboardEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\nexport const KeyboardControllerView =\n View as unknown as React.FC<KeyboardControllerProps>;\nexport const KeyboardGestureArea =\n View as unknown as React.FC<KeyboardGestureAreaProps>;\n"],"mappings":"AAAA,SAA8BA,IAAI,QAAQ,cAAc;AAQxD,MAAMC,IAAI,GAAG,MAAM,CAAC,CAAC;AACrB,OAAO,MAAMC,kBAA4C,GAAG;EAC1DC,cAAc,EAAEF,IAAI;EACpBG,YAAY,EAAEH,IAAI;EAClBI,WAAW,EAAEJ,IAAI;EACjBK,eAAe,EAAEL;AACnB,CAAC;AACD,OAAO,MAAMM,cAAoC,GAAG;EAClDF,WAAW,EAAE,OAAO;IAAEG,MAAM,EAAEP;EAAK,CAAC;AACtC,CAAC;AACD,OAAO,MAAMQ,sBAAsB,GACjCT,IAAoD;AACtD,OAAO,MAAMU,mBAAmB,GAC9BV,IAAqD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Platform, NativeEventEmitter } from 'react-native';
|
|
2
|
+
const LINKING_ERROR = `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
|
3
|
+
ios: "- You have run 'pod install'\n",
|
|
4
|
+
default: ''
|
|
5
|
+
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
6
|
+
const RCTKeyboardController = require('./specs/NativeKeyboardController').default;
|
|
7
|
+
export const KeyboardController = RCTKeyboardController ? RCTKeyboardController : new Proxy({}, {
|
|
8
|
+
get() {
|
|
9
|
+
throw new Error(LINKING_ERROR);
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
const eventEmitter = new NativeEventEmitter(KeyboardController);
|
|
13
|
+
export const KeyboardEvents = {
|
|
14
|
+
addListener: (name, cb) => eventEmitter.addListener('KeyboardController::' + name, cb)
|
|
15
|
+
};
|
|
16
|
+
export const KeyboardControllerView = require('./specs/KeyboardControllerViewNativeComponent').default;
|
|
17
|
+
export const KeyboardGestureArea = Platform.OS === 'android' && Platform.Version >= 30 ? require('./specs/KeyboardGestureAreaNativeComponent').default : _ref => {
|
|
18
|
+
let {
|
|
19
|
+
children
|
|
20
|
+
} = _ref;
|
|
21
|
+
return children;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=bindings.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Platform","NativeEventEmitter","LINKING_ERROR","select","ios","default","RCTKeyboardController","require","KeyboardController","Proxy","get","Error","eventEmitter","KeyboardEvents","addListener","name","cb","KeyboardControllerView","KeyboardGestureArea","OS","Version","children"],"sources":["bindings.native.ts"],"sourcesContent":["import { Platform, NativeEventEmitter } from 'react-native';\n\nimport type {\n KeyboardControllerModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardGestureAreaProps,\n} from './types';\n\nconst LINKING_ERROR =\n `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo Go\\n';\n\nconst RCTKeyboardController =\n require('./specs/NativeKeyboardController').default;\nexport const KeyboardController = (\n RCTKeyboardController\n ? RCTKeyboardController\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n )\n) as KeyboardControllerModule;\n\nconst eventEmitter = new NativeEventEmitter(KeyboardController);\n\nexport const KeyboardEvents: KeyboardEventsModule = {\n addListener: (name, cb) =>\n eventEmitter.addListener('KeyboardController::' + name, cb),\n};\nexport const KeyboardControllerView: React.FC<KeyboardControllerProps> =\n require('./specs/KeyboardControllerViewNativeComponent').default;\nexport const KeyboardGestureArea: React.FC<KeyboardGestureAreaProps> =\n Platform.OS === 'android' && Platform.Version >= 30\n ? require('./specs/KeyboardGestureAreaNativeComponent').default\n : ({ children }: KeyboardGestureAreaProps) => children;\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,kBAAkB,QAAQ,cAAc;AAS3D,MAAMC,aAAa,GAChB,2FAA0F,GAC3FF,QAAQ,CAACG,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,qBAAqB,GACzBC,OAAO,CAAC,kCAAkC,CAAC,CAACF,OAAO;AACrD,OAAO,MAAMG,kBAAkB,GAC7BF,qBAAqB,GACjBA,qBAAqB,GACrB,IAAIG,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAK,CAACT,aAAa,CAAC;EAChC;AACF,CAAC,CAEoB;AAE7B,MAAMU,YAAY,GAAG,IAAIX,kBAAkB,CAACO,kBAAkB,CAAC;AAE/D,OAAO,MAAMK,cAAoC,GAAG;EAClDC,WAAW,EAAE,CAACC,IAAI,EAAEC,EAAE,KACpBJ,YAAY,CAACE,WAAW,CAAC,sBAAsB,GAAGC,IAAI,EAAEC,EAAE;AAC9D,CAAC;AACD,OAAO,MAAMC,sBAAyD,GACpEV,OAAO,CAAC,+CAA+C,CAAC,CAACF,OAAO;AAClE,OAAO,MAAMa,mBAAuD,GAClElB,QAAQ,CAACmB,EAAE,KAAK,SAAS,IAAInB,QAAQ,CAACoB,OAAO,IAAI,EAAE,GAC/Cb,OAAO,CAAC,4CAA4C,CAAC,CAACF,OAAO,GAC7D;EAAA,IAAC;IAAEgB;EAAmC,CAAC;EAAA,OAAKA,QAAQ;AAAA"}
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import { Platform, NativeEventEmitter } from 'react-native';
|
|
2
|
-
const LINKING_ERROR = `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
|
3
|
-
ios: "- You have run 'pod install'\n",
|
|
4
|
-
default: ''
|
|
5
|
-
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
6
|
-
|
|
7
1
|
// copied from `android.view.WindowManager.LayoutParams`
|
|
8
2
|
export let AndroidSoftInputModes;
|
|
9
3
|
(function (AndroidSoftInputModes) {
|
|
@@ -22,21 +16,4 @@ export let AndroidSoftInputModes;
|
|
|
22
16
|
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_UNSPECIFIED"] = 0] = "SOFT_INPUT_STATE_UNSPECIFIED";
|
|
23
17
|
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_VISIBLE"] = 4] = "SOFT_INPUT_STATE_VISIBLE";
|
|
24
18
|
})(AndroidSoftInputModes || (AndroidSoftInputModes = {}));
|
|
25
|
-
|
|
26
|
-
export const KeyboardController = RCTKeyboardController ? RCTKeyboardController : new Proxy({}, {
|
|
27
|
-
get() {
|
|
28
|
-
throw new Error(LINKING_ERROR);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
const eventEmitter = new NativeEventEmitter(KeyboardController);
|
|
32
|
-
export const KeyboardEvents = {
|
|
33
|
-
addListener: (name, cb) => eventEmitter.addListener('KeyboardController::' + name, cb)
|
|
34
|
-
};
|
|
35
|
-
export const KeyboardControllerView = require('./specs/KeyboardControllerViewNativeComponent').default;
|
|
36
|
-
export const KeyboardGestureArea = Platform.OS === 'android' && Platform.Version >= 30 ? require('./specs/KeyboardGestureAreaNativeComponent').default : _ref => {
|
|
37
|
-
let {
|
|
38
|
-
children
|
|
39
|
-
} = _ref;
|
|
40
|
-
return children;
|
|
41
|
-
};
|
|
42
|
-
//# sourceMappingURL=native.js.map
|
|
19
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["AndroidSoftInputModes"],"sources":["constants.ts"],"sourcesContent":["// copied from `android.view.WindowManager.LayoutParams`\nexport enum AndroidSoftInputModes {\n SOFT_INPUT_ADJUST_NOTHING = 48,\n SOFT_INPUT_ADJUST_PAN = 32,\n SOFT_INPUT_ADJUST_RESIZE = 16,\n SOFT_INPUT_ADJUST_UNSPECIFIED = 0,\n SOFT_INPUT_IS_FORWARD_NAVIGATION = 256,\n SOFT_INPUT_MASK_ADJUST = 240,\n SOFT_INPUT_MASK_STATE = 15,\n SOFT_INPUT_MODE_CHANGED = 512,\n SOFT_INPUT_STATE_ALWAYS_HIDDEN = 3,\n SOFT_INPUT_STATE_ALWAYS_VISIBLE = 5,\n SOFT_INPUT_STATE_HIDDEN = 2,\n SOFT_INPUT_STATE_UNCHANGED = 1,\n SOFT_INPUT_STATE_UNSPECIFIED = 0,\n SOFT_INPUT_STATE_VISIBLE = 4,\n}\n"],"mappings":"AAAA;AACA,WAAYA,qBAAqB;AAehC,WAfWA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;AAAA,GAArBA,qBAAqB,KAArBA,qBAAqB"}
|
package/lib/module/context.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createContext } from 'react';
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
2
|
import { Animated } from 'react-native';
|
|
3
3
|
const defaultContext = {
|
|
4
4
|
animated: {
|
|
@@ -16,4 +16,11 @@ const defaultContext = {
|
|
|
16
16
|
setHandlers: () => {}
|
|
17
17
|
};
|
|
18
18
|
export const KeyboardContext = /*#__PURE__*/createContext(defaultContext);
|
|
19
|
+
export const useKeyboardContext = () => {
|
|
20
|
+
const context = useContext(KeyboardContext);
|
|
21
|
+
if (__DEV__ && context === defaultContext) {
|
|
22
|
+
console.warn("Couldn't find real values for `KeyboardContext`. Please make sure you're inside of `KeyboardProvider` - otherwise functionality of `react-native-keyboard-controller` will not work.");
|
|
23
|
+
}
|
|
24
|
+
return context;
|
|
25
|
+
};
|
|
19
26
|
//# sourceMappingURL=context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createContext","Animated","defaultContext","animated","progress","Value","height","reanimated","value","setHandlers","KeyboardContext"],"sources":["context.ts"],"sourcesContent":["import { createContext } from 'react';\nimport { Animated } from 'react-native';\n\nimport type { SharedValue } from 'react-native-reanimated';\nimport type { KeyboardHandlers } from './types';\n\nexport type AnimatedContext = {\n progress: Animated.Value;\n height: Animated.AnimatedMultiplication<number>;\n};\nexport type ReanimatedContext = {\n progress: SharedValue<number>;\n height: SharedValue<number>;\n};\nexport type KeyboardAnimationContext = {\n animated: AnimatedContext;\n reanimated: ReanimatedContext;\n setHandlers: (handlers: KeyboardHandlers) => void;\n};\nconst defaultContext: KeyboardAnimationContext = {\n animated: {\n progress: new Animated.Value(0),\n height: new Animated.Value(0),\n },\n reanimated: {\n progress: { value: 0 },\n height: { value: 0 },\n },\n setHandlers: () => {},\n};\nexport const KeyboardContext = createContext(defaultContext);\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,OAAO;
|
|
1
|
+
{"version":3,"names":["createContext","useContext","Animated","defaultContext","animated","progress","Value","height","reanimated","value","setHandlers","KeyboardContext","useKeyboardContext","context","__DEV__","console","warn"],"sources":["context.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\nimport { Animated } from 'react-native';\n\nimport type { SharedValue } from 'react-native-reanimated';\nimport type { KeyboardHandlers } from './types';\n\nexport type AnimatedContext = {\n progress: Animated.Value;\n height: Animated.AnimatedMultiplication<number>;\n};\nexport type ReanimatedContext = {\n progress: SharedValue<number>;\n height: SharedValue<number>;\n};\nexport type KeyboardAnimationContext = {\n animated: AnimatedContext;\n reanimated: ReanimatedContext;\n setHandlers: (handlers: KeyboardHandlers) => void;\n};\nconst defaultContext: KeyboardAnimationContext = {\n animated: {\n progress: new Animated.Value(0),\n height: new Animated.Value(0),\n },\n reanimated: {\n progress: { value: 0 },\n height: { value: 0 },\n },\n setHandlers: () => {},\n};\nexport const KeyboardContext = createContext(defaultContext);\nexport const useKeyboardContext = () => {\n const context = useContext(KeyboardContext);\n\n if (__DEV__ && context === defaultContext) {\n console.warn(\n \"Couldn't find real values for `KeyboardContext`. Please make sure you're inside of `KeyboardProvider` - otherwise functionality of `react-native-keyboard-controller` will not work.\"\n );\n }\n\n return context;\n};\n"],"mappings":"AAAA,SAASA,aAAa,EAAEC,UAAU,QAAQ,OAAO;AACjD,SAASC,QAAQ,QAAQ,cAAc;AAkBvC,MAAMC,cAAwC,GAAG;EAC/CC,QAAQ,EAAE;IACRC,QAAQ,EAAE,IAAIH,QAAQ,CAACI,KAAK,CAAC,CAAC,CAAC;IAC/BC,MAAM,EAAE,IAAIL,QAAQ,CAACI,KAAK,CAAC,CAAC;EAC9B,CAAC;EACDE,UAAU,EAAE;IACVH,QAAQ,EAAE;MAAEI,KAAK,EAAE;IAAE,CAAC;IACtBF,MAAM,EAAE;MAAEE,KAAK,EAAE;IAAE;EACrB,CAAC;EACDC,WAAW,EAAE,MAAM,CAAC;AACtB,CAAC;AACD,OAAO,MAAMC,eAAe,gBAAGX,aAAa,CAACG,cAAc,CAAC;AAC5D,OAAO,MAAMS,kBAAkB,GAAG,MAAM;EACtC,MAAMC,OAAO,GAAGZ,UAAU,CAACU,eAAe,CAAC;EAE3C,IAAIG,OAAO,IAAID,OAAO,KAAKV,cAAc,EAAE;IACzCY,OAAO,CAACC,IAAI,CACV,sLAAsL,CACvL;EACH;EAEA,OAAOH,OAAO;AAChB,CAAC"}
|
package/lib/module/hooks.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { useKeyboardContext } from './context';
|
|
3
|
+
import { KeyboardController } from './bindings';
|
|
4
|
+
import { AndroidSoftInputModes } from './constants';
|
|
4
5
|
import { uuid } from './utils';
|
|
5
6
|
export const useResizeMode = () => {
|
|
6
7
|
useEffect(() => {
|
|
@@ -10,16 +11,16 @@ export const useResizeMode = () => {
|
|
|
10
11
|
};
|
|
11
12
|
export const useKeyboardAnimation = () => {
|
|
12
13
|
useResizeMode();
|
|
13
|
-
const context =
|
|
14
|
+
const context = useKeyboardContext();
|
|
14
15
|
return context.animated;
|
|
15
16
|
};
|
|
16
17
|
export const useReanimatedKeyboardAnimation = () => {
|
|
17
18
|
useResizeMode();
|
|
18
|
-
const context =
|
|
19
|
+
const context = useKeyboardContext();
|
|
19
20
|
return context.reanimated;
|
|
20
21
|
};
|
|
21
22
|
export function useGenericKeyboardHandler(handler, deps) {
|
|
22
|
-
const context =
|
|
23
|
+
const context = useKeyboardContext();
|
|
23
24
|
useEffect(() => {
|
|
24
25
|
const key = uuid();
|
|
25
26
|
context.setHandlers({
|
package/lib/module/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["useEffect","useKeyboardContext","KeyboardController","AndroidSoftInputModes","uuid","useResizeMode","setInputMode","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","useKeyboardAnimation","context","animated","useReanimatedKeyboardAnimation","reanimated","useGenericKeyboardHandler","handler","deps","key","setHandlers","undefined","useKeyboardHandler"],"sources":["hooks.ts"],"sourcesContent":["import { DependencyList, useEffect } from 'react';\n\nimport {\n AnimatedContext,\n ReanimatedContext,\n useKeyboardContext,\n} from './context';\nimport { KeyboardController } from './bindings';\nimport { AndroidSoftInputModes } from './constants';\nimport { uuid } from './utils';\n\nimport type { KeyboardHandler } from './types';\n\nexport const useResizeMode = () => {\n useEffect(() => {\n KeyboardController.setInputMode(\n AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE\n );\n\n return () => KeyboardController.setDefaultMode();\n }, []);\n};\n\nexport const useKeyboardAnimation = (): AnimatedContext => {\n useResizeMode();\n const context = useKeyboardContext();\n\n return context.animated;\n};\n\nexport const useReanimatedKeyboardAnimation = (): ReanimatedContext => {\n useResizeMode();\n const context = useKeyboardContext();\n\n return context.reanimated;\n};\n\nexport function useGenericKeyboardHandler(\n handler: KeyboardHandler,\n deps?: DependencyList\n) {\n const context = useKeyboardContext();\n\n useEffect(() => {\n const key = uuid();\n\n context.setHandlers({ [key]: handler });\n\n return () => {\n context.setHandlers({ [key]: undefined });\n };\n }, deps);\n}\n\nexport function useKeyboardHandler(\n handler: KeyboardHandler,\n deps?: DependencyList\n) {\n useResizeMode();\n useGenericKeyboardHandler(handler, deps);\n}\n"],"mappings":"AAAA,SAAyBA,SAAS,QAAQ,OAA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
2
|
-
export * from './
|
|
2
|
+
export * from './bindings';
|
|
3
3
|
export * from './animated';
|
|
4
4
|
export * from './replicas';
|
|
5
5
|
export * from './context';
|
|
6
6
|
export * from './hooks';
|
|
7
|
+
export * from './constants';
|
|
7
8
|
export * from './types';
|
|
8
9
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import './monkey-patch';\n\nexport * from './
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import './monkey-patch';\n\nexport * from './bindings';\nexport * from './animated';\nexport * from './replicas';\nexport * from './context';\nexport * from './hooks';\nexport * from './constants';\nexport * from './types';\n"],"mappings":"AAAA,OAAO,gBAAgB;AAEvB,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,SAAS"}
|
package/lib/module/internal.js
CHANGED
|
@@ -1,35 +1,6 @@
|
|
|
1
1
|
import { useCallback, useRef } from 'react';
|
|
2
2
|
import { Animated } from 'react-native';
|
|
3
|
-
import {
|
|
4
|
-
export function useAnimatedKeyboardHandler(handlers, dependencies) {
|
|
5
|
-
const {
|
|
6
|
-
context,
|
|
7
|
-
doDependenciesDiffer
|
|
8
|
-
} = useHandler(handlers, dependencies);
|
|
9
|
-
return useEvent(event => {
|
|
10
|
-
'worklet';
|
|
11
|
-
|
|
12
|
-
const {
|
|
13
|
-
onKeyboardMoveStart,
|
|
14
|
-
onKeyboardMove,
|
|
15
|
-
onKeyboardMoveEnd,
|
|
16
|
-
onKeyboardMoveInteractive
|
|
17
|
-
} = handlers;
|
|
18
|
-
if (onKeyboardMoveStart && event.eventName.endsWith('onKeyboardMoveStart')) {
|
|
19
|
-
onKeyboardMoveStart(event, context);
|
|
20
|
-
}
|
|
21
|
-
if (onKeyboardMove && event.eventName.endsWith('onKeyboardMove')) {
|
|
22
|
-
onKeyboardMove(event, context);
|
|
23
|
-
}
|
|
24
|
-
if (onKeyboardMoveEnd && event.eventName.endsWith('onKeyboardMoveEnd')) {
|
|
25
|
-
onKeyboardMoveEnd(event, context);
|
|
26
|
-
}
|
|
27
|
-
if (onKeyboardMoveInteractive && event.eventName.endsWith('onKeyboardMoveInteractive')) {
|
|
28
|
-
onKeyboardMoveInteractive(event, context);
|
|
29
|
-
}
|
|
30
|
-
}, ['onKeyboardMoveStart', 'onKeyboardMove', 'onKeyboardMoveEnd', 'onKeyboardMoveInteractive'], doDependenciesDiffer);
|
|
31
|
-
}
|
|
32
|
-
|
|
3
|
+
import { useSharedValue } from 'react-native-reanimated';
|
|
33
4
|
/**
|
|
34
5
|
* Hook for storing worklet handlers (objects with keys, where values are worklets).
|
|
35
6
|
* Returns methods for setting handlers and broadcasting events in them.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useCallback","useRef","Animated","
|
|
1
|
+
{"version":3,"names":["useCallback","useRef","Animated","useSharedValue","useSharedHandlers","handlers","jsHandlers","updateSharedHandlers","value","current","setHandlers","handler","broadcast","type","event","Object","keys","forEach","key","useAnimatedValue","initialValue","config","ref","Value"],"sources":["internal.ts"],"sourcesContent":["import { useCallback, useRef } from 'react';\nimport { Animated } from 'react-native';\nimport { useSharedValue } from 'react-native-reanimated';\n\nimport type { Handlers, NativeEvent } from './types';\n\n/**\n * Hook for storing worklet handlers (objects with keys, where values are worklets).\n * Returns methods for setting handlers and broadcasting events in them.\n *\n * T is a generic that looks like:\n * @example\n * {\n * onEvent: () => {},\n * onEvent2: () => {},\n * }\n */\nexport function useSharedHandlers<T extends Record<string, Function>>() {\n const handlers = useSharedValue<Handlers<T>>({});\n const jsHandlers = useRef<Handlers<T>>({});\n\n // since js -> worklet -> js call is asynchronous, we can not write handlers\n // straight into shared variable (using current shared value as a previous result),\n // since there may be a race condition in a call, and closure may have out-of-dated\n // values. As a result, some of handlers may be not written to \"all handlers\" object.\n // Below we are writing all handlers to `ref` and afterwards synchronize them with\n // shared value (since `refs` are not referring to actual value in worklets).\n // This approach allow us to update synchronously handlers in js thread (and it assures,\n // that it will have all of them) and then update them in worklet thread (calls are\n // happening in FIFO order, so we will always have actual value).\n const updateSharedHandlers = () => {\n handlers.value = jsHandlers.current;\n };\n const setHandlers = useCallback((handler: Handlers<T>) => {\n jsHandlers.current = {\n ...jsHandlers.current,\n ...handler,\n };\n updateSharedHandlers();\n }, []);\n const broadcast = (type: keyof T, event: NativeEvent) => {\n 'worklet';\n\n Object.keys(handlers.value).forEach((key) =>\n handlers.value[key]?.[type]?.(event)\n );\n };\n\n return { setHandlers, broadcast };\n}\n\n/**\n * TS variant of `useAnimatedValue` hook which is added in RN 0.71\n * A better alternative of storing animated values in refs, since\n * it doesn't recreate a new `Animated.Value` object on every re-render\n * and therefore consumes less memory. We can not use a variant from\n * RN, since this library supports earlier versions of RN.\n *\n * @see https://github.com/facebook/react-native/commit/e22217fe8b9455e32695f88ca835e11442b0a937\n */\nexport function useAnimatedValue(\n initialValue: number,\n config?: Animated.AnimatedConfig\n): Animated.Value {\n const ref = useRef<Animated.Value | null>(null);\n\n if (ref.current == null) {\n ref.current = new Animated.Value(initialValue, config);\n }\n\n return ref.current;\n}\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,MAAM,QAAQ,OAAO;AAC3C,SAASC,QAAQ,QAAQ,cAAc;AACvC,SAASC,cAAc,QAAQ,yBAAyB;AAIxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiB,GAAuC;EACtE,MAAMC,QAAQ,GAAGF,cAAc,CAAc,CAAC,CAAC,CAAC;EAChD,MAAMG,UAAU,GAAGL,MAAM,CAAc,CAAC,CAAC,CAAC;;EAE1C;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,MAAMM,oBAAoB,GAAG,MAAM;IACjCF,QAAQ,CAACG,KAAK,GAAGF,UAAU,CAACG,OAAO;EACrC,CAAC;EACD,MAAMC,WAAW,GAAGV,WAAW,CAAEW,OAAoB,IAAK;IACxDL,UAAU,CAACG,OAAO,GAAG;MACnB,GAAGH,UAAU,CAACG,OAAO;MACrB,GAAGE;IACL,CAAC;IACDJ,oBAAoB,EAAE;EACxB,CAAC,EAAE,EAAE,CAAC;EACN,MAAMK,SAAS,GAAG,CAACC,IAAa,EAAEC,KAAkB,KAAK;IACvD,SAAS;;IAETC,MAAM,CAACC,IAAI,CAACX,QAAQ,CAACG,KAAK,CAAC,CAACS,OAAO,CAAEC,GAAG;MAAA;MAAA,8BACtCb,QAAQ,CAACG,KAAK,CAACU,GAAG,CAAC,iFAAnB,oBAAsBL,IAAI,CAAC,0DAA3B,gDAA8BC,KAAK,CAAC;IAAA,EACrC;EACH,CAAC;EAED,OAAO;IAAEJ,WAAW;IAAEE;EAAU,CAAC;AACnC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASO,gBAAgB,CAC9BC,YAAoB,EACpBC,MAAgC,EAChB;EAChB,MAAMC,GAAG,GAAGrB,MAAM,CAAwB,IAAI,CAAC;EAE/C,IAAIqB,GAAG,CAACb,OAAO,IAAI,IAAI,EAAE;IACvBa,GAAG,CAACb,OAAO,GAAG,IAAIP,QAAQ,CAACqB,KAAK,CAACH,YAAY,EAAEC,MAAM,CAAC;EACxD;EAEA,OAAOC,GAAG,CAACb,OAAO;AACpB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// @ts-expect-error because there is no corresponding type definition
|
|
2
|
+
import * as NativeAndroidManager from 'react-native/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid';
|
|
3
|
+
const getConstants = NativeAndroidManager.default.getConstants;
|
|
4
|
+
|
|
5
|
+
// On Android < 11 RN uses legacy API which breaks EdgeToEdge mode in RN, so
|
|
6
|
+
// in order to use library on all available platforms we have to monkey patch
|
|
7
|
+
// default RN implementation and use modern `WindowInsetsControllerCompat`.
|
|
8
|
+
const RCTStatusBarManagerCompat = require('./specs/NativeStatusBarManagerCompat').default;
|
|
9
|
+
NativeAndroidManager.default = {
|
|
10
|
+
getConstants,
|
|
11
|
+
setColor(color, animated) {
|
|
12
|
+
RCTStatusBarManagerCompat.setColor(color, animated);
|
|
13
|
+
},
|
|
14
|
+
setTranslucent(translucent) {
|
|
15
|
+
RCTStatusBarManagerCompat.setTranslucent(translucent);
|
|
16
|
+
},
|
|
17
|
+
/**
|
|
18
|
+
* - statusBarStyles can be:
|
|
19
|
+
* - 'default'
|
|
20
|
+
* - 'dark-content'
|
|
21
|
+
*/
|
|
22
|
+
setStyle(statusBarStyle) {
|
|
23
|
+
RCTStatusBarManagerCompat.setStyle(statusBarStyle);
|
|
24
|
+
},
|
|
25
|
+
setHidden(hidden) {
|
|
26
|
+
RCTStatusBarManagerCompat.setHidden(hidden);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=monkey-patch.android.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NativeAndroidManager","getConstants","default","RCTStatusBarManagerCompat","require","setColor","color","animated","setTranslucent","translucent","setStyle","statusBarStyle","setHidden","hidden"],"sources":["monkey-patch.android.ts"],"sourcesContent":["// @ts-expect-error because there is no corresponding type definition\nimport * as NativeAndroidManager from 'react-native/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid';\n\nconst getConstants = NativeAndroidManager.default.getConstants;\n\n// On Android < 11 RN uses legacy API which breaks EdgeToEdge mode in RN, so\n// in order to use library on all available platforms we have to monkey patch\n// default RN implementation and use modern `WindowInsetsControllerCompat`.\nconst RCTStatusBarManagerCompat =\n require('./specs/NativeStatusBarManagerCompat').default;\nNativeAndroidManager.default = {\n getConstants,\n setColor(color: number, animated: boolean): void {\n RCTStatusBarManagerCompat.setColor(color, animated);\n },\n\n setTranslucent(translucent: boolean): void {\n RCTStatusBarManagerCompat.setTranslucent(translucent);\n },\n\n /**\n * - statusBarStyles can be:\n * - 'default'\n * - 'dark-content'\n */\n setStyle(statusBarStyle?: string): void {\n RCTStatusBarManagerCompat.setStyle(statusBarStyle);\n },\n\n setHidden(hidden: boolean): void {\n RCTStatusBarManagerCompat.setHidden(hidden);\n },\n};\n"],"mappings":"AAAA;AACA,OAAO,KAAKA,oBAAoB,MAAM,2EAA2E;AAEjH,MAAMC,YAAY,GAAGD,oBAAoB,CAACE,OAAO,CAACD,YAAY;;AAE9D;AACA;AACA;AACA,MAAME,yBAAyB,GAC7BC,OAAO,CAAC,sCAAsC,CAAC,CAACF,OAAO;AACzDF,oBAAoB,CAACE,OAAO,GAAG;EAC7BD,YAAY;EACZI,QAAQ,CAACC,KAAa,EAAEC,QAAiB,EAAQ;IAC/CJ,yBAAyB,CAACE,QAAQ,CAACC,KAAK,EAAEC,QAAQ,CAAC;EACrD,CAAC;EAEDC,cAAc,CAACC,WAAoB,EAAQ;IACzCN,yBAAyB,CAACK,cAAc,CAACC,WAAW,CAAC;EACvD,CAAC;EAED;AACF;AACA;AACA;AACA;EACEC,QAAQ,CAACC,cAAuB,EAAQ;IACtCR,yBAAyB,CAACO,QAAQ,CAACC,cAAc,CAAC;EACpD,CAAC;EAEDC,SAAS,CAACC,MAAe,EAAQ;IAC/BV,yBAAyB,CAACS,SAAS,CAACC,MAAM,CAAC;EAC7C;AACF,CAAC"}
|
|
@@ -1,32 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
// @ts-expect-error because there is no corresponding type definition
|
|
3
|
-
import * as NativeAndroidManager from 'react-native/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid';
|
|
4
|
-
const getConstants = NativeAndroidManager.default.getConstants;
|
|
5
|
-
const RCTStatusBarManagerCompat = require('./specs/NativeStatusBarManagerCompat').default;
|
|
6
|
-
|
|
7
|
-
// On Android < 11 RN uses legacy API which breaks EdgeToEdge mode in RN, so
|
|
8
|
-
// in order to use library on all available platforms we have to monkey patch
|
|
9
|
-
// default RN implementation and use modern `WindowInsetsControllerCompat`.
|
|
10
|
-
if (Platform.OS === 'android') {
|
|
11
|
-
NativeAndroidManager.default = {
|
|
12
|
-
getConstants,
|
|
13
|
-
setColor(color, animated) {
|
|
14
|
-
RCTStatusBarManagerCompat.setColor(color, animated);
|
|
15
|
-
},
|
|
16
|
-
setTranslucent(translucent) {
|
|
17
|
-
RCTStatusBarManagerCompat.setTranslucent(translucent);
|
|
18
|
-
},
|
|
19
|
-
/**
|
|
20
|
-
* - statusBarStyles can be:
|
|
21
|
-
* - 'default'
|
|
22
|
-
* - 'dark-content'
|
|
23
|
-
*/
|
|
24
|
-
setStyle(statusBarStyle) {
|
|
25
|
-
RCTStatusBarManagerCompat.setStyle(statusBarStyle);
|
|
26
|
-
},
|
|
27
|
-
setHidden(hidden) {
|
|
28
|
-
RCTStatusBarManagerCompat.setHidden(hidden);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
}
|
|
1
|
+
// stub for all platforms
|
|
32
2
|
//# sourceMappingURL=monkey-patch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sources":["monkey-patch.ts"],"sourcesContent":["// stub for all platforms\n"],"mappings":"AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useAnimatedKeyboardHandler"],"sources":["reanimated.ts"],"sourcesContent":["import type { EventWithName, KeyboardHandlerHook, NativeEvent } from './types';\n\nexport const useAnimatedKeyboardHandler: KeyboardHandlerHook<\n Record<string, unknown>,\n EventWithName<NativeEvent>\n> = () => () => {};\n"],"mappings":"AAEA,OAAO,MAAMA,0BAGZ,GAAG,MAAM,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useEvent, useHandler } from 'react-native-reanimated';
|
|
2
|
+
export const useAnimatedKeyboardHandler = (handlers, dependencies) => {
|
|
3
|
+
const {
|
|
4
|
+
context,
|
|
5
|
+
doDependenciesDiffer
|
|
6
|
+
} = useHandler(handlers, dependencies);
|
|
7
|
+
return useEvent(event => {
|
|
8
|
+
'worklet';
|
|
9
|
+
|
|
10
|
+
const {
|
|
11
|
+
onKeyboardMoveStart,
|
|
12
|
+
onKeyboardMove,
|
|
13
|
+
onKeyboardMoveEnd,
|
|
14
|
+
onKeyboardMoveInteractive
|
|
15
|
+
} = handlers;
|
|
16
|
+
if (onKeyboardMoveStart && event.eventName.endsWith('onKeyboardMoveStart')) {
|
|
17
|
+
onKeyboardMoveStart(event, context);
|
|
18
|
+
}
|
|
19
|
+
if (onKeyboardMove && event.eventName.endsWith('onKeyboardMove')) {
|
|
20
|
+
onKeyboardMove(event, context);
|
|
21
|
+
}
|
|
22
|
+
if (onKeyboardMoveEnd && event.eventName.endsWith('onKeyboardMoveEnd')) {
|
|
23
|
+
onKeyboardMoveEnd(event, context);
|
|
24
|
+
}
|
|
25
|
+
if (onKeyboardMoveInteractive && event.eventName.endsWith('onKeyboardMoveInteractive')) {
|
|
26
|
+
onKeyboardMoveInteractive(event, context);
|
|
27
|
+
}
|
|
28
|
+
}, ['onKeyboardMoveStart', 'onKeyboardMove', 'onKeyboardMoveEnd', 'onKeyboardMoveInteractive'], doDependenciesDiffer);
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=reanimated.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEvent","useHandler","useAnimatedKeyboardHandler","handlers","dependencies","context","doDependenciesDiffer","event","onKeyboardMoveStart","onKeyboardMove","onKeyboardMoveEnd","onKeyboardMoveInteractive","eventName","endsWith"],"sources":["reanimated.native.ts"],"sourcesContent":["import { useEvent, useHandler } from 'react-native-reanimated';\n\nimport type { EventWithName, KeyboardHandlerHook, NativeEvent } from './types';\n\nexport const useAnimatedKeyboardHandler: KeyboardHandlerHook<\n Record<string, unknown>,\n EventWithName<NativeEvent>\n> = (handlers, dependencies) => {\n const { context, doDependenciesDiffer } = useHandler(handlers, dependencies);\n\n return useEvent(\n (event) => {\n 'worklet';\n const {\n onKeyboardMoveStart,\n onKeyboardMove,\n onKeyboardMoveEnd,\n onKeyboardMoveInteractive,\n } = handlers;\n\n if (\n onKeyboardMoveStart &&\n event.eventName.endsWith('onKeyboardMoveStart')\n ) {\n onKeyboardMoveStart(event, context);\n }\n\n if (onKeyboardMove && event.eventName.endsWith('onKeyboardMove')) {\n onKeyboardMove(event, context);\n }\n\n if (onKeyboardMoveEnd && event.eventName.endsWith('onKeyboardMoveEnd')) {\n onKeyboardMoveEnd(event, context);\n }\n\n if (\n onKeyboardMoveInteractive &&\n event.eventName.endsWith('onKeyboardMoveInteractive')\n ) {\n onKeyboardMoveInteractive(event, context);\n }\n },\n [\n 'onKeyboardMoveStart',\n 'onKeyboardMove',\n 'onKeyboardMoveEnd',\n 'onKeyboardMoveInteractive',\n ],\n doDependenciesDiffer\n );\n};\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,UAAU,QAAQ,yBAAyB;AAI9D,OAAO,MAAMC,0BAGZ,GAAG,CAACC,QAAQ,EAAEC,YAAY,KAAK;EAC9B,MAAM;IAAEC,OAAO;IAAEC;EAAqB,CAAC,GAAGL,UAAU,CAACE,QAAQ,EAAEC,YAAY,CAAC;EAE5E,OAAOJ,QAAQ,CACZO,KAAK,IAAK;IACT,SAAS;;IACT,MAAM;MACJC,mBAAmB;MACnBC,cAAc;MACdC,iBAAiB;MACjBC;IACF,CAAC,GAAGR,QAAQ;IAEZ,IACEK,mBAAmB,IACnBD,KAAK,CAACK,SAAS,CAACC,QAAQ,CAAC,qBAAqB,CAAC,EAC/C;MACAL,mBAAmB,CAACD,KAAK,EAAEF,OAAO,CAAC;IACrC;IAEA,IAAII,cAAc,IAAIF,KAAK,CAACK,SAAS,CAACC,QAAQ,CAAC,gBAAgB,CAAC,EAAE;MAChEJ,cAAc,CAACF,KAAK,EAAEF,OAAO,CAAC;IAChC;IAEA,IAAIK,iBAAiB,IAAIH,KAAK,CAACK,SAAS,CAACC,QAAQ,CAAC,mBAAmB,CAAC,EAAE;MACtEH,iBAAiB,CAACH,KAAK,EAAEF,OAAO,CAAC;IACnC;IAEA,IACEM,yBAAyB,IACzBJ,KAAK,CAACK,SAAS,CAACC,QAAQ,CAAC,2BAA2B,CAAC,EACrD;MACAF,yBAAyB,CAACJ,KAAK,EAAEF,OAAO,CAAC;IAC3C;EACF,CAAC,EACD,CACE,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACnB,2BAA2B,CAC5B,EACDC,oBAAoB,CACrB;AACH,CAAC"}
|
package/lib/module/replicas.js
CHANGED
|
@@ -2,7 +2,8 @@ import { useRef, useEffect, useMemo } from 'react';
|
|
|
2
2
|
import { Animated, Easing, Keyboard, Platform } from 'react-native';
|
|
3
3
|
import { runOnUI, useAnimatedReaction, useDerivedValue, useSharedValue, useWorkletCallback, withSpring } from 'react-native-reanimated';
|
|
4
4
|
import { useReanimatedKeyboardAnimation } from './hooks';
|
|
5
|
-
import {
|
|
5
|
+
import { KeyboardController } from './bindings';
|
|
6
|
+
import { AndroidSoftInputModes } from './constants';
|
|
6
7
|
const availableOSEventType = Platform.OS === 'ios' ? 'Will' : 'Did';
|
|
7
8
|
|
|
8
9
|
// cubic-bezier(.17,.67,.34,.94)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useRef","useEffect","useMemo","Animated","Easing","Keyboard","Platform","runOnUI","useAnimatedReaction","useDerivedValue","useSharedValue","useWorkletCallback","withSpring","useReanimatedKeyboardAnimation","
|
|
1
|
+
{"version":3,"names":["useRef","useEffect","useMemo","Animated","Easing","Keyboard","Platform","runOnUI","useAnimatedReaction","useDerivedValue","useSharedValue","useWorkletCallback","withSpring","useReanimatedKeyboardAnimation","KeyboardController","AndroidSoftInputModes","availableOSEventType","OS","defaultAndroidEasing","bezier","useKeyboardAnimationReplica","height","Value","progress","animation","current","setInputMode","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","listener","addListener","e","timing","toValue","endCoordinates","duration","easing","useNativeDriver","start","remove","IOS_SPRING_CONFIG","damping","stiffness","mass","overshootClamping","restDisplacementThreshold","restSpeedThreshold","useReanimatedKeyboardAnimationReplica","heightEvent","value","handler","_height","_keyboardHeight","result","_previousResult","_previousKeyboardHeight","show","hide","useGradualKeyboardAnimation"],"sources":["replicas.ts"],"sourcesContent":["import { useRef, useEffect, useMemo } from 'react';\nimport { Animated, Easing, Keyboard, Platform } from 'react-native';\nimport {\n runOnUI,\n useAnimatedReaction,\n useDerivedValue,\n useSharedValue,\n useWorkletCallback,\n withSpring,\n} from 'react-native-reanimated';\nimport { useReanimatedKeyboardAnimation } from './hooks';\n\nimport { KeyboardController } from './bindings';\nimport { AndroidSoftInputModes } from './constants';\n\nconst availableOSEventType = Platform.OS === 'ios' ? 'Will' : 'Did';\n\n// cubic-bezier(.17,.67,.34,.94)\nexport const defaultAndroidEasing = Easing.bezier(0.4, 0.0, 0.2, 1);\ntype KeyboardAnimation = {\n progress: Animated.Value;\n height: Animated.Value;\n};\n\n/**\n * An experimental implementation of tracing keyboard appearance.\n * Switch an input mode to adjust resize mode. In this case all did* events\n * are triggering before keyboard appears, and using some approximations\n * it tries to mimicries a native transition.\n *\n * @returns {Animated.Value}\n */\nexport const useKeyboardAnimationReplica = (): KeyboardAnimation => {\n const height = useRef(new Animated.Value(0));\n const progress = useRef(new Animated.Value(0));\n const animation = useMemo(\n () => ({\n height: height.current,\n progress: progress.current,\n }),\n []\n );\n\n useEffect(() => {\n KeyboardController.setInputMode(\n AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE\n );\n\n return () => KeyboardController.setDefaultMode();\n }, []);\n useEffect(() => {\n const listener = Keyboard.addListener(\n `keyboard${availableOSEventType}Show`,\n (e) => {\n Animated.timing(height.current, {\n toValue: -e.endCoordinates.height,\n duration: e.duration !== 0 ? e.duration : 300,\n easing: Easing.bezier(0.4, 0.0, 0.2, 1),\n useNativeDriver: true,\n }).start();\n\n return () => listener.remove();\n }\n );\n }, []);\n useEffect(() => {\n const listener = Keyboard.addListener(\n `keyboard${availableOSEventType}Hide`,\n (e) => {\n Animated.timing(height.current, {\n toValue: 0,\n duration: e.duration !== 0 ? e.duration : 300,\n easing: Easing.bezier(0.4, 0.0, 0.2, 1),\n useNativeDriver: true,\n }).start();\n\n return () => listener.remove();\n }\n );\n }, []);\n\n return animation;\n};\n\nconst IOS_SPRING_CONFIG = {\n damping: 500,\n stiffness: 1000,\n mass: 3,\n overshootClamping: true,\n restDisplacementThreshold: 10,\n restSpeedThreshold: 10,\n};\n\n/**\n * A close replica to native iOS keyboard animation. The problem is that\n * iOS (unlike Android) can not fire events for each keyboard frame movement.\n * As a result we can not get gradual values (for example, for progress it always\n * will be 1 or 0). So if you want to rely on gradual values you will need to use\n * this replica.\n *\n * The transition is hardcoded and may vary from one to another OS versions. But it\n * seems like last time it has been changed in iOS 7. Since RN supports at least iOS\n * 11 it doesn't make sense to replicate iOS 7 behavior. If it changes in next OS\n * versions, then this implementation should be revisited and reflect necessary changes.\n *\n * @returns {height, progress} - animated values\n */\nexport const useReanimatedKeyboardAnimationReplica = () => {\n const height = useSharedValue(0);\n const heightEvent = useSharedValue(0);\n\n const progress = useDerivedValue(() => height.value / heightEvent.value);\n\n const handler = useWorkletCallback((_height: number) => {\n heightEvent.value = _height;\n }, []);\n\n useAnimatedReaction(\n () => ({\n _keyboardHeight: heightEvent.value,\n }),\n (result, _previousResult) => {\n const { _keyboardHeight } = result;\n const _previousKeyboardHeight = _previousResult?._keyboardHeight;\n\n if (_keyboardHeight !== _previousKeyboardHeight) {\n height.value = withSpring(_keyboardHeight, IOS_SPRING_CONFIG);\n }\n },\n []\n );\n\n useEffect(() => {\n const show = Keyboard.addListener('keyboardWillShow', (e) => {\n runOnUI(handler)(-e.endCoordinates.height);\n });\n const hide = Keyboard.addListener('keyboardWillHide', () => {\n runOnUI(handler)(0);\n });\n\n return () => {\n show.remove();\n hide.remove();\n };\n }, []);\n\n return { height, progress };\n};\n\nexport const useGradualKeyboardAnimation =\n Platform.OS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;IACrB,CAAC,CAAC;IAEF,OAAO,MAAM;MACXM,IAAI,CAACjB,MAAM,EAAE;MACbkB,IAAI,CAAClB,MAAM,EAAE;IACf,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO;IAAElB,MAAM;IAAEE;EAAS,CAAC;AAC7B,CAAC;AAED,OAAO,MAAMmC,2BAA2B,GACtCpD,QAAQ,CAACW,EAAE,KAAK,KAAK,GACjB8B,qCAAqC,GACrClC,8BAA8B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["codegenNativeComponent"],"sources":["KeyboardControllerViewNativeComponent.ts"],"sourcesContent":["import type { HostComponent } from 'react-native';\nimport type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';\nimport type {\n DirectEventHandler,\n Double,\n} from 'react-native/Libraries/Types/CodegenTypes';\nimport codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';\n\ntype KeyboardMoveEvent = Readonly<{\n height: Double;\n progress: Double;\n}>;\n\nexport interface NativeProps extends ViewProps {\n // props\n statusBarTranslucent?: boolean;\n navigationBarTranslucent?: boolean;\n // callbacks\n onKeyboardMoveStart?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMove?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMoveEnd?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMoveInteractive?: DirectEventHandler<KeyboardMoveEvent>;\n}\n\nexport default codegenNativeComponent<NativeProps>(\n 'KeyboardControllerView'\n) as HostComponent<NativeProps>;\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["codegenNativeComponent"],"sources":["KeyboardControllerViewNativeComponent.ts"],"sourcesContent":["import type { HostComponent } from 'react-native';\nimport type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';\nimport type {\n DirectEventHandler,\n Double,\n Int32,\n} from 'react-native/Libraries/Types/CodegenTypes';\nimport codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';\n\ntype KeyboardMoveEvent = Readonly<{\n height: Double;\n progress: Double;\n duration: Int32;\n target: Int32;\n}>;\n\nexport interface NativeProps extends ViewProps {\n // props\n statusBarTranslucent?: boolean;\n navigationBarTranslucent?: boolean;\n // callbacks\n onKeyboardMoveStart?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMove?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMoveEnd?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMoveInteractive?: DirectEventHandler<KeyboardMoveEvent>;\n}\n\nexport default codegenNativeComponent<NativeProps>(\n 'KeyboardControllerView'\n) as HostComponent<NativeProps>;\n"],"mappings":"AAOA,OAAOA,sBAAsB,MAAM,yDAAyD;AAoB5F,eAAeA,sBAAsB,CACnC,wBAAwB,CACzB"}
|
package/lib/module/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {
|
|
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 EventWithName<T> = {\n eventName: string;\n} & T;\n\n// native View/Module declarations\nexport type KeyboardControllerProps = {\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 // fake prop used to activate reanimated bindings\n onKeyboardMoveReanimated?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>\n ) => void;\n statusBarTranslucent?: boolean;\n navigationBarTranslucent?: 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 KeyboardControllerModule = {\n // android only\n setDefaultMode: () => void;\n setInputMode: (mode: number) => 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};\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?: ReadonlyArray<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>;\n"],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { KeyboardControllerModule, KeyboardControllerProps, KeyboardEventsModule, KeyboardGestureAreaProps } from './types';
|
|
3
|
+
export declare const KeyboardController: KeyboardControllerModule;
|
|
4
|
+
export declare const KeyboardEvents: KeyboardEventsModule;
|
|
5
|
+
export declare const KeyboardControllerView: import("react").FC<KeyboardControllerProps>;
|
|
6
|
+
export declare const KeyboardGestureArea: import("react").FC<KeyboardGestureAreaProps>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { KeyboardControllerModule, KeyboardControllerProps, KeyboardEventsModule, KeyboardGestureAreaProps } from './types';
|
|
3
|
+
export declare const KeyboardController: KeyboardControllerModule;
|
|
4
|
+
export declare const KeyboardEvents: KeyboardEventsModule;
|
|
5
|
+
export declare const KeyboardControllerView: React.FC<KeyboardControllerProps>;
|
|
6
|
+
export declare const KeyboardGestureArea: React.FC<KeyboardGestureAreaProps>;
|