react-native-nitro-modal 0.1.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 (117) hide show
  1. package/LICENSE +20 -0
  2. package/NitroModal.podspec +29 -0
  3. package/README.md +39 -0
  4. package/android/CMakeLists.txt +24 -0
  5. package/android/build.gradle +124 -0
  6. package/android/src/main/AndroidManifest.xml +2 -0
  7. package/android/src/main/cpp/cpp-adapter.cpp +11 -0
  8. package/android/src/main/java/com/margelo/nitro/nitromodal/BottomSheetPresenter.kt +284 -0
  9. package/android/src/main/java/com/margelo/nitro/nitromodal/HybridNitroModal.kt +312 -0
  10. package/android/src/main/java/com/margelo/nitro/nitromodal/ModalConfig.kt +50 -0
  11. package/android/src/main/java/com/margelo/nitro/nitromodal/ModalContentRoot.kt +115 -0
  12. package/android/src/main/java/com/margelo/nitro/nitromodal/ModalPresenter.kt +253 -0
  13. package/android/src/main/java/com/margelo/nitro/nitromodal/NitroModalHostView.kt +52 -0
  14. package/android/src/main/java/com/margelo/nitro/nitromodal/NitroModalPackage.kt +28 -0
  15. package/android/src/main/java/com/margelo/nitro/nitromodal/NitroModalViewManager.kt +67 -0
  16. package/android/src/main/java/com/margelo/nitro/nitromodal/PopupPresenter.kt +156 -0
  17. package/android/src/main/res/values/styles.xml +17 -0
  18. package/ios/BackdropView.swift +64 -0
  19. package/ios/HybridNitroModal.swift +329 -0
  20. package/ios/HybridNitroModalComponent+Children.mm +77 -0
  21. package/ios/ModalConfig.swift +73 -0
  22. package/ios/NitroModalHostView.swift +91 -0
  23. package/ios/PopupViewController.swift +223 -0
  24. package/ios/SheetViewController.swift +244 -0
  25. package/lib/module/NitroModal.js +188 -0
  26. package/lib/module/NitroModal.js.map +1 -0
  27. package/lib/module/NitroModal.nitro.js +4 -0
  28. package/lib/module/NitroModal.nitro.js.map +1 -0
  29. package/lib/module/NitroModalView.js +17 -0
  30. package/lib/module/NitroModalView.js.map +1 -0
  31. package/lib/module/NitroModalView.native.js +6 -0
  32. package/lib/module/NitroModalView.native.js.map +1 -0
  33. package/lib/module/index.js +4 -0
  34. package/lib/module/index.js.map +1 -0
  35. package/lib/module/package.json +1 -0
  36. package/lib/typescript/package.json +1 -0
  37. package/lib/typescript/src/NitroModal.d.ts +59 -0
  38. package/lib/typescript/src/NitroModal.d.ts.map +1 -0
  39. package/lib/typescript/src/NitroModal.nitro.d.ts +78 -0
  40. package/lib/typescript/src/NitroModal.nitro.d.ts.map +1 -0
  41. package/lib/typescript/src/NitroModalView.d.ts +4 -0
  42. package/lib/typescript/src/NitroModalView.d.ts.map +1 -0
  43. package/lib/typescript/src/NitroModalView.native.d.ts +3 -0
  44. package/lib/typescript/src/NitroModalView.native.d.ts.map +1 -0
  45. package/lib/typescript/src/index.d.ts +3 -0
  46. package/lib/typescript/src/index.d.ts.map +1 -0
  47. package/nitro.json +23 -0
  48. package/nitrogen/generated/android/c++/JDismissReason.hpp +64 -0
  49. package/nitrogen/generated/android/c++/JFunc_void.hpp +75 -0
  50. package/nitrogen/generated/android/c++/JFunc_void_DismissReason.hpp +77 -0
  51. package/nitrogen/generated/android/c++/JFunc_void_ModalContentArea.hpp +77 -0
  52. package/nitrogen/generated/android/c++/JFunc_void_double.hpp +75 -0
  53. package/nitrogen/generated/android/c++/JHybridNitroModalSpec.cpp +344 -0
  54. package/nitrogen/generated/android/c++/JHybridNitroModalSpec.hpp +106 -0
  55. package/nitrogen/generated/android/c++/JKeyboardBehavior.hpp +61 -0
  56. package/nitrogen/generated/android/c++/JModalContentArea.hpp +61 -0
  57. package/nitrogen/generated/android/c++/JModalMode.hpp +58 -0
  58. package/nitrogen/generated/android/c++/JPopupAnimation.hpp +61 -0
  59. package/nitrogen/generated/android/c++/JSheetDetent.hpp +64 -0
  60. package/nitrogen/generated/android/c++/views/JHybridNitroModalStateUpdater.cpp +174 -0
  61. package/nitrogen/generated/android/c++/views/JHybridNitroModalStateUpdater.hpp +54 -0
  62. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/DismissReason.kt +25 -0
  63. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/Func_void.kt +78 -0
  64. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/Func_void_DismissReason.kt +78 -0
  65. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/Func_void_ModalContentArea.kt +78 -0
  66. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/Func_void_double.kt +78 -0
  67. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/HybridNitroModalSpec.kt +237 -0
  68. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/KeyboardBehavior.kt +24 -0
  69. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/ModalContentArea.kt +56 -0
  70. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/ModalMode.kt +23 -0
  71. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/PopupAnimation.kt +24 -0
  72. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/SheetDetent.kt +25 -0
  73. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/nitromodalOnLoad.kt +35 -0
  74. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/views/HybridNitroModalManager.kt +96 -0
  75. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/views/HybridNitroModalStateUpdater.kt +23 -0
  76. package/nitrogen/generated/android/nitromodal+autolinking.cmake +83 -0
  77. package/nitrogen/generated/android/nitromodal+autolinking.gradle +27 -0
  78. package/nitrogen/generated/android/nitromodalOnLoad.cpp +64 -0
  79. package/nitrogen/generated/android/nitromodalOnLoad.hpp +34 -0
  80. package/nitrogen/generated/ios/NitroModal+autolinking.rb +62 -0
  81. package/nitrogen/generated/ios/NitroModal-Swift-Cxx-Bridge.cpp +65 -0
  82. package/nitrogen/generated/ios/NitroModal-Swift-Cxx-Bridge.hpp +237 -0
  83. package/nitrogen/generated/ios/NitroModal-Swift-Cxx-Umbrella.hpp +64 -0
  84. package/nitrogen/generated/ios/NitroModalAutolinking.mm +33 -0
  85. package/nitrogen/generated/ios/NitroModalAutolinking.swift +26 -0
  86. package/nitrogen/generated/ios/c++/HybridNitroModalSpecSwift.cpp +11 -0
  87. package/nitrogen/generated/ios/c++/HybridNitroModalSpecSwift.hpp +247 -0
  88. package/nitrogen/generated/ios/c++/views/HybridNitroModalComponent.mm +264 -0
  89. package/nitrogen/generated/ios/swift/DismissReason.swift +48 -0
  90. package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
  91. package/nitrogen/generated/ios/swift/Func_void_DismissReason.swift +46 -0
  92. package/nitrogen/generated/ios/swift/Func_void_ModalContentArea.swift +46 -0
  93. package/nitrogen/generated/ios/swift/Func_void_double.swift +46 -0
  94. package/nitrogen/generated/ios/swift/HybridNitroModalSpec.swift +77 -0
  95. package/nitrogen/generated/ios/swift/HybridNitroModalSpec_cxx.swift +554 -0
  96. package/nitrogen/generated/ios/swift/KeyboardBehavior.swift +44 -0
  97. package/nitrogen/generated/ios/swift/ModalContentArea.swift +34 -0
  98. package/nitrogen/generated/ios/swift/ModalMode.swift +40 -0
  99. package/nitrogen/generated/ios/swift/PopupAnimation.swift +44 -0
  100. package/nitrogen/generated/ios/swift/SheetDetent.swift +48 -0
  101. package/nitrogen/generated/shared/c++/DismissReason.hpp +84 -0
  102. package/nitrogen/generated/shared/c++/HybridNitroModalSpec.cpp +65 -0
  103. package/nitrogen/generated/shared/c++/HybridNitroModalSpec.hpp +124 -0
  104. package/nitrogen/generated/shared/c++/KeyboardBehavior.hpp +80 -0
  105. package/nitrogen/generated/shared/c++/ModalContentArea.hpp +87 -0
  106. package/nitrogen/generated/shared/c++/ModalMode.hpp +76 -0
  107. package/nitrogen/generated/shared/c++/PopupAnimation.hpp +80 -0
  108. package/nitrogen/generated/shared/c++/SheetDetent.hpp +84 -0
  109. package/nitrogen/generated/shared/c++/views/HybridNitroModalComponent.cpp +74 -0
  110. package/nitrogen/generated/shared/c++/views/HybridNitroModalComponent.hpp +151 -0
  111. package/nitrogen/generated/shared/json/NitroModalConfig.json +30 -0
  112. package/package.json +183 -0
  113. package/src/NitroModal.nitro.ts +92 -0
  114. package/src/NitroModal.tsx +292 -0
  115. package/src/NitroModalView.native.tsx +8 -0
  116. package/src/NitroModalView.tsx +24 -0
  117. package/src/index.tsx +12 -0
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ let warned = false;
4
+
5
+ /**
6
+ * Platforms without a native implementation (e.g. web) render nothing.
7
+ * iOS and Android use `NitroModalView.native.tsx`.
8
+ */
9
+ function UnsupportedNitroModalView() {
10
+ if (!warned) {
11
+ warned = true;
12
+ console.warn('react-native-nitro-modal is only implemented on iOS and Android.');
13
+ }
14
+ return null;
15
+ }
16
+ export const NitroModalView = UnsupportedNitroModalView;
17
+ //# sourceMappingURL=NitroModalView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["warned","UnsupportedNitroModalView","console","warn","NitroModalView"],"sourceRoot":"../../src","sources":["NitroModalView.tsx"],"mappings":";;AAGA,IAAIA,MAAM,GAAG,KAAK;;AAElB;AACA;AACA;AACA;AACA,SAASC,yBAAyBA,CAAA,EAAG;EACnC,IAAI,CAACD,MAAM,EAAE;IACXA,MAAM,GAAG,IAAI;IACbE,OAAO,CAACC,IAAI,CACV,kEACF,CAAC;EACH;EACA,OAAO,IAAI;AACb;AAEA,OAAO,MAAMC,cAAc,GACzBH,yBAGC","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ import { getHostComponent } from 'react-native-nitro-modules';
4
+ const NitroModalConfig = require('../nitrogen/generated/shared/json/NitroModalConfig.json');
5
+ export const NitroModalView = getHostComponent('NitroModal', () => NitroModalConfig);
6
+ //# sourceMappingURL=NitroModalView.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getHostComponent","NitroModalConfig","require","NitroModalView"],"sourceRoot":"../../src","sources":["NitroModalView.native.tsx"],"mappings":";;AAAA,SAASA,gBAAgB,QAAQ,4BAA4B;AAC7D,MAAMC,gBAAgB,GAAGC,OAAO,CAAC,yDAAyD,CAAC;AAG3F,OAAO,MAAMC,cAAc,GAAGH,gBAAgB,CAG5C,YAAY,EAAE,MAAMC,gBAAgB,CAAC","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export { NitroModal } from "./NitroModal.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NitroModal"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SACEA,UAAU,QAGL,iBAAc","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,59 @@
1
+ import { type ReactNode, type Ref } from 'react';
2
+ import { type ColorValue, type StyleProp, type ViewStyle } from 'react-native';
3
+ import type { DismissReason, KeyboardBehavior, ModalMode, PopupAnimation, SheetDetent } from './NitroModal.nitro.js';
4
+ export interface NitroModalRef {
5
+ /** Opens the modal. Only for uncontrolled usage (no `isOpen` prop). */
6
+ present(): void;
7
+ /** Closes the modal. `onDismiss` then fires with `'programmatic'`. */
8
+ dismiss(): void;
9
+ /** Animates a `bottomSheet` to `detents[index]`. */
10
+ snapToDetent(index: number): void;
11
+ }
12
+ export interface NitroModalProps {
13
+ /**
14
+ * Controls visibility. Leave undefined to drive the modal through `ref`
15
+ * instead. When the user dismisses it natively (swipe, backdrop, back
16
+ * button), `onDismiss` fires and you should set this back to `false`.
17
+ */
18
+ isOpen?: boolean;
19
+ /** @default 'bottomSheet' */
20
+ mode?: ModalMode;
21
+ /** Sheet heights, smallest first. Android uses at most three. @default ['fitContent'] */
22
+ detents?: SheetDetent[];
23
+ /** @default 0 */
24
+ initialDetentIndex?: number;
25
+ /** @default 'black' */
26
+ backdropColor?: ColorValue;
27
+ /** @default 0.4 */
28
+ backdropOpacity?: number;
29
+ /** Blur radius (dp/pt) behind the modal. Android 12+; approximated on iOS. @default 0 */
30
+ backdropBlur?: number;
31
+ /** @default true */
32
+ dismissOnBackdropPress?: boolean;
33
+ /** Swipe down to dismiss a `bottomSheet`. @default true */
34
+ dismissOnSwipe?: boolean;
35
+ /** Android back button/gesture dismisses the modal. @default true */
36
+ dismissOnBackButton?: boolean;
37
+ /** @default false */
38
+ showGrabber?: boolean;
39
+ /** Corner radius of the sheet/card. Defaults to the platform style. */
40
+ cornerRadius?: number;
41
+ /** Sheet/card background. Defaults to the system surface color. */
42
+ backgroundColor?: ColorValue;
43
+ /** @default 'pan' */
44
+ keyboardBehavior?: KeyboardBehavior;
45
+ /** @default 'scale' */
46
+ popupAnimation?: PopupAnimation;
47
+ /** Style of the view that wraps `children` inside the modal. */
48
+ contentContainerStyle?: StyleProp<ViewStyle>;
49
+ onPresent?: () => void;
50
+ onDismiss?: (reason: DismissReason) => void;
51
+ onDetentChange?: (index: number) => void;
52
+ onBackdropPress?: () => void;
53
+ onBackButtonPress?: () => void;
54
+ children?: ReactNode;
55
+ testID?: string;
56
+ ref?: Ref<NitroModalRef>;
57
+ }
58
+ export declare function NitroModal({ isOpen, mode, detents, initialDetentIndex, backdropColor, backdropOpacity, backdropBlur, dismissOnBackdropPress, dismissOnSwipe, dismissOnBackButton, showGrabber, cornerRadius, backgroundColor, keyboardBehavior, popupAnimation, contentContainerStyle, onPresent, onDismiss, onDetentChange, onBackdropPress, onBackButtonPress, children, testID, ref, }: NitroModalProps): import("react").JSX.Element;
59
+ //# sourceMappingURL=NitroModal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NitroModal.d.ts","sourceRoot":"","sources":["../../../src/NitroModal.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,SAAS,EACd,KAAK,GAAG,EACT,MAAM,OAAO,CAAC;AACf,OAAO,EAKL,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAEhB,SAAS,EAET,cAAc,EACd,WAAW,EACZ,MAAM,uBAAoB,CAAC;AAG5B,MAAM,WAAW,aAAa;IAC5B,uEAAuE;IACvE,OAAO,IAAI,IAAI,CAAC;IAChB,sEAAsE;IACtE,OAAO,IAAI,IAAI,CAAC;IAChB,oDAAoD;IACpD,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,6BAA6B;IAC7B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,yFAAyF;IACzF,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;IACxB,iBAAiB;IACjB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,uBAAuB;IACvB,aAAa,CAAC,EAAE,UAAU,CAAC;IAC3B,mBAAmB;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yFAAyF;IACzF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB;IACpB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,2DAA2D;IAC3D,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,qEAAqE;IACrE,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,qBAAqB;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,uEAAuE;IACvE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mEAAmE;IACnE,eAAe,CAAC,EAAE,UAAU,CAAC;IAC7B,qBAAqB;IACrB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,uBAAuB;IACvB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,gEAAgE;IAChE,qBAAqB,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7C,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;IAC5C,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC/B,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;CAC1B;AAYD,wBAAgB,UAAU,CAAC,EACzB,MAAM,EACN,IAAoB,EACpB,OAAyB,EACzB,kBAAsB,EACtB,aAAuB,EACvB,eAAqB,EACrB,YAAgB,EAChB,sBAA6B,EAC7B,cAAqB,EACrB,mBAA0B,EAC1B,WAAmB,EACnB,YAAY,EACZ,eAAe,EACf,gBAAwB,EACxB,cAAwB,EACxB,qBAAqB,EACrB,SAAS,EACT,SAAS,EACT,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,QAAQ,EACR,MAAM,EACN,GAAG,GACJ,EAAE,eAAe,+BAuJjB"}
@@ -0,0 +1,78 @@
1
+ import type { HybridView, HybridViewMethods, HybridViewProps } from 'react-native-nitro-modules';
2
+ /**
3
+ * How the modal is presented.
4
+ * - `bottomSheet`: native sheet (iOS `UISheetPresentationController`,
5
+ * Android `BottomSheetBehavior`) with detents and swipe-to-dismiss.
6
+ * - `popup`: centered dialog with a native fade/scale transition.
7
+ */
8
+ export type ModalMode = 'bottomSheet' | 'popup';
9
+ /**
10
+ * Resting heights of a `bottomSheet`.
11
+ * - `small`: ~25% of the available height.
12
+ * - `medium`: ~50% of the available height.
13
+ * - `large`: the full available height.
14
+ * - `fitContent`: the measured height of the React content.
15
+ */
16
+ export type SheetDetent = 'small' | 'medium' | 'large' | 'fitContent';
17
+ /**
18
+ * How the modal reacts to the software keyboard.
19
+ * - `pan`: the sheet/card is translated above the keyboard, in sync with the
20
+ * keyboard animation. The content keeps its size.
21
+ * - `resize`: like `pan`, and the area reported to the content shrinks so
22
+ * scrollable content can fit above the keyboard.
23
+ * - `none`: the keyboard is ignored.
24
+ */
25
+ export type KeyboardBehavior = 'pan' | 'resize' | 'none';
26
+ /** Enter/exit transition of a `popup`. */
27
+ export type PopupAnimation = 'scale' | 'fade' | 'none';
28
+ /** What caused the modal to close. */
29
+ export type DismissReason = 'programmatic' | 'swipe' | 'backdrop' | 'backButton';
30
+ /** Size (dp/pt) available to the React content inside the presented modal. */
31
+ export interface ModalContentArea {
32
+ width: number;
33
+ height: number;
34
+ }
35
+ export interface NitroModalProps extends HybridViewProps {
36
+ /** Whether the modal should be presented. */
37
+ isOpen: boolean;
38
+ mode: ModalMode;
39
+ /** Detents of a `bottomSheet`, smallest first. At most 3 are used on Android. */
40
+ detents: SheetDetent[];
41
+ /** Index into `detents` that the sheet opens at. */
42
+ initialDetentIndex: number;
43
+ /** Backdrop color as a processed ARGB color (see `processColor`). */
44
+ backdropColor: number;
45
+ /** Opacity of the backdrop color, 0-1. */
46
+ backdropOpacity: number;
47
+ /** Blur radius (dp/pt) applied behind the modal. 0 disables the blur. */
48
+ backdropBlurRadius: number;
49
+ dismissOnBackdropPress: boolean;
50
+ dismissOnSwipe: boolean;
51
+ dismissOnBackButton: boolean;
52
+ grabberVisible: boolean;
53
+ /** Corner radius of the sheet/card. A negative value uses the platform default. */
54
+ cornerRadius: number;
55
+ /** Sheet/card background as a processed ARGB color. Omit for the system background. */
56
+ contentBackgroundColor?: number;
57
+ keyboardBehavior: KeyboardBehavior;
58
+ popupAnimation: PopupAnimation;
59
+ /** The present transition finished. */
60
+ onPresent?: () => void;
61
+ /** The modal is fully gone. Fired exactly once for every presentation request. */
62
+ onDismiss?: (reason: DismissReason) => void;
63
+ /** A `bottomSheet` settled on a different detent. */
64
+ onDetentChange?: (index: number) => void;
65
+ onBackdropPress?: () => void;
66
+ /** Android hardware/gesture back. */
67
+ onBackButtonPress?: () => void;
68
+ /** The area available to the content changed (rotation, keyboard, sheet sizing). */
69
+ onContentAreaChange?: (area: ModalContentArea) => void;
70
+ }
71
+ export interface NitroModalMethods extends HybridViewMethods {
72
+ present(): void;
73
+ dismiss(): void;
74
+ /** Animates a `bottomSheet` to `detents[index]`. */
75
+ snapToDetent(index: number): void;
76
+ }
77
+ export type NitroModal = HybridView<NitroModalProps, NitroModalMethods>;
78
+ //# sourceMappingURL=NitroModal.nitro.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NitroModal.nitro.d.ts","sourceRoot":"","sources":["../../../src/NitroModal.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EACjB,eAAe,EAChB,MAAM,4BAA4B,CAAC;AAEpC;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,OAAO,CAAC;AAEhD;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,YAAY,CAAC;AAEtE;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEzD,0CAA0C;AAC1C,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAEvD,sCAAsC;AACtC,MAAM,MAAM,aAAa,GACvB,cAAc,GAAG,OAAO,GAAG,UAAU,GAAG,YAAY,CAAC;AAEvD,8EAA8E;AAC9E,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD,6CAA6C;IAC7C,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,SAAS,CAAC;IAChB,iFAAiF;IACjF,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,oDAAoD;IACpD,kBAAkB,EAAE,MAAM,CAAC;IAC3B,qEAAqE;IACrE,aAAa,EAAE,MAAM,CAAC;IACtB,0CAA0C;IAC1C,eAAe,EAAE,MAAM,CAAC;IACxB,yEAAyE;IACzE,kBAAkB,EAAE,MAAM,CAAC;IAC3B,sBAAsB,EAAE,OAAO,CAAC;IAChC,cAAc,EAAE,OAAO,CAAC;IACxB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,cAAc,EAAE,OAAO,CAAC;IACxB,mFAAmF;IACnF,YAAY,EAAE,MAAM,CAAC;IACrB,uFAAuF;IACvF,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,cAAc,EAAE,cAAc,CAAC;IAE/B,uCAAuC;IACvC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,kFAAkF;IAClF,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;IAC5C,qDAAqD;IACrD,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,qCAAqC;IACrC,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC/B,oFAAoF;IACpF,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,CAAC;CACxD;AAED,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;IAC1D,OAAO,IAAI,IAAI,CAAC;IAChB,OAAO,IAAI,IAAI,CAAC;IAChB,oDAAoD;IACpD,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ReactNativeView } from 'react-native-nitro-modules';
2
+ import type { NitroModalMethods, NitroModalProps } from './NitroModal.nitro.js';
3
+ export declare const NitroModalView: ReactNativeView<NitroModalProps, NitroModalMethods>;
4
+ //# sourceMappingURL=NitroModalView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NitroModalView.d.ts","sourceRoot":"","sources":["../../../src/NitroModalView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,uBAAoB,CAAC;AAkB7E,eAAO,MAAM,cAAc,EACe,eAAe,CACrD,eAAe,EACf,iBAAiB,CAClB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { NitroModalMethods, NitroModalProps } from './NitroModal.nitro.js';
2
+ export declare const NitroModalView: import("react-native-nitro-modules").ReactNativeView<NitroModalProps, NitroModalMethods>;
3
+ //# sourceMappingURL=NitroModalView.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NitroModalView.native.d.ts","sourceRoot":"","sources":["../../../src/NitroModalView.native.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,uBAAoB,CAAC;AAE7E,eAAO,MAAM,cAAc,0FAGY,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { NitroModal, type NitroModalProps, type NitroModalRef, } from './NitroModal.js';
2
+ export type { DismissReason, KeyboardBehavior, ModalMode, PopupAnimation, SheetDetent, } from './NitroModal.nitro.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,KAAK,eAAe,EACpB,KAAK,aAAa,GACnB,MAAM,iBAAc,CAAC;AACtB,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,SAAS,EACT,cAAc,EACd,WAAW,GACZ,MAAM,uBAAoB,CAAC"}
package/nitro.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "cxxNamespace": ["nitromodal"],
3
+ "ios": {
4
+ "iosModuleName": "NitroModal"
5
+ },
6
+ "android": {
7
+ "androidNamespace": ["nitromodal"],
8
+ "androidCxxLibName": "nitromodal"
9
+ },
10
+ "autolinking": {
11
+ "NitroModal": {
12
+ "ios": {
13
+ "language": "swift",
14
+ "implementationClassName": "HybridNitroModal"
15
+ },
16
+ "android": {
17
+ "language": "kotlin",
18
+ "implementationClassName": "HybridNitroModal"
19
+ }
20
+ }
21
+ },
22
+ "ignorePaths": ["node_modules"]
23
+ }
@@ -0,0 +1,64 @@
1
+ ///
2
+ /// JDismissReason.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <fbjni/fbjni.h>
11
+ #include "DismissReason.hpp"
12
+
13
+ namespace margelo::nitro::nitromodal {
14
+
15
+ using namespace facebook;
16
+
17
+ /**
18
+ * The C++ JNI bridge between the C++ enum "DismissReason" and the Kotlin enum "DismissReason".
19
+ */
20
+ struct JDismissReason final: public jni::JavaClass<JDismissReason> {
21
+ public:
22
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitromodal/DismissReason;";
23
+
24
+ public:
25
+ /**
26
+ * Convert this Java/Kotlin-based enum to the C++ enum DismissReason.
27
+ */
28
+ [[maybe_unused]]
29
+ [[nodiscard]]
30
+ DismissReason toCpp() const {
31
+ static const auto clazz = javaClassStatic();
32
+ static const auto fieldOrdinal = clazz->getField<int>("value");
33
+ int ordinal = this->getFieldValue(fieldOrdinal);
34
+ return static_cast<DismissReason>(ordinal);
35
+ }
36
+
37
+ public:
38
+ /**
39
+ * Create a Java/Kotlin-based enum with the given C++ enum's value.
40
+ */
41
+ [[maybe_unused]]
42
+ static jni::alias_ref<JDismissReason> fromCpp(DismissReason value) {
43
+ static const auto clazz = javaClassStatic();
44
+ switch (value) {
45
+ case DismissReason::PROGRAMMATIC:
46
+ static const auto fieldPROGRAMMATIC = clazz->getStaticField<JDismissReason>("PROGRAMMATIC");
47
+ return clazz->getStaticFieldValue(fieldPROGRAMMATIC);
48
+ case DismissReason::SWIPE:
49
+ static const auto fieldSWIPE = clazz->getStaticField<JDismissReason>("SWIPE");
50
+ return clazz->getStaticFieldValue(fieldSWIPE);
51
+ case DismissReason::BACKDROP:
52
+ static const auto fieldBACKDROP = clazz->getStaticField<JDismissReason>("BACKDROP");
53
+ return clazz->getStaticFieldValue(fieldBACKDROP);
54
+ case DismissReason::BACKBUTTON:
55
+ static const auto fieldBACKBUTTON = clazz->getStaticField<JDismissReason>("BACKBUTTON");
56
+ return clazz->getStaticFieldValue(fieldBACKBUTTON);
57
+ default:
58
+ std::string stringValue = std::to_string(static_cast<int>(value));
59
+ throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
60
+ }
61
+ }
62
+ };
63
+
64
+ } // namespace margelo::nitro::nitromodal
@@ -0,0 +1,75 @@
1
+ ///
2
+ /// JFunc_void.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <fbjni/fbjni.h>
11
+ #include <functional>
12
+
13
+ #include <functional>
14
+ #include <NitroModules/JNICallable.hpp>
15
+
16
+ namespace margelo::nitro::nitromodal {
17
+
18
+ using namespace facebook;
19
+
20
+ /**
21
+ * Represents the Java/Kotlin callback `() -> Unit`.
22
+ * This can be passed around between C++ and Java/Kotlin.
23
+ */
24
+ struct JFunc_void: public jni::JavaClass<JFunc_void> {
25
+ public:
26
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitromodal/Func_void;";
27
+
28
+ public:
29
+ /**
30
+ * Invokes the function this `JFunc_void` instance holds through JNI.
31
+ */
32
+ void invoke() const {
33
+ static const auto method = javaClassStatic()->getMethod<void()>("invoke");
34
+ method(self());
35
+ }
36
+ };
37
+
38
+ /**
39
+ * An implementation of Func_void that is backed by a C++ implementation (using `std::function<...>`)
40
+ */
41
+ class JFunc_void_cxx final: public jni::HybridClass<JFunc_void_cxx, JFunc_void> {
42
+ public:
43
+ static jni::local_ref<JFunc_void::javaobject> fromCpp(const std::function<void()>& func) {
44
+ return JFunc_void_cxx::newObjectCxxArgs(func);
45
+ }
46
+
47
+ public:
48
+ /**
49
+ * Invokes the C++ `std::function<...>` this `JFunc_void_cxx` instance holds.
50
+ */
51
+ void invoke_cxx() {
52
+ _func();
53
+ }
54
+
55
+ public:
56
+ [[nodiscard]]
57
+ inline const std::function<void()>& getFunction() const {
58
+ return _func;
59
+ }
60
+
61
+ public:
62
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitromodal/Func_void_cxx;";
63
+ static void registerNatives() {
64
+ registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_cxx::invoke_cxx)});
65
+ }
66
+
67
+ private:
68
+ explicit JFunc_void_cxx(const std::function<void()>& func): _func(func) { }
69
+
70
+ private:
71
+ friend HybridBase;
72
+ std::function<void()> _func;
73
+ };
74
+
75
+ } // namespace margelo::nitro::nitromodal
@@ -0,0 +1,77 @@
1
+ ///
2
+ /// JFunc_void_DismissReason.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <fbjni/fbjni.h>
11
+ #include <functional>
12
+
13
+ #include "DismissReason.hpp"
14
+ #include <functional>
15
+ #include <NitroModules/JNICallable.hpp>
16
+ #include "JDismissReason.hpp"
17
+
18
+ namespace margelo::nitro::nitromodal {
19
+
20
+ using namespace facebook;
21
+
22
+ /**
23
+ * Represents the Java/Kotlin callback `(reason: DismissReason) -> Unit`.
24
+ * This can be passed around between C++ and Java/Kotlin.
25
+ */
26
+ struct JFunc_void_DismissReason: public jni::JavaClass<JFunc_void_DismissReason> {
27
+ public:
28
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitromodal/Func_void_DismissReason;";
29
+
30
+ public:
31
+ /**
32
+ * Invokes the function this `JFunc_void_DismissReason` instance holds through JNI.
33
+ */
34
+ void invoke(DismissReason reason) const {
35
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JDismissReason> /* reason */)>("invoke");
36
+ method(self(), JDismissReason::fromCpp(reason));
37
+ }
38
+ };
39
+
40
+ /**
41
+ * An implementation of Func_void_DismissReason that is backed by a C++ implementation (using `std::function<...>`)
42
+ */
43
+ class JFunc_void_DismissReason_cxx final: public jni::HybridClass<JFunc_void_DismissReason_cxx, JFunc_void_DismissReason> {
44
+ public:
45
+ static jni::local_ref<JFunc_void_DismissReason::javaobject> fromCpp(const std::function<void(DismissReason /* reason */)>& func) {
46
+ return JFunc_void_DismissReason_cxx::newObjectCxxArgs(func);
47
+ }
48
+
49
+ public:
50
+ /**
51
+ * Invokes the C++ `std::function<...>` this `JFunc_void_DismissReason_cxx` instance holds.
52
+ */
53
+ void invoke_cxx(jni::alias_ref<JDismissReason> reason) {
54
+ _func(reason->toCpp());
55
+ }
56
+
57
+ public:
58
+ [[nodiscard]]
59
+ inline const std::function<void(DismissReason /* reason */)>& getFunction() const {
60
+ return _func;
61
+ }
62
+
63
+ public:
64
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitromodal/Func_void_DismissReason_cxx;";
65
+ static void registerNatives() {
66
+ registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_DismissReason_cxx::invoke_cxx)});
67
+ }
68
+
69
+ private:
70
+ explicit JFunc_void_DismissReason_cxx(const std::function<void(DismissReason /* reason */)>& func): _func(func) { }
71
+
72
+ private:
73
+ friend HybridBase;
74
+ std::function<void(DismissReason /* reason */)> _func;
75
+ };
76
+
77
+ } // namespace margelo::nitro::nitromodal
@@ -0,0 +1,77 @@
1
+ ///
2
+ /// JFunc_void_ModalContentArea.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <fbjni/fbjni.h>
11
+ #include <functional>
12
+
13
+ #include "ModalContentArea.hpp"
14
+ #include <functional>
15
+ #include <NitroModules/JNICallable.hpp>
16
+ #include "JModalContentArea.hpp"
17
+
18
+ namespace margelo::nitro::nitromodal {
19
+
20
+ using namespace facebook;
21
+
22
+ /**
23
+ * Represents the Java/Kotlin callback `(area: ModalContentArea) -> Unit`.
24
+ * This can be passed around between C++ and Java/Kotlin.
25
+ */
26
+ struct JFunc_void_ModalContentArea: public jni::JavaClass<JFunc_void_ModalContentArea> {
27
+ public:
28
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitromodal/Func_void_ModalContentArea;";
29
+
30
+ public:
31
+ /**
32
+ * Invokes the function this `JFunc_void_ModalContentArea` instance holds through JNI.
33
+ */
34
+ void invoke(const ModalContentArea& area) const {
35
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JModalContentArea> /* area */)>("invoke");
36
+ method(self(), JModalContentArea::fromCpp(area));
37
+ }
38
+ };
39
+
40
+ /**
41
+ * An implementation of Func_void_ModalContentArea that is backed by a C++ implementation (using `std::function<...>`)
42
+ */
43
+ class JFunc_void_ModalContentArea_cxx final: public jni::HybridClass<JFunc_void_ModalContentArea_cxx, JFunc_void_ModalContentArea> {
44
+ public:
45
+ static jni::local_ref<JFunc_void_ModalContentArea::javaobject> fromCpp(const std::function<void(const ModalContentArea& /* area */)>& func) {
46
+ return JFunc_void_ModalContentArea_cxx::newObjectCxxArgs(func);
47
+ }
48
+
49
+ public:
50
+ /**
51
+ * Invokes the C++ `std::function<...>` this `JFunc_void_ModalContentArea_cxx` instance holds.
52
+ */
53
+ void invoke_cxx(jni::alias_ref<JModalContentArea> area) {
54
+ _func(area->toCpp());
55
+ }
56
+
57
+ public:
58
+ [[nodiscard]]
59
+ inline const std::function<void(const ModalContentArea& /* area */)>& getFunction() const {
60
+ return _func;
61
+ }
62
+
63
+ public:
64
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitromodal/Func_void_ModalContentArea_cxx;";
65
+ static void registerNatives() {
66
+ registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_ModalContentArea_cxx::invoke_cxx)});
67
+ }
68
+
69
+ private:
70
+ explicit JFunc_void_ModalContentArea_cxx(const std::function<void(const ModalContentArea& /* area */)>& func): _func(func) { }
71
+
72
+ private:
73
+ friend HybridBase;
74
+ std::function<void(const ModalContentArea& /* area */)> _func;
75
+ };
76
+
77
+ } // namespace margelo::nitro::nitromodal
@@ -0,0 +1,75 @@
1
+ ///
2
+ /// JFunc_void_double.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <fbjni/fbjni.h>
11
+ #include <functional>
12
+
13
+ #include <functional>
14
+ #include <NitroModules/JNICallable.hpp>
15
+
16
+ namespace margelo::nitro::nitromodal {
17
+
18
+ using namespace facebook;
19
+
20
+ /**
21
+ * Represents the Java/Kotlin callback `(index: Double) -> Unit`.
22
+ * This can be passed around between C++ and Java/Kotlin.
23
+ */
24
+ struct JFunc_void_double: public jni::JavaClass<JFunc_void_double> {
25
+ public:
26
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitromodal/Func_void_double;";
27
+
28
+ public:
29
+ /**
30
+ * Invokes the function this `JFunc_void_double` instance holds through JNI.
31
+ */
32
+ void invoke(double index) const {
33
+ static const auto method = javaClassStatic()->getMethod<void(double /* index */)>("invoke");
34
+ method(self(), index);
35
+ }
36
+ };
37
+
38
+ /**
39
+ * An implementation of Func_void_double that is backed by a C++ implementation (using `std::function<...>`)
40
+ */
41
+ class JFunc_void_double_cxx final: public jni::HybridClass<JFunc_void_double_cxx, JFunc_void_double> {
42
+ public:
43
+ static jni::local_ref<JFunc_void_double::javaobject> fromCpp(const std::function<void(double /* index */)>& func) {
44
+ return JFunc_void_double_cxx::newObjectCxxArgs(func);
45
+ }
46
+
47
+ public:
48
+ /**
49
+ * Invokes the C++ `std::function<...>` this `JFunc_void_double_cxx` instance holds.
50
+ */
51
+ void invoke_cxx(double index) {
52
+ _func(index);
53
+ }
54
+
55
+ public:
56
+ [[nodiscard]]
57
+ inline const std::function<void(double /* index */)>& getFunction() const {
58
+ return _func;
59
+ }
60
+
61
+ public:
62
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitromodal/Func_void_double_cxx;";
63
+ static void registerNatives() {
64
+ registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_double_cxx::invoke_cxx)});
65
+ }
66
+
67
+ private:
68
+ explicit JFunc_void_double_cxx(const std::function<void(double /* index */)>& func): _func(func) { }
69
+
70
+ private:
71
+ friend HybridBase;
72
+ std::function<void(double /* index */)> _func;
73
+ };
74
+
75
+ } // namespace margelo::nitro::nitromodal