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,48 @@
1
+ ///
2
+ /// SheetDetent.swift
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
+ /**
9
+ * Represents the JS union `SheetDetent`, backed by a C++ enum.
10
+ */
11
+ public typealias SheetDetent = margelo.nitro.nitromodal.SheetDetent
12
+
13
+ public extension SheetDetent {
14
+ /**
15
+ * Get a SheetDetent for the given String value, or
16
+ * return `nil` if the given value was invalid/unknown.
17
+ */
18
+ init?(fromString string: String) {
19
+ switch string {
20
+ case "small":
21
+ self = .small
22
+ case "medium":
23
+ self = .medium
24
+ case "large":
25
+ self = .large
26
+ case "fitContent":
27
+ self = .fitcontent
28
+ default:
29
+ return nil
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Get the String value this SheetDetent represents.
35
+ */
36
+ var stringValue: String {
37
+ switch self {
38
+ case .small:
39
+ return "small"
40
+ case .medium:
41
+ return "medium"
42
+ case .large:
43
+ return "large"
44
+ case .fitcontent:
45
+ return "fitContent"
46
+ }
47
+ }
48
+ }
@@ -0,0 +1,84 @@
1
+ ///
2
+ /// 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
+ #if __has_include(<NitroModules/NitroHash.hpp>)
11
+ #include <NitroModules/NitroHash.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
16
+ #include <NitroModules/JSIConverter.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
21
+ #include <NitroModules/NitroDefines.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+ namespace margelo::nitro::nitromodal {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (DismissReason).
30
+ */
31
+ enum class DismissReason {
32
+ PROGRAMMATIC SWIFT_NAME(programmatic) = 0,
33
+ SWIPE SWIFT_NAME(swipe) = 1,
34
+ BACKDROP SWIFT_NAME(backdrop) = 2,
35
+ BACKBUTTON SWIFT_NAME(backbutton) = 3,
36
+ } CLOSED_ENUM;
37
+
38
+ } // namespace margelo::nitro::nitromodal
39
+
40
+ namespace margelo::nitro {
41
+
42
+ // C++ DismissReason <> JS DismissReason (union)
43
+ template <>
44
+ struct JSIConverter<margelo::nitro::nitromodal::DismissReason> final {
45
+ static inline margelo::nitro::nitromodal::DismissReason fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
46
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
47
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
48
+ case hashString("programmatic"): return margelo::nitro::nitromodal::DismissReason::PROGRAMMATIC;
49
+ case hashString("swipe"): return margelo::nitro::nitromodal::DismissReason::SWIPE;
50
+ case hashString("backdrop"): return margelo::nitro::nitromodal::DismissReason::BACKDROP;
51
+ case hashString("backButton"): return margelo::nitro::nitromodal::DismissReason::BACKBUTTON;
52
+ default: [[unlikely]]
53
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum DismissReason - invalid value!");
54
+ }
55
+ }
56
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::nitromodal::DismissReason arg) {
57
+ switch (arg) {
58
+ case margelo::nitro::nitromodal::DismissReason::PROGRAMMATIC: return JSIConverter<std::string>::toJSI(runtime, "programmatic");
59
+ case margelo::nitro::nitromodal::DismissReason::SWIPE: return JSIConverter<std::string>::toJSI(runtime, "swipe");
60
+ case margelo::nitro::nitromodal::DismissReason::BACKDROP: return JSIConverter<std::string>::toJSI(runtime, "backdrop");
61
+ case margelo::nitro::nitromodal::DismissReason::BACKBUTTON: return JSIConverter<std::string>::toJSI(runtime, "backButton");
62
+ default: [[unlikely]]
63
+ throw std::invalid_argument("Cannot convert DismissReason to JS - invalid value: "
64
+ + std::to_string(static_cast<int>(arg)) + "!");
65
+ }
66
+ }
67
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
68
+ if (!value.isString()) {
69
+ return false;
70
+ }
71
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
72
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
73
+ case hashString("programmatic"):
74
+ case hashString("swipe"):
75
+ case hashString("backdrop"):
76
+ case hashString("backButton"):
77
+ return true;
78
+ default:
79
+ return false;
80
+ }
81
+ }
82
+ };
83
+
84
+ } // namespace margelo::nitro
@@ -0,0 +1,65 @@
1
+ ///
2
+ /// HybridNitroModalSpec.cpp
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
+ #include "HybridNitroModalSpec.hpp"
9
+
10
+ namespace margelo::nitro::nitromodal {
11
+
12
+ void HybridNitroModalSpec::loadHybridMethods() {
13
+ // load base methods/properties
14
+ HybridObject::loadHybridMethods();
15
+ // load custom methods/properties
16
+ registerHybrids(this, [](Prototype& prototype) {
17
+ prototype.registerHybridGetter("isOpen", &HybridNitroModalSpec::getIsOpen);
18
+ prototype.registerHybridSetter("isOpen", &HybridNitroModalSpec::setIsOpen);
19
+ prototype.registerHybridGetter("mode", &HybridNitroModalSpec::getMode);
20
+ prototype.registerHybridSetter("mode", &HybridNitroModalSpec::setMode);
21
+ prototype.registerHybridGetter("detents", &HybridNitroModalSpec::getDetents);
22
+ prototype.registerHybridSetter("detents", &HybridNitroModalSpec::setDetents);
23
+ prototype.registerHybridGetter("initialDetentIndex", &HybridNitroModalSpec::getInitialDetentIndex);
24
+ prototype.registerHybridSetter("initialDetentIndex", &HybridNitroModalSpec::setInitialDetentIndex);
25
+ prototype.registerHybridGetter("backdropColor", &HybridNitroModalSpec::getBackdropColor);
26
+ prototype.registerHybridSetter("backdropColor", &HybridNitroModalSpec::setBackdropColor);
27
+ prototype.registerHybridGetter("backdropOpacity", &HybridNitroModalSpec::getBackdropOpacity);
28
+ prototype.registerHybridSetter("backdropOpacity", &HybridNitroModalSpec::setBackdropOpacity);
29
+ prototype.registerHybridGetter("backdropBlurRadius", &HybridNitroModalSpec::getBackdropBlurRadius);
30
+ prototype.registerHybridSetter("backdropBlurRadius", &HybridNitroModalSpec::setBackdropBlurRadius);
31
+ prototype.registerHybridGetter("dismissOnBackdropPress", &HybridNitroModalSpec::getDismissOnBackdropPress);
32
+ prototype.registerHybridSetter("dismissOnBackdropPress", &HybridNitroModalSpec::setDismissOnBackdropPress);
33
+ prototype.registerHybridGetter("dismissOnSwipe", &HybridNitroModalSpec::getDismissOnSwipe);
34
+ prototype.registerHybridSetter("dismissOnSwipe", &HybridNitroModalSpec::setDismissOnSwipe);
35
+ prototype.registerHybridGetter("dismissOnBackButton", &HybridNitroModalSpec::getDismissOnBackButton);
36
+ prototype.registerHybridSetter("dismissOnBackButton", &HybridNitroModalSpec::setDismissOnBackButton);
37
+ prototype.registerHybridGetter("grabberVisible", &HybridNitroModalSpec::getGrabberVisible);
38
+ prototype.registerHybridSetter("grabberVisible", &HybridNitroModalSpec::setGrabberVisible);
39
+ prototype.registerHybridGetter("cornerRadius", &HybridNitroModalSpec::getCornerRadius);
40
+ prototype.registerHybridSetter("cornerRadius", &HybridNitroModalSpec::setCornerRadius);
41
+ prototype.registerHybridGetter("contentBackgroundColor", &HybridNitroModalSpec::getContentBackgroundColor);
42
+ prototype.registerHybridSetter("contentBackgroundColor", &HybridNitroModalSpec::setContentBackgroundColor);
43
+ prototype.registerHybridGetter("keyboardBehavior", &HybridNitroModalSpec::getKeyboardBehavior);
44
+ prototype.registerHybridSetter("keyboardBehavior", &HybridNitroModalSpec::setKeyboardBehavior);
45
+ prototype.registerHybridGetter("popupAnimation", &HybridNitroModalSpec::getPopupAnimation);
46
+ prototype.registerHybridSetter("popupAnimation", &HybridNitroModalSpec::setPopupAnimation);
47
+ prototype.registerHybridGetter("onPresent", &HybridNitroModalSpec::getOnPresent);
48
+ prototype.registerHybridSetter("onPresent", &HybridNitroModalSpec::setOnPresent);
49
+ prototype.registerHybridGetter("onDismiss", &HybridNitroModalSpec::getOnDismiss);
50
+ prototype.registerHybridSetter("onDismiss", &HybridNitroModalSpec::setOnDismiss);
51
+ prototype.registerHybridGetter("onDetentChange", &HybridNitroModalSpec::getOnDetentChange);
52
+ prototype.registerHybridSetter("onDetentChange", &HybridNitroModalSpec::setOnDetentChange);
53
+ prototype.registerHybridGetter("onBackdropPress", &HybridNitroModalSpec::getOnBackdropPress);
54
+ prototype.registerHybridSetter("onBackdropPress", &HybridNitroModalSpec::setOnBackdropPress);
55
+ prototype.registerHybridGetter("onBackButtonPress", &HybridNitroModalSpec::getOnBackButtonPress);
56
+ prototype.registerHybridSetter("onBackButtonPress", &HybridNitroModalSpec::setOnBackButtonPress);
57
+ prototype.registerHybridGetter("onContentAreaChange", &HybridNitroModalSpec::getOnContentAreaChange);
58
+ prototype.registerHybridSetter("onContentAreaChange", &HybridNitroModalSpec::setOnContentAreaChange);
59
+ prototype.registerHybridMethod("present", &HybridNitroModalSpec::present);
60
+ prototype.registerHybridMethod("dismiss", &HybridNitroModalSpec::dismiss);
61
+ prototype.registerHybridMethod("snapToDetent", &HybridNitroModalSpec::snapToDetent);
62
+ });
63
+ }
64
+
65
+ } // namespace margelo::nitro::nitromodal
@@ -0,0 +1,124 @@
1
+ ///
2
+ /// HybridNitroModalSpec.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
+ #if __has_include(<NitroModules/HybridObject.hpp>)
11
+ #include <NitroModules/HybridObject.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+
16
+ // Forward declaration of `ModalMode` to properly resolve imports.
17
+ namespace margelo::nitro::nitromodal { enum class ModalMode; }
18
+ // Forward declaration of `SheetDetent` to properly resolve imports.
19
+ namespace margelo::nitro::nitromodal { enum class SheetDetent; }
20
+ // Forward declaration of `KeyboardBehavior` to properly resolve imports.
21
+ namespace margelo::nitro::nitromodal { enum class KeyboardBehavior; }
22
+ // Forward declaration of `PopupAnimation` to properly resolve imports.
23
+ namespace margelo::nitro::nitromodal { enum class PopupAnimation; }
24
+ // Forward declaration of `DismissReason` to properly resolve imports.
25
+ namespace margelo::nitro::nitromodal { enum class DismissReason; }
26
+ // Forward declaration of `ModalContentArea` to properly resolve imports.
27
+ namespace margelo::nitro::nitromodal { struct ModalContentArea; }
28
+
29
+ #include "ModalMode.hpp"
30
+ #include "SheetDetent.hpp"
31
+ #include <vector>
32
+ #include <optional>
33
+ #include "KeyboardBehavior.hpp"
34
+ #include "PopupAnimation.hpp"
35
+ #include <functional>
36
+ #include "DismissReason.hpp"
37
+ #include "ModalContentArea.hpp"
38
+
39
+ namespace margelo::nitro::nitromodal {
40
+
41
+ using namespace margelo::nitro;
42
+
43
+ /**
44
+ * An abstract base class for `NitroModal`
45
+ * Inherit this class to create instances of `HybridNitroModalSpec` in C++.
46
+ * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
47
+ * @example
48
+ * ```cpp
49
+ * class HybridNitroModal: public HybridNitroModalSpec {
50
+ * public:
51
+ * HybridNitroModal(...): HybridObject(TAG) { ... }
52
+ * // ...
53
+ * };
54
+ * ```
55
+ */
56
+ class HybridNitroModalSpec: public virtual HybridObject {
57
+ public:
58
+ // Constructor
59
+ explicit HybridNitroModalSpec(): HybridObject(TAG) { }
60
+
61
+ // Destructor
62
+ ~HybridNitroModalSpec() override = default;
63
+
64
+ public:
65
+ // Properties
66
+ virtual bool getIsOpen() = 0;
67
+ virtual void setIsOpen(bool isOpen) = 0;
68
+ virtual ModalMode getMode() = 0;
69
+ virtual void setMode(ModalMode mode) = 0;
70
+ virtual std::vector<SheetDetent> getDetents() = 0;
71
+ virtual void setDetents(const std::vector<SheetDetent>& detents) = 0;
72
+ virtual double getInitialDetentIndex() = 0;
73
+ virtual void setInitialDetentIndex(double initialDetentIndex) = 0;
74
+ virtual double getBackdropColor() = 0;
75
+ virtual void setBackdropColor(double backdropColor) = 0;
76
+ virtual double getBackdropOpacity() = 0;
77
+ virtual void setBackdropOpacity(double backdropOpacity) = 0;
78
+ virtual double getBackdropBlurRadius() = 0;
79
+ virtual void setBackdropBlurRadius(double backdropBlurRadius) = 0;
80
+ virtual bool getDismissOnBackdropPress() = 0;
81
+ virtual void setDismissOnBackdropPress(bool dismissOnBackdropPress) = 0;
82
+ virtual bool getDismissOnSwipe() = 0;
83
+ virtual void setDismissOnSwipe(bool dismissOnSwipe) = 0;
84
+ virtual bool getDismissOnBackButton() = 0;
85
+ virtual void setDismissOnBackButton(bool dismissOnBackButton) = 0;
86
+ virtual bool getGrabberVisible() = 0;
87
+ virtual void setGrabberVisible(bool grabberVisible) = 0;
88
+ virtual double getCornerRadius() = 0;
89
+ virtual void setCornerRadius(double cornerRadius) = 0;
90
+ virtual std::optional<double> getContentBackgroundColor() = 0;
91
+ virtual void setContentBackgroundColor(std::optional<double> contentBackgroundColor) = 0;
92
+ virtual KeyboardBehavior getKeyboardBehavior() = 0;
93
+ virtual void setKeyboardBehavior(KeyboardBehavior keyboardBehavior) = 0;
94
+ virtual PopupAnimation getPopupAnimation() = 0;
95
+ virtual void setPopupAnimation(PopupAnimation popupAnimation) = 0;
96
+ virtual std::optional<std::function<void()>> getOnPresent() = 0;
97
+ virtual void setOnPresent(const std::optional<std::function<void()>>& onPresent) = 0;
98
+ virtual std::optional<std::function<void(DismissReason /* reason */)>> getOnDismiss() = 0;
99
+ virtual void setOnDismiss(const std::optional<std::function<void(DismissReason /* reason */)>>& onDismiss) = 0;
100
+ virtual std::optional<std::function<void(double /* index */)>> getOnDetentChange() = 0;
101
+ virtual void setOnDetentChange(const std::optional<std::function<void(double /* index */)>>& onDetentChange) = 0;
102
+ virtual std::optional<std::function<void()>> getOnBackdropPress() = 0;
103
+ virtual void setOnBackdropPress(const std::optional<std::function<void()>>& onBackdropPress) = 0;
104
+ virtual std::optional<std::function<void()>> getOnBackButtonPress() = 0;
105
+ virtual void setOnBackButtonPress(const std::optional<std::function<void()>>& onBackButtonPress) = 0;
106
+ virtual std::optional<std::function<void(const ModalContentArea& /* area */)>> getOnContentAreaChange() = 0;
107
+ virtual void setOnContentAreaChange(const std::optional<std::function<void(const ModalContentArea& /* area */)>>& onContentAreaChange) = 0;
108
+
109
+ public:
110
+ // Methods
111
+ virtual void present() = 0;
112
+ virtual void dismiss() = 0;
113
+ virtual void snapToDetent(double index) = 0;
114
+
115
+ protected:
116
+ // Hybrid Setup
117
+ void loadHybridMethods() override;
118
+
119
+ protected:
120
+ // Tag for logging
121
+ static constexpr auto TAG = "NitroModal";
122
+ };
123
+
124
+ } // namespace margelo::nitro::nitromodal
@@ -0,0 +1,80 @@
1
+ ///
2
+ /// KeyboardBehavior.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
+ #if __has_include(<NitroModules/NitroHash.hpp>)
11
+ #include <NitroModules/NitroHash.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
16
+ #include <NitroModules/JSIConverter.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
21
+ #include <NitroModules/NitroDefines.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+ namespace margelo::nitro::nitromodal {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (KeyboardBehavior).
30
+ */
31
+ enum class KeyboardBehavior {
32
+ PAN SWIFT_NAME(pan) = 0,
33
+ RESIZE SWIFT_NAME(resize) = 1,
34
+ NONE SWIFT_NAME(none) = 2,
35
+ } CLOSED_ENUM;
36
+
37
+ } // namespace margelo::nitro::nitromodal
38
+
39
+ namespace margelo::nitro {
40
+
41
+ // C++ KeyboardBehavior <> JS KeyboardBehavior (union)
42
+ template <>
43
+ struct JSIConverter<margelo::nitro::nitromodal::KeyboardBehavior> final {
44
+ static inline margelo::nitro::nitromodal::KeyboardBehavior fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
45
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
46
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
47
+ case hashString("pan"): return margelo::nitro::nitromodal::KeyboardBehavior::PAN;
48
+ case hashString("resize"): return margelo::nitro::nitromodal::KeyboardBehavior::RESIZE;
49
+ case hashString("none"): return margelo::nitro::nitromodal::KeyboardBehavior::NONE;
50
+ default: [[unlikely]]
51
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum KeyboardBehavior - invalid value!");
52
+ }
53
+ }
54
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::nitromodal::KeyboardBehavior arg) {
55
+ switch (arg) {
56
+ case margelo::nitro::nitromodal::KeyboardBehavior::PAN: return JSIConverter<std::string>::toJSI(runtime, "pan");
57
+ case margelo::nitro::nitromodal::KeyboardBehavior::RESIZE: return JSIConverter<std::string>::toJSI(runtime, "resize");
58
+ case margelo::nitro::nitromodal::KeyboardBehavior::NONE: return JSIConverter<std::string>::toJSI(runtime, "none");
59
+ default: [[unlikely]]
60
+ throw std::invalid_argument("Cannot convert KeyboardBehavior to JS - invalid value: "
61
+ + std::to_string(static_cast<int>(arg)) + "!");
62
+ }
63
+ }
64
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
65
+ if (!value.isString()) {
66
+ return false;
67
+ }
68
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
69
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
70
+ case hashString("pan"):
71
+ case hashString("resize"):
72
+ case hashString("none"):
73
+ return true;
74
+ default:
75
+ return false;
76
+ }
77
+ }
78
+ };
79
+
80
+ } // namespace margelo::nitro
@@ -0,0 +1,87 @@
1
+ ///
2
+ /// 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
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+
32
+
33
+
34
+
35
+ namespace margelo::nitro::nitromodal {
36
+
37
+ /**
38
+ * A struct which can be represented as a JavaScript object (ModalContentArea).
39
+ */
40
+ struct ModalContentArea final {
41
+ public:
42
+ double width SWIFT_PRIVATE;
43
+ double height SWIFT_PRIVATE;
44
+
45
+ public:
46
+ ModalContentArea() = default;
47
+ explicit ModalContentArea(double width, double height): width(width), height(height) {}
48
+
49
+ public:
50
+ friend bool operator==(const ModalContentArea& lhs, const ModalContentArea& rhs) = default;
51
+ };
52
+
53
+ } // namespace margelo::nitro::nitromodal
54
+
55
+ namespace margelo::nitro {
56
+
57
+ // C++ ModalContentArea <> JS ModalContentArea (object)
58
+ template <>
59
+ struct JSIConverter<margelo::nitro::nitromodal::ModalContentArea> final {
60
+ static inline margelo::nitro::nitromodal::ModalContentArea fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
61
+ jsi::Object obj = arg.asObject(runtime);
62
+ return margelo::nitro::nitromodal::ModalContentArea(
63
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "width"))),
64
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "height")))
65
+ );
66
+ }
67
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitromodal::ModalContentArea& arg) {
68
+ jsi::Object obj(runtime);
69
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "width"), JSIConverter<double>::toJSI(runtime, arg.width));
70
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "height"), JSIConverter<double>::toJSI(runtime, arg.height));
71
+ return obj;
72
+ }
73
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
74
+ if (!value.isObject()) {
75
+ return false;
76
+ }
77
+ jsi::Object obj = value.getObject(runtime);
78
+ if (!nitro::isPlainObject(runtime, obj)) {
79
+ return false;
80
+ }
81
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "width")))) return false;
82
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "height")))) return false;
83
+ return true;
84
+ }
85
+ };
86
+
87
+ } // namespace margelo::nitro
@@ -0,0 +1,76 @@
1
+ ///
2
+ /// ModalMode.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
+ #if __has_include(<NitroModules/NitroHash.hpp>)
11
+ #include <NitroModules/NitroHash.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
16
+ #include <NitroModules/JSIConverter.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
21
+ #include <NitroModules/NitroDefines.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+ namespace margelo::nitro::nitromodal {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (ModalMode).
30
+ */
31
+ enum class ModalMode {
32
+ BOTTOMSHEET SWIFT_NAME(bottomsheet) = 0,
33
+ POPUP SWIFT_NAME(popup) = 1,
34
+ } CLOSED_ENUM;
35
+
36
+ } // namespace margelo::nitro::nitromodal
37
+
38
+ namespace margelo::nitro {
39
+
40
+ // C++ ModalMode <> JS ModalMode (union)
41
+ template <>
42
+ struct JSIConverter<margelo::nitro::nitromodal::ModalMode> final {
43
+ static inline margelo::nitro::nitromodal::ModalMode fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
44
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
45
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
46
+ case hashString("bottomSheet"): return margelo::nitro::nitromodal::ModalMode::BOTTOMSHEET;
47
+ case hashString("popup"): return margelo::nitro::nitromodal::ModalMode::POPUP;
48
+ default: [[unlikely]]
49
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum ModalMode - invalid value!");
50
+ }
51
+ }
52
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::nitromodal::ModalMode arg) {
53
+ switch (arg) {
54
+ case margelo::nitro::nitromodal::ModalMode::BOTTOMSHEET: return JSIConverter<std::string>::toJSI(runtime, "bottomSheet");
55
+ case margelo::nitro::nitromodal::ModalMode::POPUP: return JSIConverter<std::string>::toJSI(runtime, "popup");
56
+ default: [[unlikely]]
57
+ throw std::invalid_argument("Cannot convert ModalMode to JS - invalid value: "
58
+ + std::to_string(static_cast<int>(arg)) + "!");
59
+ }
60
+ }
61
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
62
+ if (!value.isString()) {
63
+ return false;
64
+ }
65
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
66
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
67
+ case hashString("bottomSheet"):
68
+ case hashString("popup"):
69
+ return true;
70
+ default:
71
+ return false;
72
+ }
73
+ }
74
+ };
75
+
76
+ } // namespace margelo::nitro
@@ -0,0 +1,80 @@
1
+ ///
2
+ /// PopupAnimation.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
+ #if __has_include(<NitroModules/NitroHash.hpp>)
11
+ #include <NitroModules/NitroHash.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
16
+ #include <NitroModules/JSIConverter.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
21
+ #include <NitroModules/NitroDefines.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+ namespace margelo::nitro::nitromodal {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (PopupAnimation).
30
+ */
31
+ enum class PopupAnimation {
32
+ NONE SWIFT_NAME(none) = 0,
33
+ SCALE SWIFT_NAME(scale) = 1,
34
+ FADE SWIFT_NAME(fade) = 2,
35
+ } CLOSED_ENUM;
36
+
37
+ } // namespace margelo::nitro::nitromodal
38
+
39
+ namespace margelo::nitro {
40
+
41
+ // C++ PopupAnimation <> JS PopupAnimation (union)
42
+ template <>
43
+ struct JSIConverter<margelo::nitro::nitromodal::PopupAnimation> final {
44
+ static inline margelo::nitro::nitromodal::PopupAnimation fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
45
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
46
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
47
+ case hashString("none"): return margelo::nitro::nitromodal::PopupAnimation::NONE;
48
+ case hashString("scale"): return margelo::nitro::nitromodal::PopupAnimation::SCALE;
49
+ case hashString("fade"): return margelo::nitro::nitromodal::PopupAnimation::FADE;
50
+ default: [[unlikely]]
51
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum PopupAnimation - invalid value!");
52
+ }
53
+ }
54
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::nitromodal::PopupAnimation arg) {
55
+ switch (arg) {
56
+ case margelo::nitro::nitromodal::PopupAnimation::NONE: return JSIConverter<std::string>::toJSI(runtime, "none");
57
+ case margelo::nitro::nitromodal::PopupAnimation::SCALE: return JSIConverter<std::string>::toJSI(runtime, "scale");
58
+ case margelo::nitro::nitromodal::PopupAnimation::FADE: return JSIConverter<std::string>::toJSI(runtime, "fade");
59
+ default: [[unlikely]]
60
+ throw std::invalid_argument("Cannot convert PopupAnimation to JS - invalid value: "
61
+ + std::to_string(static_cast<int>(arg)) + "!");
62
+ }
63
+ }
64
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
65
+ if (!value.isString()) {
66
+ return false;
67
+ }
68
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
69
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
70
+ case hashString("none"):
71
+ case hashString("scale"):
72
+ case hashString("fade"):
73
+ return true;
74
+ default:
75
+ return false;
76
+ }
77
+ }
78
+ };
79
+
80
+ } // namespace margelo::nitro