react-native-keyboard-controller 1.1.0 → 1.2.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.
Files changed (67) hide show
  1. package/android/build.gradle +72 -3
  2. package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerComponentsRegistry.kt +31 -0
  3. package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +25 -0
  4. package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +32 -0
  5. package/android/src/fabric/java/com/reactnativekeyboardcontroller/StatusBarManagerCompatModule.kt +25 -0
  6. package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardAnimationCallback.kt +6 -6
  7. package/android/src/main/java/com/reactnativekeyboardcontroller/{KeyboardControllerModule.kt → KeyboardControllerModuleImpl.kt} +5 -17
  8. package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardControllerPackage.kt +5 -0
  9. package/android/src/main/java/com/reactnativekeyboardcontroller/{KeyboardControllerViewManager.kt → KeyboardControllerViewManagerImpl.kt} +8 -9
  10. package/android/src/main/java/com/reactnativekeyboardcontroller/{StatusBarManagerCompatModule.kt → StatusBarManagerCompatImpl.kt} +10 -14
  11. package/android/src/main/jni/Android.mk +42 -0
  12. package/android/src/main/jni/KeyboardControllerComponentsRegistry.cpp +71 -0
  13. package/android/src/main/jni/KeyboardControllerComponentsRegistry.h +35 -0
  14. package/android/src/main/jni/OnLoad.cpp +9 -0
  15. package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +31 -0
  16. package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +26 -0
  17. package/android/src/paper/java/com/reactnativekeyboardcontroller/StatusBarManagerCompatModule.kt +34 -0
  18. package/ios/.clang-format +1 -1
  19. package/ios/KeyboardController.xcodeproj/project.pbxproj +18 -14
  20. package/ios/KeyboardControllerModule-Header.h +6 -2
  21. package/ios/KeyboardControllerModule.mm +105 -0
  22. package/ios/KeyboardControllerView.h +23 -0
  23. package/ios/KeyboardControllerView.mm +81 -0
  24. package/ios/{KeyboardControllerViewManager.m → KeyboardControllerViewManager.mm} +0 -0
  25. package/ios/KeyboardControllerViewManager.swift +2 -2
  26. package/ios/KeyboardMoveEvent.h +18 -0
  27. package/ios/KeyboardMoveEvent.m +74 -0
  28. package/lib/commonjs/KeyboardControllerViewNativeComponent.js +16 -0
  29. package/lib/commonjs/KeyboardControllerViewNativeComponent.js.map +1 -0
  30. package/lib/commonjs/NativeKeyboardController.js +13 -0
  31. package/lib/commonjs/NativeKeyboardController.js.map +1 -0
  32. package/lib/commonjs/NativeStatusBarManagerCompat.js +13 -0
  33. package/lib/commonjs/NativeStatusBarManagerCompat.js.map +1 -0
  34. package/lib/commonjs/architecture.js +13 -0
  35. package/lib/commonjs/architecture.js.map +1 -0
  36. package/lib/commonjs/monkey-patch.js +3 -1
  37. package/lib/commonjs/monkey-patch.js.map +1 -1
  38. package/lib/commonjs/native.js +4 -2
  39. package/lib/commonjs/native.js.map +1 -1
  40. package/lib/module/KeyboardControllerViewNativeComponent.js +4 -0
  41. package/lib/module/KeyboardControllerViewNativeComponent.js.map +1 -0
  42. package/lib/module/NativeKeyboardController.js +3 -0
  43. package/lib/module/NativeKeyboardController.js.map +1 -0
  44. package/lib/module/NativeStatusBarManagerCompat.js +3 -0
  45. package/lib/module/NativeStatusBarManagerCompat.js.map +1 -0
  46. package/lib/module/architecture.js +5 -0
  47. package/lib/module/architecture.js.map +1 -0
  48. package/lib/module/monkey-patch.js +2 -1
  49. package/lib/module/monkey-patch.js.map +1 -1
  50. package/lib/module/native.js +3 -2
  51. package/lib/module/native.js.map +1 -1
  52. package/lib/typescript/KeyboardControllerViewNativeComponent.d.ts +13 -0
  53. package/lib/typescript/NativeKeyboardController.d.ts +10 -0
  54. package/lib/typescript/NativeStatusBarManagerCompat.d.ts +10 -0
  55. package/lib/typescript/architecture.d.ts +2 -0
  56. package/lib/typescript/native.d.ts +1 -1
  57. package/package.json +16 -1
  58. package/react-native-keyboard-controller.podspec +19 -0
  59. package/src/KeyboardControllerViewNativeComponent.ts +23 -0
  60. package/src/NativeKeyboardController.ts +16 -0
  61. package/src/NativeStatusBarManagerCompat.ts +13 -0
  62. package/src/architecture.ts +4 -0
  63. package/src/monkey-patch.tsx +5 -1
  64. package/src/native.ts +12 -7
  65. package/ios/KeyboardControllerModule.m +0 -21
  66. package/ios/KeyboardControllerModule.swift +0 -53
  67. package/ios/KeyboardMoveEvent.swift +0 -41
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","Platform","NativeAndroidManager","getConstants","default","RCTStatusBarManagerCompat","StatusBarManagerCompat","OS","setColor","color","animated","setTranslucent","translucent","setStyle","statusBarStyle","setHidden","hidden"],"sources":["monkey-patch.tsx"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\n// @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\nconst RCTStatusBarManagerCompat = NativeModules.StatusBarManagerCompat;\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`.\nif (Platform.OS === 'android') {\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}\n"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,QAAxB,QAAwC,cAAxC,C,CACA;;AACA,OAAO,KAAKC,oBAAZ,MAAsC,2EAAtC;AAEA,MAAMC,YAAY,GAAGD,oBAAoB,CAACE,OAArB,CAA6BD,YAAlD;AAEA,MAAME,yBAAyB,GAAGL,aAAa,CAACM,sBAAhD,C,CAEA;AACA;AACA;;AACA,IAAIL,QAAQ,CAACM,EAAT,KAAgB,SAApB,EAA+B;EAC7BL,oBAAoB,CAACE,OAArB,GAA+B;IAC7BD,YAD6B;;IAE7BK,QAAQ,CAACC,KAAD,EAAgBC,QAAhB,EAAyC;MAC/CL,yBAAyB,CAACG,QAA1B,CAAmCC,KAAnC,EAA0CC,QAA1C;IACD,CAJ4B;;IAM7BC,cAAc,CAACC,WAAD,EAA6B;MACzCP,yBAAyB,CAACM,cAA1B,CAAyCC,WAAzC;IACD,CAR4B;;IAU7B;AACJ;AACA;AACA;AACA;IACIC,QAAQ,CAACC,cAAD,EAAgC;MACtCT,yBAAyB,CAACQ,QAA1B,CAAmCC,cAAnC;IACD,CAjB4B;;IAmB7BC,SAAS,CAACC,MAAD,EAAwB;MAC/BX,yBAAyB,CAACU,SAA1B,CAAoCC,MAApC;IACD;;EArB4B,CAA/B;AAuBD"}
1
+ {"version":3,"names":["NativeModules","Platform","NativeAndroidManager","isTurboModuleEnabled","getConstants","default","RCTStatusBarManagerCompat","require","StatusBarManagerCompat","OS","setColor","color","animated","setTranslucent","translucent","setStyle","statusBarStyle","setHidden","hidden"],"sources":["monkey-patch.tsx"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\n// @ts-expect-error because there is no corresponding type definition\nimport * as NativeAndroidManager from 'react-native/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid';\n\nimport { isTurboModuleEnabled } from './architecture';\n\nconst getConstants = NativeAndroidManager.default.getConstants;\n\nconst RCTStatusBarManagerCompat = isTurboModuleEnabled\n ? require('./NativeStatusBarManagerCompat').default\n : NativeModules.StatusBarManagerCompat;\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`.\nif (Platform.OS === 'android') {\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}\n"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,QAAxB,QAAwC,cAAxC,C,CACA;;AACA,OAAO,KAAKC,oBAAZ,MAAsC,2EAAtC;AAEA,SAASC,oBAAT,QAAqC,gBAArC;AAEA,MAAMC,YAAY,GAAGF,oBAAoB,CAACG,OAArB,CAA6BD,YAAlD;AAEA,MAAME,yBAAyB,GAAGH,oBAAoB,GAClDI,OAAO,CAAC,gCAAD,CAAP,CAA0CF,OADQ,GAElDL,aAAa,CAACQ,sBAFlB,C,CAIA;AACA;AACA;;AACA,IAAIP,QAAQ,CAACQ,EAAT,KAAgB,SAApB,EAA+B;EAC7BP,oBAAoB,CAACG,OAArB,GAA+B;IAC7BD,YAD6B;;IAE7BM,QAAQ,CAACC,KAAD,EAAgBC,QAAhB,EAAyC;MAC/CN,yBAAyB,CAACI,QAA1B,CAAmCC,KAAnC,EAA0CC,QAA1C;IACD,CAJ4B;;IAM7BC,cAAc,CAACC,WAAD,EAA6B;MACzCR,yBAAyB,CAACO,cAA1B,CAAyCC,WAAzC;IACD,CAR4B;;IAU7B;AACJ;AACA;AACA;AACA;IACIC,QAAQ,CAACC,cAAD,EAAgC;MACtCV,yBAAyB,CAACS,QAA1B,CAAmCC,cAAnC;IACD,CAjB4B;;IAmB7BC,SAAS,CAACC,MAAD,EAAwB;MAC/BZ,yBAAyB,CAACW,SAA1B,CAAoCC,MAApC;IACD;;EArB4B,CAA/B;AAuBD"}
@@ -1,5 +1,6 @@
1
1
  import { useEffect } from 'react';
2
2
  import { requireNativeComponent, UIManager, Platform, NativeModules, NativeEventEmitter } from 'react-native';
3
+ import { isFabricEnabled, isTurboModuleEnabled } from './architecture';
3
4
  const LINKING_ERROR = `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
4
5
  ios: "- You have run 'pod install'\n",
5
6
  default: ''
@@ -14,13 +15,13 @@ export let AndroidSoftInputModes;
14
15
  })(AndroidSoftInputModes || (AndroidSoftInputModes = {}));
15
16
 
16
17
  const ComponentName = 'KeyboardControllerView';
17
- const RCTKeyboardController = NativeModules.KeyboardController;
18
+ const RCTKeyboardController = isTurboModuleEnabled ? require('./NativeKeyboardController').default : NativeModules.KeyboardController;
18
19
  export const KeyboardController = RCTKeyboardController;
19
20
  const eventEmitter = new NativeEventEmitter(RCTKeyboardController);
20
21
  export const KeyboardEvents = {
21
22
  addListener: (name, cb) => eventEmitter.addListener('KeyboardController::' + name, cb)
22
23
  };
23
- export const KeyboardControllerView = UIManager.getViewManagerConfig(ComponentName) != null ? requireNativeComponent(ComponentName) : () => {
24
+ export const KeyboardControllerView = isFabricEnabled ? require('./KeyboardControllerViewNativeComponent').default : UIManager.getViewManagerConfig(ComponentName) != null ? requireNativeComponent(ComponentName) : () => {
24
25
  throw new Error(LINKING_ERROR);
25
26
  };
26
27
  export const useResizeMode = () => {
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","requireNativeComponent","UIManager","Platform","NativeModules","NativeEventEmitter","LINKING_ERROR","select","ios","default","AndroidSoftInputModes","ComponentName","RCTKeyboardController","KeyboardController","eventEmitter","KeyboardEvents","addListener","name","cb","KeyboardControllerView","getViewManagerConfig","Error","useResizeMode","setInputMode","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode"],"sources":["native.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport {\n requireNativeComponent,\n UIManager,\n Platform,\n NativeModules,\n NativeEventEmitter,\n NativeSyntheticEvent,\n ViewProps,\n} from 'react-native';\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 managed workflow\\n';\n\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}\n\nexport type NativeEvent = {\n progress: number;\n height: number;\n};\nexport type EventWithName<T> = {\n eventName: string;\n} & T;\nexport type KeyboardControllerProps = {\n onKeyboardMove: (e: NativeSyntheticEvent<EventWithName<NativeEvent>>) => void;\n // fake prop used to activate reanimated bindings\n onKeyboardMoveReanimated: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>\n ) => void;\n statusBarTranslucent?: boolean;\n} & ViewProps;\ntype KeyboardController = {\n // android only\n setDefaultMode: () => void;\n setInputMode: (mode: AndroidSoftInputModes) => void;\n};\n\nconst ComponentName = 'KeyboardControllerView';\n\nconst RCTKeyboardController = NativeModules.KeyboardController;\nexport const KeyboardController = RCTKeyboardController as KeyboardController;\n\nconst eventEmitter = new NativeEventEmitter(RCTKeyboardController);\ntype KeyboardControllerEvents =\n | 'keyboardWillShow'\n | 'keyboardDidShow'\n | 'keyboardWillHide'\n | 'keyboardDidHide';\ntype KeyboardEvent = {\n height: number;\n};\nexport const KeyboardEvents = {\n addListener: (\n name: KeyboardControllerEvents,\n cb: (e: KeyboardEvent) => void\n ) => eventEmitter.addListener('KeyboardController::' + name, cb),\n};\nexport const KeyboardControllerView =\n UIManager.getViewManagerConfig(ComponentName) != null\n ? requireNativeComponent<KeyboardControllerProps>(ComponentName)\n : () => {\n throw new Error(LINKING_ERROR);\n };\n\nexport const useResizeMode = () => {\n useEffect(() => {\n KeyboardController.setInputMode(\n AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE\n );\n\n return () => KeyboardController.setDefaultMode();\n }, []);\n};\n"],"mappings":"AAAA,SAASA,SAAT,QAA0B,OAA1B;AACA,SACEC,sBADF,EAEEC,SAFF,EAGEC,QAHF,EAIEC,aAJF,EAKEC,kBALF,QAQO,cARP;AAUA,MAAMC,aAAa,GAChB,2FAAD,GACAH,QAAQ,CAACI,MAAT,CAAgB;EAAEC,GAAG,EAAE,gCAAP;EAAyCC,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAMA,WAAYC,qBAAZ;;WAAYA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;GAAAA,qB,KAAAA,qB;;AA4BZ,MAAMC,aAAa,GAAG,wBAAtB;AAEA,MAAMC,qBAAqB,GAAGR,aAAa,CAACS,kBAA5C;AACA,OAAO,MAAMA,kBAAkB,GAAGD,qBAA3B;AAEP,MAAME,YAAY,GAAG,IAAIT,kBAAJ,CAAuBO,qBAAvB,CAArB;AASA,OAAO,MAAMG,cAAc,GAAG;EAC5BC,WAAW,EAAE,CACXC,IADW,EAEXC,EAFW,KAGRJ,YAAY,CAACE,WAAb,CAAyB,yBAAyBC,IAAlD,EAAwDC,EAAxD;AAJuB,CAAvB;AAMP,OAAO,MAAMC,sBAAsB,GACjCjB,SAAS,CAACkB,oBAAV,CAA+BT,aAA/B,KAAiD,IAAjD,GACIV,sBAAsB,CAA0BU,aAA1B,CAD1B,GAEI,MAAM;EACJ,MAAM,IAAIU,KAAJ,CAAUf,aAAV,CAAN;AACD,CALA;AAOP,OAAO,MAAMgB,aAAa,GAAG,MAAM;EACjCtB,SAAS,CAAC,MAAM;IACda,kBAAkB,CAACU,YAAnB,CACEb,qBAAqB,CAACc,wBADxB;IAIA,OAAO,MAAMX,kBAAkB,CAACY,cAAnB,EAAb;EACD,CANQ,EAMN,EANM,CAAT;AAOD,CARM"}
1
+ {"version":3,"names":["useEffect","requireNativeComponent","UIManager","Platform","NativeModules","NativeEventEmitter","isFabricEnabled","isTurboModuleEnabled","LINKING_ERROR","select","ios","default","AndroidSoftInputModes","ComponentName","RCTKeyboardController","require","KeyboardController","eventEmitter","KeyboardEvents","addListener","name","cb","KeyboardControllerView","getViewManagerConfig","Error","useResizeMode","setInputMode","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode"],"sources":["native.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport {\n requireNativeComponent,\n UIManager,\n Platform,\n NativeModules,\n NativeEventEmitter,\n NativeSyntheticEvent,\n ViewProps,\n} from 'react-native';\n\nimport { isFabricEnabled, isTurboModuleEnabled } from './architecture';\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 managed workflow\\n';\n\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}\n\nexport type NativeEvent = {\n progress: number;\n height: number;\n};\nexport type EventWithName<T> = {\n eventName: string;\n} & T;\nexport type KeyboardControllerProps = {\n onKeyboardMove: (e: NativeSyntheticEvent<EventWithName<NativeEvent>>) => void;\n // fake prop used to activate reanimated bindings\n onKeyboardMoveReanimated: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>\n ) => void;\n statusBarTranslucent?: boolean;\n} & ViewProps;\ntype KeyboardController = {\n // android only\n setDefaultMode: () => void;\n setInputMode: (mode: AndroidSoftInputModes) => void;\n};\n\nconst ComponentName = 'KeyboardControllerView';\n\nconst RCTKeyboardController = isTurboModuleEnabled\n ? require('./NativeKeyboardController').default\n : NativeModules.KeyboardController;\nexport const KeyboardController = RCTKeyboardController as KeyboardController;\n\nconst eventEmitter = new NativeEventEmitter(RCTKeyboardController);\ntype KeyboardControllerEvents =\n | 'keyboardWillShow'\n | 'keyboardDidShow'\n | 'keyboardWillHide'\n | 'keyboardDidHide';\ntype KeyboardEvent = {\n height: number;\n};\nexport const KeyboardEvents = {\n addListener: (\n name: KeyboardControllerEvents,\n cb: (e: KeyboardEvent) => void\n ) => eventEmitter.addListener('KeyboardController::' + name, cb),\n};\nexport const KeyboardControllerView = isFabricEnabled\n ? require('./KeyboardControllerViewNativeComponent').default\n : UIManager.getViewManagerConfig(ComponentName) != null\n ? requireNativeComponent<KeyboardControllerProps>(ComponentName)\n : () => {\n throw new Error(LINKING_ERROR);\n };\n\nexport const useResizeMode = () => {\n useEffect(() => {\n KeyboardController.setInputMode(\n AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE\n );\n\n return () => KeyboardController.setDefaultMode();\n }, []);\n};\n"],"mappings":"AAAA,SAASA,SAAT,QAA0B,OAA1B;AACA,SACEC,sBADF,EAEEC,SAFF,EAGEC,QAHF,EAIEC,aAJF,EAKEC,kBALF,QAQO,cARP;AAUA,SAASC,eAAT,EAA0BC,oBAA1B,QAAsD,gBAAtD;AAEA,MAAMC,aAAa,GAChB,2FAAD,GACAL,QAAQ,CAACM,MAAT,CAAgB;EAAEC,GAAG,EAAE,gCAAP;EAAyCC,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAMA,WAAYC,qBAAZ;;WAAYA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;GAAAA,qB,KAAAA,qB;;AA4BZ,MAAMC,aAAa,GAAG,wBAAtB;AAEA,MAAMC,qBAAqB,GAAGP,oBAAoB,GAC9CQ,OAAO,CAAC,4BAAD,CAAP,CAAsCJ,OADQ,GAE9CP,aAAa,CAACY,kBAFlB;AAGA,OAAO,MAAMA,kBAAkB,GAAGF,qBAA3B;AAEP,MAAMG,YAAY,GAAG,IAAIZ,kBAAJ,CAAuBS,qBAAvB,CAArB;AASA,OAAO,MAAMI,cAAc,GAAG;EAC5BC,WAAW,EAAE,CACXC,IADW,EAEXC,EAFW,KAGRJ,YAAY,CAACE,WAAb,CAAyB,yBAAyBC,IAAlD,EAAwDC,EAAxD;AAJuB,CAAvB;AAMP,OAAO,MAAMC,sBAAsB,GAAGhB,eAAe,GACjDS,OAAO,CAAC,yCAAD,CAAP,CAAmDJ,OADF,GAEjDT,SAAS,CAACqB,oBAAV,CAA+BV,aAA/B,KAAiD,IAAjD,GACAZ,sBAAsB,CAA0BY,aAA1B,CADtB,GAEA,MAAM;EACJ,MAAM,IAAIW,KAAJ,CAAUhB,aAAV,CAAN;AACD,CANE;AAQP,OAAO,MAAMiB,aAAa,GAAG,MAAM;EACjCzB,SAAS,CAAC,MAAM;IACdgB,kBAAkB,CAACU,YAAnB,CACEd,qBAAqB,CAACe,wBADxB;IAIA,OAAO,MAAMX,kBAAkB,CAACY,cAAnB,EAAb;EACD,CANQ,EAMN,EANM,CAAT;AAOD,CARM"}
@@ -0,0 +1,13 @@
1
+ import type { HostComponent } from 'react-native';
2
+ import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';
3
+ import type { DirectEventHandler, Float, Int32 } from 'react-native/Libraries/Types/CodegenTypes';
4
+ declare type KeyboardMoveEvent = Readonly<{
5
+ height: Int32;
6
+ progress: Float;
7
+ }>;
8
+ export interface NativeProps extends ViewProps {
9
+ statusBarTranslucent?: boolean;
10
+ onKeyboardMove?: DirectEventHandler<KeyboardMoveEvent>;
11
+ }
12
+ declare const _default: HostComponent<NativeProps>;
13
+ export default _default;
@@ -0,0 +1,10 @@
1
+ import type { TurboModule } from 'react-native';
2
+ export interface Spec extends TurboModule {
3
+ readonly getConstants: () => {};
4
+ setInputMode(mode: number): void;
5
+ setDefaultMode(): void;
6
+ addListener: (eventName: string) => void;
7
+ removeListeners: (count: number) => void;
8
+ }
9
+ declare const _default: Spec | null;
10
+ export default _default;
@@ -0,0 +1,10 @@
1
+ import type { TurboModule } from 'react-native';
2
+ export interface Spec extends TurboModule {
3
+ readonly getConstants: () => {};
4
+ setHidden(hidden: boolean): void;
5
+ setColor(color: number, animated: boolean): void;
6
+ setTranslucent(translucent: boolean): void;
7
+ setStyle(style: string): void;
8
+ }
9
+ declare const _default: Spec | null;
10
+ export default _default;
@@ -0,0 +1,2 @@
1
+ export declare const isTurboModuleEnabled: boolean;
2
+ export declare const isFabricEnabled: boolean;
@@ -29,6 +29,6 @@ declare type KeyboardEvent = {
29
29
  export declare const KeyboardEvents: {
30
30
  addListener: (name: KeyboardControllerEvents, cb: (e: KeyboardEvent) => void) => import("react-native").EmitterSubscription;
31
31
  };
32
- export declare const KeyboardControllerView: import("react-native").HostComponent<KeyboardControllerProps> | (() => never);
32
+ export declare const KeyboardControllerView: any;
33
33
  export declare const useResizeMode: () => void;
34
34
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-keyboard-controller",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Keyboard manager which works in identical way on both iOS and Android",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -16,6 +16,7 @@
16
16
  "react-native-keyboard-controller.podspec",
17
17
  "!lib/typescript/example",
18
18
  "!android/build",
19
+ "!android/.gradle",
19
20
  "!ios/build",
20
21
  "!**/__tests__",
21
22
  "!**/__fixtures__",
@@ -150,5 +151,19 @@
150
151
  }
151
152
  ]
152
153
  ]
154
+ },
155
+ "codegenConfig": {
156
+ "libraries": [
157
+ {
158
+ "name": "RNKeyboardControllerSpec",
159
+ "type": "modules",
160
+ "jsSrcsDir": "src"
161
+ },
162
+ {
163
+ "name": "RNKeyboardControllerViewSpec",
164
+ "type": "components",
165
+ "jsSrcsDir": "src"
166
+ }
167
+ ]
153
168
  }
154
169
  }
@@ -2,6 +2,8 @@ require "json"
2
2
 
3
3
  package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
4
 
5
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
6
+
5
7
  Pod::Spec.new do |s|
6
8
  s.name = "react-native-keyboard-controller"
7
9
  s.version = package["version"]
@@ -14,6 +16,23 @@ Pod::Spec.new do |s|
14
16
  s.source = { :git => "https://github.com/kirillzyusko/react-native-keyboard-controller.git", :tag => "#{s.version}" }
15
17
 
16
18
  s.source_files = "ios/**/*.{h,m,mm,swift}"
19
+ s.public_header_files = "ios/**/*.h"
17
20
 
18
21
  s.dependency "React-Core"
22
+
23
+ # This guard prevent to install the dependencies when we run `pod install` in the old architecture.
24
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
25
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
26
+ s.pod_target_xcconfig = {
27
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
28
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
29
+ }
30
+
31
+ s.dependency "React-RCTFabric"
32
+ s.dependency "React-Codegen"
33
+ s.dependency "RCT-Folly"
34
+ s.dependency "RCTRequired"
35
+ s.dependency "RCTTypeSafety"
36
+ s.dependency "ReactCommon/turbomodule/core"
37
+ end
19
38
  end
@@ -0,0 +1,23 @@
1
+ import type { HostComponent } from 'react-native';
2
+ // @ts-expect-error - no type definition
3
+ import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';
4
+ import type {
5
+ DirectEventHandler,
6
+ Float,
7
+ Int32,
8
+ } from 'react-native/Libraries/Types/CodegenTypes';
9
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
10
+
11
+ type KeyboardMoveEvent = Readonly<{
12
+ height: Int32;
13
+ progress: Float;
14
+ }>;
15
+
16
+ export interface NativeProps extends ViewProps {
17
+ statusBarTranslucent?: boolean;
18
+ onKeyboardMove?: DirectEventHandler<KeyboardMoveEvent>;
19
+ }
20
+
21
+ export default codegenNativeComponent<NativeProps>(
22
+ 'KeyboardControllerView'
23
+ ) as HostComponent<NativeProps>;
@@ -0,0 +1,16 @@
1
+ import type { TurboModule } from 'react-native';
2
+ import { TurboModuleRegistry } from 'react-native';
3
+
4
+ export interface Spec extends TurboModule {
5
+ readonly getConstants: () => {};
6
+
7
+ // methods
8
+ setInputMode(mode: number): void;
9
+ setDefaultMode(): void;
10
+
11
+ // event emitter
12
+ addListener: (eventName: string) => void;
13
+ removeListeners: (count: number) => void;
14
+ }
15
+
16
+ export default TurboModuleRegistry.get<Spec>('KeyboardController');
@@ -0,0 +1,13 @@
1
+ import type { TurboModule } from 'react-native';
2
+ import { TurboModuleRegistry } from 'react-native';
3
+
4
+ export interface Spec extends TurboModule {
5
+ readonly getConstants: () => {};
6
+
7
+ setHidden(hidden: boolean): void;
8
+ setColor(color: number, animated: boolean): void;
9
+ setTranslucent(translucent: boolean): void;
10
+ setStyle(style: string): void;
11
+ }
12
+
13
+ export default TurboModuleRegistry.get<Spec>('StatusBarManagerCompat');
@@ -0,0 +1,4 @@
1
+ // @ts-expect-error because `__turboModuleProxy` has any type (maybe think about own types declaration)
2
+ export const isTurboModuleEnabled = global.__turboModuleProxy != null;
3
+ // @ts-expect-error because `nativeFabricUIManager` has any type (maybe think about own types declaration)
4
+ export const isFabricEnabled = global.nativeFabricUIManager != null;
@@ -2,9 +2,13 @@ import { NativeModules, Platform } from 'react-native';
2
2
  // @ts-expect-error because there is no corresponding type definition
3
3
  import * as NativeAndroidManager from 'react-native/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid';
4
4
 
5
+ import { isTurboModuleEnabled } from './architecture';
6
+
5
7
  const getConstants = NativeAndroidManager.default.getConstants;
6
8
 
7
- const RCTStatusBarManagerCompat = NativeModules.StatusBarManagerCompat;
9
+ const RCTStatusBarManagerCompat = isTurboModuleEnabled
10
+ ? require('./NativeStatusBarManagerCompat').default
11
+ : NativeModules.StatusBarManagerCompat;
8
12
 
9
13
  // On Android < 11 RN uses legacy API which breaks EdgeToEdge mode in RN, so
10
14
  // in order to use library on all available platforms we have to monkey patch
package/src/native.ts CHANGED
@@ -9,6 +9,8 @@ import {
9
9
  ViewProps,
10
10
  } from 'react-native';
11
11
 
12
+ import { isFabricEnabled, isTurboModuleEnabled } from './architecture';
13
+
12
14
  const LINKING_ERROR =
13
15
  `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \n\n` +
14
16
  Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
@@ -45,7 +47,9 @@ type KeyboardController = {
45
47
 
46
48
  const ComponentName = 'KeyboardControllerView';
47
49
 
48
- const RCTKeyboardController = NativeModules.KeyboardController;
50
+ const RCTKeyboardController = isTurboModuleEnabled
51
+ ? require('./NativeKeyboardController').default
52
+ : NativeModules.KeyboardController;
49
53
  export const KeyboardController = RCTKeyboardController as KeyboardController;
50
54
 
51
55
  const eventEmitter = new NativeEventEmitter(RCTKeyboardController);
@@ -63,12 +67,13 @@ export const KeyboardEvents = {
63
67
  cb: (e: KeyboardEvent) => void
64
68
  ) => eventEmitter.addListener('KeyboardController::' + name, cb),
65
69
  };
66
- export const KeyboardControllerView =
67
- UIManager.getViewManagerConfig(ComponentName) != null
68
- ? requireNativeComponent<KeyboardControllerProps>(ComponentName)
69
- : () => {
70
- throw new Error(LINKING_ERROR);
71
- };
70
+ export const KeyboardControllerView = isFabricEnabled
71
+ ? require('./KeyboardControllerViewNativeComponent').default
72
+ : UIManager.getViewManagerConfig(ComponentName) != null
73
+ ? requireNativeComponent<KeyboardControllerProps>(ComponentName)
74
+ : () => {
75
+ throw new Error(LINKING_ERROR);
76
+ };
72
77
 
73
78
  export const useResizeMode = () => {
74
79
  useEffect(() => {
@@ -1,21 +0,0 @@
1
- //
2
- // RCTBridge.m
3
- // KeyboardController
4
- //
5
- // Created by Kiryl Ziusko on 22.04.22.
6
- // Copyright © 2022 Facebook. All rights reserved.
7
- //
8
-
9
- #import <React/RCTBridgeModule.h>
10
- #import <React/RCTEventEmitter.h>
11
-
12
- @interface RCT_EXTERN_MODULE (KeyboardController, RCTEventEmitter)
13
-
14
- // Android stubs
15
- RCT_EXTERN_METHOD(setInputMode : (nonnull NSNumber *)mode)
16
- RCT_EXTERN_METHOD(setDefaultMode)
17
-
18
- // event emitter
19
- RCT_EXTERN_METHOD(supportedEvents)
20
-
21
- @end
@@ -1,53 +0,0 @@
1
- //
2
- // KeyboardController.swift
3
- // KeyboardController
4
- //
5
- // Created by Kiryl Ziusko on 22.04.22.
6
- // Copyright © 2022 Facebook. All rights reserved.
7
- //
8
-
9
- import AVFoundation
10
- import Foundation
11
- import UIKit
12
-
13
- @objc(KeyboardController)
14
- class KeyboardController: RCTEventEmitter {
15
- public static var shared: KeyboardController?
16
- private var hasListeners = false
17
-
18
- override class func requiresMainQueueSetup() -> Bool {
19
- return false
20
- }
21
-
22
- override init() {
23
- super.init()
24
- KeyboardController.shared = self
25
- }
26
-
27
- // Android stubs
28
- @objc func setInputMode(_: NSNumber!) {}
29
- @objc func setDefaultMode() {}
30
-
31
- @objc override open func supportedEvents() -> [String] {
32
- return [
33
- "KeyboardController::keyboardWillShow",
34
- "KeyboardController::keyboardDidShow",
35
- "KeyboardController::keyboardWillHide",
36
- "KeyboardController::keyboardDidHide",
37
- ]
38
- }
39
-
40
- @objc override open func startObserving() {
41
- hasListeners = true
42
- }
43
-
44
- @objc override open func stopObserving() {
45
- hasListeners = false
46
- }
47
-
48
- @objc override open func sendEvent(withName name: String!, body: Any!) {
49
- if hasListeners {
50
- super.sendEvent(withName: name, body: body)
51
- }
52
- }
53
- }
@@ -1,41 +0,0 @@
1
- //
2
- // KeyboardMoveEvent.swift
3
- // KeyboardController
4
- //
5
- // Created by Kiryl Ziusko on 26.04.22.
6
- // Copyright © 2022 Facebook. All rights reserved.
7
- //
8
-
9
- class KeyboardMoveEvent: NSObject, RCTEvent {
10
- var viewTag: NSNumber!
11
- var eventName: String = "onKeyboardMove"
12
- var coalescingKey: UInt16 = 0
13
- var height: NSNumber!
14
- var progress: NSNumber!
15
-
16
- func canCoalesce() -> Bool {
17
- return false
18
- }
19
-
20
- func coalesce(with newEvent: RCTEvent!) -> RCTEvent! {
21
- return newEvent
22
- }
23
-
24
- static func moduleDotMethod() -> String! {
25
- return "RCTEventEmitter.receiveEvent"
26
- }
27
-
28
- func arguments() -> [Any]! {
29
- return [
30
- viewTag,
31
- RCTNormalizeInputEventName(eventName),
32
- ["height": height, "progress": progress],
33
- ]
34
- }
35
-
36
- init(viewTag: NSNumber, height: NSNumber, progress: NSNumber) {
37
- self.viewTag = viewTag
38
- self.height = height
39
- self.progress = progress
40
- }
41
- }