react-native-keyboard-controller 1.9.5 → 1.10.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/README.md +1 -1
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +4 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/events/FocusedInputTextChangedEvent.kt +20 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/EditText.kt +36 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/WindowInsetsAnimationCompat.kt +7 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/FocusedInputObserver.kt +17 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt +12 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardControllerViewManagerImpl.kt +2 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/modules/KeyboardControllerModuleImpl.kt +13 -0
- package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +5 -0
- package/ios/.clang-format +30 -30
- package/ios/.swiftlint.yml +1 -1
- package/ios/KeyboardController.xcodeproj/project.pbxproj +10 -0
- package/ios/KeyboardControllerModule.mm +14 -0
- package/ios/events/FocusedInputTextChangedEvent.h +16 -0
- package/ios/events/FocusedInputTextChangedEvent.m +72 -0
- package/ios/observers/FocusedInputObserver.swift +29 -14
- package/ios/observers/TextChangeObserver.swift +41 -0
- package/ios/views/KeyboardControllerView.mm +53 -31
- package/ios/views/KeyboardControllerViewManager.mm +1 -0
- package/ios/views/KeyboardControllerViewManager.swift +21 -10
- package/jest/index.js +6 -4
- package/lib/commonjs/animated.js +33 -27
- package/lib/commonjs/animated.js.map +1 -1
- package/lib/commonjs/bindings.js +1 -0
- package/lib/commonjs/bindings.js.map +1 -1
- package/lib/commonjs/bindings.native.js +6 -6
- package/lib/commonjs/bindings.native.js.map +1 -1
- package/lib/commonjs/components/KeyboardAvoidingView/hooks.js +5 -3
- package/lib/commonjs/components/KeyboardAvoidingView/hooks.js.map +1 -1
- package/lib/commonjs/components/KeyboardAvoidingView/index.js +17 -9
- package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js +199 -0
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -0
- package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +100 -0
- package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -0
- package/lib/commonjs/components/KeyboardAwareScrollView/utils.js +28 -0
- package/lib/commonjs/components/KeyboardAwareScrollView/utils.js.map +1 -0
- package/lib/commonjs/components/KeyboardStickyView/index.js +7 -4
- package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -1
- package/lib/commonjs/components/hooks/useKeyboardInterpolation.js +81 -0
- package/lib/commonjs/components/hooks/useKeyboardInterpolation.js.map +1 -0
- package/lib/commonjs/components/index.js +7 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/constants.js.map +1 -1
- package/lib/commonjs/context.js +2 -1
- package/lib/commonjs/context.js.map +1 -1
- package/lib/commonjs/hooks.js +17 -2
- package/lib/commonjs/hooks.js.map +1 -1
- package/lib/commonjs/index.js +8 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/internal.js +3 -6
- 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 +5 -3
- package/lib/commonjs/reanimated.js.map +1 -1
- package/lib/commonjs/reanimated.native.js +29 -12
- package/lib/commonjs/reanimated.native.js.map +1 -1
- package/lib/commonjs/replicas.js +7 -5
- package/lib/commonjs/replicas.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 +2 -2
- package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
- package/lib/commonjs/specs/NativeKeyboardController.js +1 -1
- package/lib/commonjs/specs/NativeKeyboardController.js.map +1 -1
- package/lib/commonjs/specs/NativeStatusBarManagerCompat.js +1 -1
- package/lib/commonjs/specs/NativeStatusBarManagerCompat.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/module/animated.js +41 -35
- package/lib/module/animated.js.map +1 -1
- package/lib/module/bindings.js +2 -1
- package/lib/module/bindings.js.map +1 -1
- package/lib/module/bindings.native.js +7 -7
- package/lib/module/bindings.native.js.map +1 -1
- package/lib/module/components/KeyboardAvoidingView/hooks.js +7 -5
- package/lib/module/components/KeyboardAvoidingView/hooks.js.map +1 -1
- package/lib/module/components/KeyboardAvoidingView/index.js +20 -13
- package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/index.js +190 -0
- package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -0
- package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +93 -0
- package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -0
- package/lib/module/components/KeyboardAwareScrollView/utils.js +21 -0
- package/lib/module/components/KeyboardAwareScrollView/utils.js.map +1 -0
- package/lib/module/components/KeyboardStickyView/index.js +9 -7
- package/lib/module/components/KeyboardStickyView/index.js.map +1 -1
- package/lib/module/components/hooks/useKeyboardInterpolation.js +74 -0
- package/lib/module/components/hooks/useKeyboardInterpolation.js.map +1 -0
- package/lib/module/components/index.js +3 -2
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/context.js +4 -3
- package/lib/module/context.js.map +1 -1
- package/lib/module/hooks.js +21 -7
- package/lib/module/hooks.js.map +1 -1
- package/lib/module/index.js +8 -8
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal.js +6 -9
- package/lib/module/internal.js.map +1 -1
- package/lib/module/monkey-patch.android.js +2 -2
- package/lib/module/monkey-patch.android.js.map +1 -1
- package/lib/module/monkey-patch.js.map +1 -1
- package/lib/module/reanimated.js +2 -1
- package/lib/module/reanimated.js.map +1 -1
- package/lib/module/reanimated.native.js +27 -11
- package/lib/module/reanimated.native.js.map +1 -1
- package/lib/module/replicas.js +13 -11
- package/lib/module/replicas.js.map +1 -1
- package/lib/module/specs/KeyboardControllerViewNativeComponent.js +2 -2
- package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
- package/lib/module/specs/KeyboardGestureAreaNativeComponent.js +3 -3
- package/lib/module/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
- package/lib/module/specs/NativeKeyboardController.js +2 -2
- package/lib/module/specs/NativeKeyboardController.js.map +1 -1
- package/lib/module/specs/NativeStatusBarManagerCompat.js +2 -2
- package/lib/module/specs/NativeStatusBarManagerCompat.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils.js.map +1 -1
- package/lib/typescript/animated.d.ts +1 -1
- package/lib/typescript/bindings.d.ts +1 -1
- package/lib/typescript/bindings.native.d.ts +1 -1
- package/lib/typescript/components/KeyboardAvoidingView/index.d.ts +4 -4
- package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +45 -0
- package/lib/typescript/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.d.ts +6 -0
- package/lib/typescript/components/KeyboardAwareScrollView/utils.d.ts +1 -0
- package/lib/typescript/components/KeyboardStickyView/index.d.ts +2 -2
- package/lib/typescript/components/hooks/useKeyboardInterpolation.d.ts +20 -0
- package/lib/typescript/components/index.d.ts +3 -2
- package/lib/typescript/context.d.ts +6 -5
- package/lib/typescript/hooks.d.ts +4 -3
- package/lib/typescript/index.d.ts +8 -8
- package/lib/typescript/internal.d.ts +9 -6
- package/lib/typescript/reanimated.d.ts +3 -2
- package/lib/typescript/reanimated.native.d.ts +3 -2
- package/lib/typescript/replicas.d.ts +1 -1
- package/lib/typescript/specs/KeyboardControllerViewNativeComponent.d.ts +7 -3
- package/lib/typescript/specs/KeyboardGestureAreaNativeComponent.d.ts +4 -4
- package/lib/typescript/specs/NativeKeyboardController.d.ts +2 -1
- package/lib/typescript/specs/NativeStatusBarManagerCompat.d.ts +1 -1
- package/lib/typescript/types.d.ts +18 -5
- package/package.json +12 -11
- package/react-native-keyboard-controller.podspec +1 -1
- package/src/animated.tsx +59 -42
- package/src/bindings.native.ts +11 -11
- package/src/bindings.ts +4 -3
- package/src/components/KeyboardAvoidingView/hooks.ts +9 -6
- package/src/components/KeyboardAvoidingView/index.tsx +30 -27
- package/src/components/KeyboardAwareScrollView/index.tsx +262 -0
- package/src/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.ts +123 -0
- package/src/components/KeyboardAwareScrollView/utils.ts +26 -0
- package/src/components/KeyboardStickyView/index.tsx +12 -18
- package/src/components/hooks/useKeyboardInterpolation.ts +96 -0
- package/src/components/index.ts +3 -2
- package/src/context.ts +15 -9
- package/src/hooks.ts +30 -13
- package/src/index.ts +12 -8
- package/src/internal.ts +22 -13
- package/src/monkey-patch.android.ts +2 -2
- package/src/reanimated.native.ts +43 -18
- package/src/reanimated.ts +9 -3
- package/src/replicas.ts +18 -17
- package/src/specs/KeyboardControllerViewNativeComponent.ts +12 -5
- package/src/specs/KeyboardGestureAreaNativeComponent.ts +7 -7
- package/src/specs/NativeKeyboardController.ts +4 -3
- package/src/specs/NativeStatusBarManagerCompat.ts +3 -3
- package/src/types.ts +45 -19
package/lib/module/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","KeyboardController","AndroidSoftInputModes","useKeyboardContext","uuid","useResizeMode","setInputMode","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","useKeyboardAnimation","context","animated","useReanimatedKeyboardAnimation","reanimated","useGenericKeyboardHandler","handler","deps","key","
|
|
1
|
+
{"version":3,"names":["useEffect","KeyboardController","AndroidSoftInputModes","useKeyboardContext","uuid","useResizeMode","setInputMode","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","useKeyboardAnimation","context","animated","useReanimatedKeyboardAnimation","reanimated","useGenericKeyboardHandler","handler","deps","key","setKeyboardHandlers","undefined","useKeyboardHandler","useKeyboardController","setEnabled","enabled","useReanimatedFocusedInput","input","layout","useFocusedInputHandler","setInputHandlers"],"sources":["hooks.ts"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport { KeyboardController } from \"./bindings\";\nimport { AndroidSoftInputModes } from \"./constants\";\nimport { useKeyboardContext } from \"./context\";\nimport { uuid } from \"./utils\";\n\nimport type { AnimatedContext, ReanimatedContext } from \"./context\";\nimport type { FocusedInputHandler, KeyboardHandler } from \"./types\";\nimport type { DependencyList } from \"react\";\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.setKeyboardHandlers({ [key]: handler });\n\n return () => {\n context.setKeyboardHandlers({ [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\nexport function useKeyboardController() {\n const context = useKeyboardContext();\n\n return { setEnabled: context.setEnabled, enabled: context.enabled };\n}\n\nexport function useReanimatedFocusedInput() {\n const context = useKeyboardContext();\n\n return { input: context.layout };\n}\n\nexport function useFocusedInputHandler(\n handler?: FocusedInputHandler,\n deps?: DependencyList,\n) {\n const context = useKeyboardContext();\n\n useEffect(() => {\n const key = uuid();\n\n context.setInputHandlers({ [key]: handler });\n\n return () => {\n context.setInputHandlers({ [key]: undefined });\n };\n }, deps);\n}\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO;AAEjC,SAASC,kBAAkB,QAAQ,YAAY;AAC/C,SAASC,qBAAqB,QAAQ,aAAa;AACnD,SAASC,kBAAkB,QAAQ,WAAW;AAC9C,SAASC,IAAI,QAAQ,SAAS;AAM9B,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAM;EACjCL,SAAS,CAAC,MAAM;IACdC,kBAAkB,CAACK,YAAY,CAC7BJ,qBAAqB,CAACK,wBACxB,CAAC;IAED,OAAO,MAAMN,kBAAkB,CAACO,cAAc,CAAC,CAAC;EAClD,CAAC,EAAE,EAAE,CAAC;AACR,CAAC;AAED,OAAO,MAAMC,oBAAoB,GAAGA,CAAA,KAAuB;EACzDJ,aAAa,CAAC,CAAC;EACf,MAAMK,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpC,OAAOO,OAAO,CAACC,QAAQ;AACzB,CAAC;AAED,OAAO,MAAMC,8BAA8B,GAAGA,CAAA,KAAyB;EACrEP,aAAa,CAAC,CAAC;EACf,MAAMK,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpC,OAAOO,OAAO,CAACG,UAAU;AAC3B,CAAC;AAED,OAAO,SAASC,yBAAyBA,CACvCC,OAAwB,EACxBC,IAAqB,EACrB;EACA,MAAMN,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpCH,SAAS,CAAC,MAAM;IACd,MAAMiB,GAAG,GAAGb,IAAI,CAAC,CAAC;IAElBM,OAAO,CAACQ,mBAAmB,CAAC;MAAE,CAACD,GAAG,GAAGF;IAAQ,CAAC,CAAC;IAE/C,OAAO,MAAM;MACXL,OAAO,CAACQ,mBAAmB,CAAC;QAAE,CAACD,GAAG,GAAGE;MAAU,CAAC,CAAC;IACnD,CAAC;EACH,CAAC,EAAEH,IAAI,CAAC;AACV;AAEA,OAAO,SAASI,kBAAkBA,CAChCL,OAAwB,EACxBC,IAAqB,EACrB;EACAX,aAAa,CAAC,CAAC;EACfS,yBAAyB,CAACC,OAAO,EAAEC,IAAI,CAAC;AAC1C;AAEA,OAAO,SAASK,qBAAqBA,CAAA,EAAG;EACtC,MAAMX,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpC,OAAO;IAAEmB,UAAU,EAAEZ,OAAO,CAACY,UAAU;IAAEC,OAAO,EAAEb,OAAO,CAACa;EAAQ,CAAC;AACrE;AAEA,OAAO,SAASC,yBAAyBA,CAAA,EAAG;EAC1C,MAAMd,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpC,OAAO;IAAEsB,KAAK,EAAEf,OAAO,CAACgB;EAAO,CAAC;AAClC;AAEA,OAAO,SAASC,sBAAsBA,CACpCZ,OAA6B,EAC7BC,IAAqB,EACrB;EACA,MAAMN,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpCH,SAAS,CAAC,MAAM;IACd,MAAMiB,GAAG,GAAGb,IAAI,CAAC,CAAC;IAElBM,OAAO,CAACkB,gBAAgB,CAAC;MAAE,CAACX,GAAG,GAAGF;IAAQ,CAAC,CAAC;IAE5C,OAAO,MAAM;MACXL,OAAO,CAACkB,gBAAgB,CAAC;QAAE,CAACX,GAAG,GAAGE;MAAU,CAAC,CAAC;IAChD,CAAC;EACH,CAAC,EAAEH,IAAI,CAAC;AACV"}
|
package/lib/module/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export { KeyboardAvoidingView, KeyboardStickyView } from
|
|
1
|
+
export * from "./bindings";
|
|
2
|
+
export * from "./animated";
|
|
3
|
+
export * from "./replicas";
|
|
4
|
+
export * from "./context";
|
|
5
|
+
export * from "./hooks";
|
|
6
|
+
export * from "./constants";
|
|
7
|
+
export * from "./types";
|
|
8
|
+
export { KeyboardAvoidingView, KeyboardStickyView, KeyboardAwareScrollView } from "./components";
|
|
9
9
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["KeyboardAvoidingView","KeyboardStickyView"],"sources":["index.ts"],"sourcesContent":["export * from
|
|
1
|
+
{"version":3,"names":["KeyboardAvoidingView","KeyboardStickyView","KeyboardAwareScrollView"],"sources":["index.ts"],"sourcesContent":["export * from \"./bindings\";\nexport * from \"./animated\";\nexport * from \"./replicas\";\nexport * from \"./context\";\nexport * from \"./hooks\";\nexport * from \"./constants\";\nexport * from \"./types\";\n\nexport {\n KeyboardAvoidingView,\n KeyboardStickyView,\n KeyboardAwareScrollView,\n} from \"./components\";\n"],"mappings":"AAAA,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,SAAS;AAEvB,SACEA,oBAAoB,EACpBC,kBAAkB,EAClBC,uBAAuB,QAClB,cAAc"}
|
package/lib/module/internal.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useCallback, useRef } from
|
|
2
|
-
import { Animated } from
|
|
3
|
-
import { useSharedValue } from
|
|
1
|
+
import { useCallback, useRef } from "react";
|
|
2
|
+
import { Animated } from "react-native";
|
|
3
|
+
import { useSharedValue } from "react-native-reanimated";
|
|
4
4
|
/**
|
|
5
5
|
* Hook for storing worklet handlers (objects with keys, where values are worklets).
|
|
6
6
|
* Returns methods for setting handlers and broadcasting events in them.
|
|
@@ -36,17 +36,14 @@ export function useSharedHandlers() {
|
|
|
36
36
|
updateSharedHandlers();
|
|
37
37
|
}, []);
|
|
38
38
|
const broadcast = (type, event) => {
|
|
39
|
-
|
|
39
|
+
"worklet";
|
|
40
40
|
|
|
41
41
|
Object.keys(handlers.value).forEach(key => {
|
|
42
42
|
var _handlers$value$key, _handlers$value$key$t;
|
|
43
|
-
|
|
43
|
+
(_handlers$value$key = handlers.value[key]) === null || _handlers$value$key === void 0 ? void 0 : (_handlers$value$key$t = _handlers$value$key[type]) === null || _handlers$value$key$t === void 0 ? void 0 : _handlers$value$key$t.call(_handlers$value$key, event);
|
|
44
44
|
});
|
|
45
45
|
};
|
|
46
|
-
return
|
|
47
|
-
setHandlers,
|
|
48
|
-
broadcast
|
|
49
|
-
};
|
|
46
|
+
return [setHandlers, broadcast];
|
|
50
47
|
}
|
|
51
48
|
|
|
52
49
|
/**
|
|
@@ -1 +1 @@
|
|
|
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
|
|
1
|
+
{"version":3,"names":["useCallback","useRef","Animated","useSharedValue","useSharedHandlers","handlers","jsHandlers","updateSharedHandlers","value","current","setHandlers","handler","broadcast","type","event","Object","keys","forEach","key","_handlers$value$key","_handlers$value$key$t","call","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 } from \"./types\";\n\ntype UntypedHandler = Record<string, (event: never) => void>;\ntype SharedHandlersReturnType<T extends UntypedHandler> = [\n (handler: Handlers<T>) => void,\n <K extends keyof T>(type: K, event: Parameters<T[K]>[0]) => void,\n];\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<\n T extends UntypedHandler,\n>(): SharedHandlersReturnType<T> {\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 = <K extends keyof T>(\n type: K,\n event: Parameters<T[K]>[0],\n ) => {\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;AAU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AAI,IAAI,EAAE;IACvBgB,GAAG,CAAChB,OAAO,GAAG,IAAIP,QAAQ,CAACwB,KAAK,CAACH,YAAY,EAAEC,MAAM,CAAC;EACxD;EAEA,OAAOC,GAAG,CAAChB,OAAO;AACpB"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @ts-expect-error because there is no corresponding type definition
|
|
2
|
-
import * as NativeAndroidManager from
|
|
2
|
+
import * as NativeAndroidManager from "react-native/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid";
|
|
3
3
|
const DefaultNativeAndroidManager = NativeAndroidManager.default;
|
|
4
4
|
const getConstants = NativeAndroidManager.default.getConstants;
|
|
5
|
-
const RCTStatusBarManagerCompat = require(
|
|
5
|
+
const RCTStatusBarManagerCompat = require("./specs/NativeStatusBarManagerCompat").default;
|
|
6
6
|
|
|
7
7
|
// On Android < 11 RN uses legacy API which breaks EdgeToEdge mode in RN, so
|
|
8
8
|
// in order to use library on all available platforms we have to monkey patch
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeAndroidManager","DefaultNativeAndroidManager","default","getConstants","RCTStatusBarManagerCompat","require","applyMonkeyPatch","setColor","color","animated","setTranslucent","translucent","setStyle","statusBarStyle","setHidden","hidden","revertMonkeyPatch"],"sources":["monkey-patch.android.ts"],"sourcesContent":["// @ts-expect-error because there is no corresponding type definition\nimport * as NativeAndroidManager from
|
|
1
|
+
{"version":3,"names":["NativeAndroidManager","DefaultNativeAndroidManager","default","getConstants","RCTStatusBarManagerCompat","require","applyMonkeyPatch","setColor","color","animated","setTranslucent","translucent","setStyle","statusBarStyle","setHidden","hidden","revertMonkeyPatch"],"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 DefaultNativeAndroidManager = NativeAndroidManager.default;\nconst getConstants = NativeAndroidManager.default.getConstants;\nconst RCTStatusBarManagerCompat =\n require(\"./specs/NativeStatusBarManagerCompat\").default;\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`.\nexport const applyMonkeyPatch = () => {\n NativeAndroidManager.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};\nexport const revertMonkeyPatch = () => {\n NativeAndroidManager.default = DefaultNativeAndroidManager;\n};\n"],"mappings":"AAAA;AACA,OAAO,KAAKA,oBAAoB,MAAM,2EAA2E;AAEjH,MAAMC,2BAA2B,GAAGD,oBAAoB,CAACE,OAAO;AAChE,MAAMC,YAAY,GAAGH,oBAAoB,CAACE,OAAO,CAACC,YAAY;AAC9D,MAAMC,yBAAyB,GAC7BC,OAAO,CAAC,sCAAsC,CAAC,CAACH,OAAO;;AAEzD;AACA;AACA;AACA,OAAO,MAAMI,gBAAgB,GAAGA,CAAA,KAAM;EACpCN,oBAAoB,CAACE,OAAO,GAAG;IAC7BC,YAAY;IACZI,QAAQA,CAACC,KAAa,EAAEC,QAAiB,EAAQ;MAC/CL,yBAAyB,CAACG,QAAQ,CAACC,KAAK,EAAEC,QAAQ,CAAC;IACrD,CAAC;IAEDC,cAAcA,CAACC,WAAoB,EAAQ;MACzCP,yBAAyB,CAACM,cAAc,CAACC,WAAW,CAAC;IACvD,CAAC;IAED;AACJ;AACA;AACA;AACA;IACIC,QAAQA,CAACC,cAAuB,EAAQ;MACtCT,yBAAyB,CAACQ,QAAQ,CAACC,cAAc,CAAC;IACpD,CAAC;IAEDC,SAASA,CAACC,MAAe,EAAQ;MAC/BX,yBAAyB,CAACU,SAAS,CAACC,MAAM,CAAC;IAC7C;EACF,CAAC;AACH,CAAC;AACD,OAAO,MAAMC,iBAAiB,GAAGA,CAAA,KAAM;EACrChB,oBAAoB,CAACE,OAAO,GAAGD,2BAA2B;AAC5D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NOOP","applyMonkeyPatch","revertMonkeyPatch"],"sources":["monkey-patch.ts"],"sourcesContent":["// stub for all platforms\nconst NOOP = () => {};\nexport const applyMonkeyPatch = NOOP;\nexport const revertMonkeyPatch = NOOP;\n"],"mappings":"AAAA;AACA,MAAMA,IAAI,
|
|
1
|
+
{"version":3,"names":["NOOP","applyMonkeyPatch","revertMonkeyPatch"],"sources":["monkey-patch.ts"],"sourcesContent":["// stub for all platforms\nconst NOOP = () => {};\nexport const applyMonkeyPatch = NOOP;\nexport const revertMonkeyPatch = NOOP;\n"],"mappings":"AAAA;AACA,MAAMA,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AACrB,OAAO,MAAMC,gBAAgB,GAAGD,IAAI;AACpC,OAAO,MAAME,iBAAiB,GAAGF,IAAI"}
|
package/lib/module/reanimated.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NOOP","useAnimatedKeyboardHandler","
|
|
1
|
+
{"version":3,"names":["NOOP","useAnimatedKeyboardHandler","useFocusedInputLayoutHandler","useFocusedInputTextHandler"],"sources":["reanimated.ts"],"sourcesContent":["import type {\n EventWithName,\n FocusedInputLayoutChangedEvent,\n FocusedInputLayoutHandlerHook,\n FocusedInputTextChangedEvent,\n FocusedInputTextHandlerHook,\n KeyboardHandlerHook,\n NativeEvent,\n} from \"./types\";\n\nconst NOOP = () => () => {};\nexport const useAnimatedKeyboardHandler: KeyboardHandlerHook<\n Record<string, unknown>,\n EventWithName<NativeEvent>\n> = NOOP;\nexport const useFocusedInputLayoutHandler: FocusedInputLayoutHandlerHook<\n Record<string, unknown>,\n EventWithName<FocusedInputLayoutChangedEvent>\n> = NOOP;\nexport const useFocusedInputTextHandler: FocusedInputTextHandlerHook<\n Record<string, unknown>,\n EventWithName<FocusedInputTextChangedEvent>\n> = NOOP;\n"],"mappings":"AAUA,MAAMA,IAAI,GAAGA,CAAA,KAAM,MAAM,CAAC,CAAC;AAC3B,OAAO,MAAMC,0BAGZ,GAAGD,IAAI;AACR,OAAO,MAAME,4BAGZ,GAAGF,IAAI;AACR,OAAO,MAAMG,0BAGZ,GAAGH,IAAI"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { useEvent, useHandler } from
|
|
1
|
+
import { useEvent, useHandler } from "react-native-reanimated";
|
|
2
2
|
export const useAnimatedKeyboardHandler = (handlers, dependencies) => {
|
|
3
3
|
const {
|
|
4
4
|
context,
|
|
5
5
|
doDependenciesDiffer
|
|
6
6
|
} = useHandler(handlers, dependencies);
|
|
7
7
|
return useEvent(event => {
|
|
8
|
-
|
|
8
|
+
"worklet";
|
|
9
9
|
|
|
10
10
|
const {
|
|
11
11
|
onKeyboardMoveStart,
|
|
@@ -13,34 +13,50 @@ export const useAnimatedKeyboardHandler = (handlers, dependencies) => {
|
|
|
13
13
|
onKeyboardMoveEnd,
|
|
14
14
|
onKeyboardMoveInteractive
|
|
15
15
|
} = handlers;
|
|
16
|
-
if (onKeyboardMoveStart && event.eventName.endsWith(
|
|
16
|
+
if (onKeyboardMoveStart && event.eventName.endsWith("onKeyboardMoveStart")) {
|
|
17
17
|
onKeyboardMoveStart(event, context);
|
|
18
18
|
}
|
|
19
|
-
if (onKeyboardMove && event.eventName.endsWith(
|
|
19
|
+
if (onKeyboardMove && event.eventName.endsWith("onKeyboardMove")) {
|
|
20
20
|
onKeyboardMove(event, context);
|
|
21
21
|
}
|
|
22
|
-
if (onKeyboardMoveEnd && event.eventName.endsWith(
|
|
22
|
+
if (onKeyboardMoveEnd && event.eventName.endsWith("onKeyboardMoveEnd")) {
|
|
23
23
|
onKeyboardMoveEnd(event, context);
|
|
24
24
|
}
|
|
25
|
-
if (onKeyboardMoveInteractive && event.eventName.endsWith(
|
|
25
|
+
if (onKeyboardMoveInteractive && event.eventName.endsWith("onKeyboardMoveInteractive")) {
|
|
26
26
|
onKeyboardMoveInteractive(event, context);
|
|
27
27
|
}
|
|
28
|
-
}, [
|
|
28
|
+
}, ["onKeyboardMoveStart", "onKeyboardMove", "onKeyboardMoveEnd", "onKeyboardMoveInteractive"], doDependenciesDiffer);
|
|
29
29
|
};
|
|
30
|
-
export const
|
|
30
|
+
export const useFocusedInputLayoutHandler = (handlers, dependencies) => {
|
|
31
31
|
const {
|
|
32
32
|
context,
|
|
33
33
|
doDependenciesDiffer
|
|
34
34
|
} = useHandler(handlers, dependencies);
|
|
35
35
|
return useEvent(event => {
|
|
36
|
-
|
|
36
|
+
"worklet";
|
|
37
37
|
|
|
38
38
|
const {
|
|
39
39
|
onFocusedInputLayoutChanged
|
|
40
40
|
} = handlers;
|
|
41
|
-
if (onFocusedInputLayoutChanged && event.eventName.endsWith(
|
|
41
|
+
if (onFocusedInputLayoutChanged && event.eventName.endsWith("onFocusedInputLayoutChanged")) {
|
|
42
42
|
onFocusedInputLayoutChanged(event, context);
|
|
43
43
|
}
|
|
44
|
-
}, [
|
|
44
|
+
}, ["onFocusedInputLayoutChanged"], doDependenciesDiffer);
|
|
45
|
+
};
|
|
46
|
+
export const useFocusedInputTextHandler = (handlers, dependencies) => {
|
|
47
|
+
const {
|
|
48
|
+
context,
|
|
49
|
+
doDependenciesDiffer
|
|
50
|
+
} = useHandler(handlers, dependencies);
|
|
51
|
+
return useEvent(event => {
|
|
52
|
+
"worklet";
|
|
53
|
+
|
|
54
|
+
const {
|
|
55
|
+
onFocusedInputTextChanged
|
|
56
|
+
} = handlers;
|
|
57
|
+
if (onFocusedInputTextChanged && event.eventName.endsWith("onFocusedInputTextChanged")) {
|
|
58
|
+
onFocusedInputTextChanged(event, context);
|
|
59
|
+
}
|
|
60
|
+
}, ["onFocusedInputTextChanged"], doDependenciesDiffer);
|
|
45
61
|
};
|
|
46
62
|
//# sourceMappingURL=reanimated.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEvent","useHandler","useAnimatedKeyboardHandler","handlers","dependencies","context","doDependenciesDiffer","event","onKeyboardMoveStart","onKeyboardMove","onKeyboardMoveEnd","onKeyboardMoveInteractive","eventName","endsWith","
|
|
1
|
+
{"version":3,"names":["useEvent","useHandler","useAnimatedKeyboardHandler","handlers","dependencies","context","doDependenciesDiffer","event","onKeyboardMoveStart","onKeyboardMove","onKeyboardMoveEnd","onKeyboardMoveInteractive","eventName","endsWith","useFocusedInputLayoutHandler","onFocusedInputLayoutChanged","useFocusedInputTextHandler","onFocusedInputTextChanged"],"sources":["reanimated.native.ts"],"sourcesContent":["import { useEvent, useHandler } from \"react-native-reanimated\";\n\nimport type {\n EventWithName,\n FocusedInputLayoutChangedEvent,\n FocusedInputLayoutHandlerHook,\n FocusedInputTextChangedEvent,\n FocusedInputTextHandlerHook,\n KeyboardHandlerHook,\n NativeEvent,\n} 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\nexport const useFocusedInputLayoutHandler: FocusedInputLayoutHandlerHook<\n Record<string, unknown>,\n EventWithName<FocusedInputLayoutChangedEvent>\n> = (handlers, dependencies) => {\n const { context, doDependenciesDiffer } = useHandler(handlers, dependencies);\n\n return useEvent(\n (event) => {\n \"worklet\";\n const { onFocusedInputLayoutChanged } = handlers;\n\n if (\n onFocusedInputLayoutChanged &&\n event.eventName.endsWith(\"onFocusedInputLayoutChanged\")\n ) {\n onFocusedInputLayoutChanged(event, context);\n }\n },\n [\"onFocusedInputLayoutChanged\"],\n doDependenciesDiffer,\n );\n};\n\nexport const useFocusedInputTextHandler: FocusedInputTextHandlerHook<\n Record<string, unknown>,\n EventWithName<FocusedInputTextChangedEvent>\n> = (handlers, dependencies) => {\n const { context, doDependenciesDiffer } = useHandler(handlers, dependencies);\n\n return useEvent(\n (event) => {\n \"worklet\";\n const { onFocusedInputTextChanged } = handlers;\n\n if (\n onFocusedInputTextChanged &&\n event.eventName.endsWith(\"onFocusedInputTextChanged\")\n ) {\n onFocusedInputTextChanged(event, context);\n }\n },\n [\"onFocusedInputTextChanged\"],\n doDependenciesDiffer,\n );\n};\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,UAAU,QAAQ,yBAAyB;AAY9D,OAAO,MAAMC,0BAGZ,GAAGA,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,GAAG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O;IAAEC;EAAqB,CAAC,GAAGL,UAAU,CAACE,QAAQ,EAAEC,YAAY,CAAC;EAE5E,OAAOJ,QAAQ,CACZO,KAAK,IAAK;IACT,SAAS;;IACT,MAAM;MAAEU;IAA0B,CAAC,GAAGd,QAAQ;IAE9C,IACEc,yBAAyB,IACzBV,KAAK,CAACK,SAAS,CAACC,QAAQ,CAAC,2BAA2B,CAAC,EACrD;MACAI,yBAAyB,CAACV,KAAK,EAAEF,OAAO,CAAC;IAC3C;EACF,CAAC,EACD,CAAC,2BAA2B,CAAC,EAC7BC,oBACF,CAAC;AACH,CAAC"}
|
package/lib/module/replicas.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { useEffect, useMemo, useRef } from
|
|
2
|
-
import { Animated, Easing, Keyboard, Platform } from
|
|
3
|
-
import { runOnUI, useAnimatedReaction, useDerivedValue, useSharedValue,
|
|
4
|
-
import { KeyboardController } from
|
|
5
|
-
import { AndroidSoftInputModes } from
|
|
6
|
-
import { useReanimatedKeyboardAnimation } from
|
|
7
|
-
const availableOSEventType = Platform.OS ===
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
2
|
+
import { Animated, Easing, Keyboard, Platform } from "react-native";
|
|
3
|
+
import { runOnUI, useAnimatedReaction, useDerivedValue, useSharedValue, withSpring } from "react-native-reanimated";
|
|
4
|
+
import { KeyboardController } from "./bindings";
|
|
5
|
+
import { AndroidSoftInputModes } from "./constants";
|
|
6
|
+
import { useReanimatedKeyboardAnimation } from "./hooks";
|
|
7
|
+
const availableOSEventType = Platform.OS === "ios" ? "Will" : "Did";
|
|
8
8
|
|
|
9
9
|
// cubic-bezier(.17,.67,.34,.94)
|
|
10
10
|
export const defaultAndroidEasing = Easing.bezier(0.4, 0.0, 0.2, 1);
|
|
@@ -78,7 +78,9 @@ export const useReanimatedKeyboardAnimationReplica = () => {
|
|
|
78
78
|
const height = useSharedValue(0);
|
|
79
79
|
const heightEvent = useSharedValue(0);
|
|
80
80
|
const progress = useDerivedValue(() => height.value / heightEvent.value);
|
|
81
|
-
const handler =
|
|
81
|
+
const handler = useCallback(_height => {
|
|
82
|
+
"worklet";
|
|
83
|
+
|
|
82
84
|
heightEvent.value = _height;
|
|
83
85
|
}, []);
|
|
84
86
|
useAnimatedReaction(() => ({
|
|
@@ -93,10 +95,10 @@ export const useReanimatedKeyboardAnimationReplica = () => {
|
|
|
93
95
|
}
|
|
94
96
|
}, []);
|
|
95
97
|
useEffect(() => {
|
|
96
|
-
const show = Keyboard.addListener(
|
|
98
|
+
const show = Keyboard.addListener("keyboardWillShow", e => {
|
|
97
99
|
runOnUI(handler)(-e.endCoordinates.height);
|
|
98
100
|
});
|
|
99
|
-
const hide = Keyboard.addListener(
|
|
101
|
+
const hide = Keyboard.addListener("keyboardWillHide", () => {
|
|
100
102
|
runOnUI(handler)(0);
|
|
101
103
|
});
|
|
102
104
|
return () => {
|
|
@@ -109,5 +111,5 @@ export const useReanimatedKeyboardAnimationReplica = () => {
|
|
|
109
111
|
progress
|
|
110
112
|
};
|
|
111
113
|
};
|
|
112
|
-
export const useGradualKeyboardAnimation = Platform.OS ===
|
|
114
|
+
export const useGradualKeyboardAnimation = Platform.OS === "ios" ? useReanimatedKeyboardAnimationReplica : useReanimatedKeyboardAnimation;
|
|
113
115
|
//# sourceMappingURL=replicas.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useMemo","useRef","Animated","Easing","Keyboard","Platform","runOnUI","useAnimatedReaction","useDerivedValue","useSharedValue","
|
|
1
|
+
{"version":3,"names":["useCallback","useEffect","useMemo","useRef","Animated","Easing","Keyboard","Platform","runOnUI","useAnimatedReaction","useDerivedValue","useSharedValue","withSpring","KeyboardController","AndroidSoftInputModes","useReanimatedKeyboardAnimation","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 { useCallback, useEffect, useMemo, useRef } from \"react\";\nimport { Animated, Easing, Keyboard, Platform } from \"react-native\";\nimport {\n runOnUI,\n useAnimatedReaction,\n useDerivedValue,\n useSharedValue,\n withSpring,\n} from \"react-native-reanimated\";\n\nimport { KeyboardController } from \"./bindings\";\nimport { AndroidSoftInputModes } from \"./constants\";\nimport { useReanimatedKeyboardAnimation } from \"./hooks\";\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 = useCallback((_height: number) => {\n \"worklet\";\n\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 === \"ios\"\n ? useReanimatedKeyboardAnimationReplica\n : useReanimatedKeyboardAnimation;\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAC/D,SAASC,QAAQ,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,cAAc;AACnE,SACEC,OAAO,EACPC,mBAAmB,EACnBC,eAAe,EACfC,cAAc,EACdC,UAAU,QACL,yBAAyB;AAEhC,SAASC,kBAAkB,QAAQ,YAAY;AAC/C,SAASC,qBAAqB,QAAQ,aAAa;AACnD,SAASC,8BAA8B,QAAQ,SAAS;AAExD,MAAMC,oBAAoB,GAAGT,QAAQ,CAACU,EAAE,KAAK,KAAK,GAAG,MAAM,GAAG,KAAK;;AAEnE;AACA,OAAO,MAAMC,oBAAoB,GAAGb,MAAM,CAACc,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;AAMnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,2BAA2B,GAAGA,CAAA,KAAyB;EAClE,MAAMC,MAAM,GAAGlB,MAAM,CAAC,IAAIC,QAAQ,CAACkB,KAAK,CAAC,CAAC,CAAC,CAAC;EAC5C,MAAMC,QAAQ,GAAGpB,MAAM,CAAC,IAAIC,QAAQ,CAACkB,KAAK,CAAC,CAAC,CAAC,CAAC;EAC9C,MAAME,SAAS,GAAGtB,OAAO,CACvB,OAAO;IACLmB,MAAM,EAAEA,MAAM,CAACI,OAAO;IACtBF,QAAQ,EAAEA,QAAQ,CAACE;EACrB,CAAC,CAAC,EACF,EACF,CAAC;EAEDxB,SAAS,CAAC,MAAM;IACdY,kBAAkB,CAACa,YAAY,CAC7BZ,qBAAqB,CAACa,wBACxB,CAAC;IAED,OAAO,MAAMd,kBAAkB,CAACe,cAAc,CAAC,CAAC;EACl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,IAAI,GAAGnD,QAAQ,CAACwB,WAAW,CAAC,kBAAkB,EAAE,MAAM;MAC1DtB,OAAO,CAAC0C,OAAO,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC,CAAC;IAEF,OAAO,MAAM;MACXM,IAAI,CAACjB,MAAM,CAAC,CAAC;MACbkB,IAAI,CAAClB,MAAM,CAAC,CAAC;IACf,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO;IAAElB,MAAM;IAAEE;EAAS,CAAC;AAC7B,CAAC;AAED,OAAO,MAAMmC,2BAA2B,GACtCnD,QAAQ,CAACU,EAAE,KAAK,KAAK,GACjB8B,qCAAqC,GACrChC,8BAA8B"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import codegenNativeComponent from
|
|
2
|
-
export default codegenNativeComponent(
|
|
1
|
+
import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
|
|
2
|
+
export default codegenNativeComponent("KeyboardControllerView");
|
|
3
3
|
//# sourceMappingURL=KeyboardControllerViewNativeComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["codegenNativeComponent"],"sources":["KeyboardControllerViewNativeComponent.ts"],"sourcesContent":["import codegenNativeComponent from
|
|
1
|
+
{"version":3,"names":["codegenNativeComponent"],"sources":["KeyboardControllerViewNativeComponent.ts"],"sourcesContent":["import codegenNativeComponent from \"react-native/Libraries/Utilities/codegenNativeComponent\";\n\nimport 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\";\n\ntype KeyboardMoveEvent = Readonly<{\n height: Double;\n progress: Double;\n duration: Int32;\n target: Int32;\n}>;\n\ntype FocusedInputLayoutChangedEvent = Readonly<{\n target: Int32;\n layout: {\n x: Double;\n y: Double;\n width: Double;\n height: Double;\n absoluteX: Double;\n absoluteY: Double;\n };\n}>;\n\ntype FocusedInputTextChangedEvent = Readonly<{\n text: string;\n}>;\n\nexport interface NativeProps extends ViewProps {\n // props\n enabled?: boolean;\n statusBarTranslucent?: boolean;\n navigationBarTranslucent?: boolean;\n // callbacks\n /// keyboard\n onKeyboardMoveStart?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMove?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMoveEnd?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMoveInteractive?: DirectEventHandler<KeyboardMoveEvent>;\n /// focused input\n onFocusedInputLayoutChanged?: DirectEventHandler<FocusedInputLayoutChangedEvent>;\n onFocusedInputTextChanged?: DirectEventHandler<FocusedInputTextChangedEvent>;\n}\n\nexport default codegenNativeComponent<NativeProps>(\n \"KeyboardControllerView\",\n) as HostComponent<NativeProps>;\n"],"mappings":"AAAA,OAAOA,sBAAsB,MAAM,yDAAyD;AAiD5F,eAAeA,sBAAsB,CACnC,wBACF,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import codegenNativeComponent from
|
|
2
|
-
export default codegenNativeComponent(
|
|
3
|
-
excludedPlatforms: [
|
|
1
|
+
import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
|
|
2
|
+
export default codegenNativeComponent("KeyboardGestureArea", {
|
|
3
|
+
excludedPlatforms: ["iOS"]
|
|
4
4
|
});
|
|
5
5
|
//# sourceMappingURL=KeyboardGestureAreaNativeComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["codegenNativeComponent","excludedPlatforms"],"sources":["KeyboardGestureAreaNativeComponent.ts"],"sourcesContent":["import codegenNativeComponent from
|
|
1
|
+
{"version":3,"names":["codegenNativeComponent","excludedPlatforms"],"sources":["KeyboardGestureAreaNativeComponent.ts"],"sourcesContent":["import codegenNativeComponent from \"react-native/Libraries/Utilities/codegenNativeComponent\";\n\nimport type { HostComponent } from \"react-native\";\nimport type { ViewProps } from \"react-native/Libraries/Components/View/ViewPropTypes\";\nimport type { WithDefault } from \"react-native/Libraries/Types/CodegenTypes\";\n\nexport interface NativeProps extends ViewProps {\n interpolator?: WithDefault<\"linear\" | \"ios\", \"linear\">;\n showOnSwipeUp?: boolean;\n enableSwipeToDismiss?: boolean;\n}\n\nexport default codegenNativeComponent<NativeProps>(\"KeyboardGestureArea\", {\n excludedPlatforms: [\"iOS\"],\n}) as HostComponent<NativeProps>;\n"],"mappings":"AAAA,OAAOA,sBAAsB,MAAM,yDAAyD;AAY5F,eAAeA,sBAAsB,CAAc,qBAAqB,EAAE;EACxEC,iBAAiB,EAAE,CAAC,KAAK;AAC3B,CAAC,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { TurboModuleRegistry } from
|
|
2
|
-
export default TurboModuleRegistry.get(
|
|
1
|
+
import { TurboModuleRegistry } from "react-native";
|
|
2
|
+
export default TurboModuleRegistry.get("KeyboardController");
|
|
3
3
|
//# sourceMappingURL=NativeKeyboardController.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TurboModuleRegistry","get"],"sources":["NativeKeyboardController.ts"],"sourcesContent":["import { TurboModuleRegistry } from
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","get"],"sources":["NativeKeyboardController.ts"],"sourcesContent":["import { TurboModuleRegistry } from \"react-native\";\n\nimport type { TurboModule } from \"react-native\";\n\nexport interface Spec extends TurboModule {\n readonly getConstants: () => {};\n\n // methods\n setInputMode(mode: number): void;\n setDefaultMode(): void;\n dismiss(): void;\n\n // event emitter\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n}\n\nexport default TurboModuleRegistry.get<Spec>(\"KeyboardController\");\n"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,cAAc;AAiBlD,eAAeA,mBAAmB,CAACC,GAAG,CAAO,oBAAoB,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { TurboModuleRegistry } from
|
|
2
|
-
export default TurboModuleRegistry.get(
|
|
1
|
+
import { TurboModuleRegistry } from "react-native";
|
|
2
|
+
export default TurboModuleRegistry.get("StatusBarManagerCompat");
|
|
3
3
|
//# sourceMappingURL=NativeStatusBarManagerCompat.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TurboModuleRegistry","get"],"sources":["NativeStatusBarManagerCompat.ts"],"sourcesContent":["import { TurboModuleRegistry } from
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","get"],"sources":["NativeStatusBarManagerCompat.ts"],"sourcesContent":["import { TurboModuleRegistry } from \"react-native\";\n\nimport type { TurboModule } from \"react-native\";\n\nexport interface Spec extends TurboModule {\n readonly getConstants: () => {};\n\n setHidden(hidden: boolean): void;\n setColor(color: number, animated: boolean): void;\n setTranslucent(translucent: boolean): void;\n setStyle(style: string): void;\n}\n\nexport default TurboModuleRegistry.get<Spec>(\"StatusBarManagerCompat\");\n"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,cAAc;AAalD,eAAeA,mBAAmB,CAACC,GAAG,CAAO,wBAAwB,CAAC"}
|
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
|
|
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 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 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 // 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 // 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 KeyboardControllerModule = {\n // android only\n setDefaultMode: () => void;\n setInputMode: (mode: number) => void;\n // all platforms\n dismiss: () => 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?: 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;\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}>;\nexport type FocusedInputHandlers = Handlers<FocusedInputHandler>;\n"],"mappings":""}
|
package/lib/module/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["uuid","Math","random","toString","slice"],"sources":["utils.ts"],"sourcesContent":["export const uuid = () => Math.random().toString(36).slice(-6);\n"],"mappings":"AAAA,OAAO,MAAMA,IAAI,
|
|
1
|
+
{"version":3,"names":["uuid","Math","random","toString","slice"],"sources":["utils.ts"],"sourcesContent":["export const uuid = () => Math.random().toString(36).slice(-6);\n"],"mappings":"AAAA,OAAO,MAAMA,IAAI,GAAGA,CAAA,KAAMC,IAAI,CAACC,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,EAAE,CAAC,CAACC,KAAK,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { KeyboardControllerModule, KeyboardControllerProps, KeyboardEventsModule, KeyboardGestureAreaProps } from
|
|
2
|
+
import type { KeyboardControllerModule, KeyboardControllerProps, KeyboardEventsModule, KeyboardGestureAreaProps } from "./types";
|
|
3
3
|
export declare const KeyboardController: KeyboardControllerModule;
|
|
4
4
|
export declare const KeyboardEvents: KeyboardEventsModule;
|
|
5
5
|
export declare const KeyboardControllerView: import("react").FC<KeyboardControllerProps>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { KeyboardControllerModule, KeyboardControllerProps, KeyboardEventsModule, KeyboardGestureAreaProps } from
|
|
2
|
+
import type { KeyboardControllerModule, KeyboardControllerProps, KeyboardEventsModule, KeyboardGestureAreaProps } from "./types";
|
|
3
3
|
export declare const KeyboardController: KeyboardControllerModule;
|
|
4
4
|
export declare const KeyboardEvents: KeyboardEventsModule;
|
|
5
5
|
export declare const KeyboardControllerView: React.FC<KeyboardControllerProps>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { View } from
|
|
3
|
-
import type { ViewProps } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import type { ViewProps } from "react-native";
|
|
4
4
|
/**
|
|
5
5
|
* View that moves out of the way when the keyboard appears by automatically
|
|
6
6
|
* adjusting its height, position, or bottom padding.
|
|
@@ -13,7 +13,7 @@ declare const KeyboardAvoidingView: React.ForwardRefExoticComponent<{
|
|
|
13
13
|
/**
|
|
14
14
|
* Style of the content container when `behavior` is 'position'.
|
|
15
15
|
*/
|
|
16
|
-
contentContainerStyle?: ViewProps[
|
|
16
|
+
contentContainerStyle?: ViewProps["style"];
|
|
17
17
|
/**
|
|
18
18
|
* Controls whether this `KeyboardAvoidingView` instance should take effect.
|
|
19
19
|
* This is useful when more than one is on the screen. Defaults to true.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { FC } from "react";
|
|
2
|
+
import type { ScrollViewProps } from "react-native";
|
|
3
|
+
type KeyboardAwareScrollViewProps = {
|
|
4
|
+
bottomOffset?: number;
|
|
5
|
+
} & ScrollViewProps;
|
|
6
|
+
/**
|
|
7
|
+
* Everything begins from `onStart` handler. This handler is called every time,
|
|
8
|
+
* when keyboard changes its size or when focused `TextInput` was changed. In
|
|
9
|
+
* this handler we are calculating/memoizing values which later will be used
|
|
10
|
+
* during layout movement. For that we calculate:
|
|
11
|
+
* - layout of focused field (`layout`) - to understand whether there will be overlap
|
|
12
|
+
* - initial keyboard size (`initialKeyboardSize`) - used in scroll interpolation
|
|
13
|
+
* - future keyboard height (`keyboardHeight`) - used in scroll interpolation
|
|
14
|
+
* - current scroll position (`scrollPosition`) - used to scroll from this point
|
|
15
|
+
*
|
|
16
|
+
* Once we've calculated all necessary variables - we can actually start to use them.
|
|
17
|
+
* It happens in `onMove` handler - this function simply calls `maybeScroll` with
|
|
18
|
+
* current keyboard frame height. This functions makes the smooth transition.
|
|
19
|
+
*
|
|
20
|
+
* When the transition has finished we go to `onEnd` handler. In this handler
|
|
21
|
+
* we verify, that the current field is not overlapped within a keyboard frame.
|
|
22
|
+
* For full `onStart`/`onMove`/`onEnd` flow it may look like a redundant thing,
|
|
23
|
+
* however there could be some cases, when `onMove` is not called:
|
|
24
|
+
* - on iOS when TextInput was changed - keyboard transition is instant
|
|
25
|
+
* - on Android when TextInput was changed and keyboard size wasn't changed
|
|
26
|
+
* So `onEnd` handler handle the case, when `onMove` wasn't triggered.
|
|
27
|
+
*
|
|
28
|
+
* ====================================================================================================================+
|
|
29
|
+
* -----------------------------------------------------Flow chart-----------------------------------------------------+
|
|
30
|
+
* ====================================================================================================================+
|
|
31
|
+
*
|
|
32
|
+
* +============================+ +============================+ +==================================+
|
|
33
|
+
* + User Press on TextInput + => + Keyboard starts showing + => + As keyboard moves frame by frame + =>
|
|
34
|
+
* + + + (run `onStart`) + + `onMove` is getting called +
|
|
35
|
+
* +============================+ +============================+ +==================================+
|
|
36
|
+
*
|
|
37
|
+
*
|
|
38
|
+
* +============================+ +============================+ +=====================================+
|
|
39
|
+
* + Keyboard is shown and we + => + User moved focus to + => + Only `onStart`/`onEnd` maybe called +
|
|
40
|
+
* + call `onEnd` handler + + another `TextInput` + + (without involving `onMove`) +
|
|
41
|
+
* +============================+ +============================+ +=====================================+
|
|
42
|
+
*
|
|
43
|
+
*/
|
|
44
|
+
declare const KeyboardAwareScrollView: FC<KeyboardAwareScrollViewProps>;
|
|
45
|
+
export default KeyboardAwareScrollView;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { useKeyboardHandler } from "react-native-keyboard-controller";
|
|
2
|
+
/**
|
|
3
|
+
* Hook that uses default transitions for iOS and Android > 11, and uses
|
|
4
|
+
* custom interpolation on Android < 11 to achieve more smooth animation
|
|
5
|
+
*/
|
|
6
|
+
export declare const useSmoothKeyboardHandler: typeof useKeyboardHandler;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const debounce: <F extends (...args: Parameters<F>) => ReturnType<F>>(worklet: F, wait?: number) => (...args: Parameters<F>) => void | ReturnType<F>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import type { View, ViewProps } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { View, ViewProps } from "react-native";
|
|
3
3
|
declare const KeyboardStickyView: React.ForwardRefExoticComponent<{
|
|
4
4
|
/**
|
|
5
5
|
* Specify additional offset to the view for given keyboard state.
|