react-native-nitro-simple-toast 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 (60) hide show
  1. package/LICENSE +20 -0
  2. package/NitroSimpleToast.podspec +30 -0
  3. package/README.md +81 -0
  4. package/android/CMakeLists.txt +24 -0
  5. package/android/build.gradle +118 -0
  6. package/android/src/main/AndroidManifest.xml +2 -0
  7. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  8. package/android/src/main/java/com/margelo/nitro/nitrosimpletoast/NitroSimpleToast.kt +66 -0
  9. package/android/src/main/java/com/margelo/nitro/nitrosimpletoast/NitroSimpleToastPackage.kt +26 -0
  10. package/ios/NitroSimpleToast.swift +60 -0
  11. package/lib/module/NitroSimpleToast.nitro.js +4 -0
  12. package/lib/module/NitroSimpleToast.nitro.js.map +1 -0
  13. package/lib/module/index.js +8 -0
  14. package/lib/module/index.js.map +1 -0
  15. package/lib/module/package.json +1 -0
  16. package/lib/typescript/package.json +1 -0
  17. package/lib/typescript/src/NitroSimpleToast.nitro.d.ts +33 -0
  18. package/lib/typescript/src/NitroSimpleToast.nitro.d.ts.map +1 -0
  19. package/lib/typescript/src/index.d.ts +4 -0
  20. package/lib/typescript/src/index.d.ts.map +1 -0
  21. package/nitro.json +23 -0
  22. package/nitrogen/generated/android/c++/JHybridNitroSimpleToastSpec.cpp +68 -0
  23. package/nitrogen/generated/android/c++/JHybridNitroSimpleToastSpec.hpp +63 -0
  24. package/nitrogen/generated/android/c++/JToastFrom.hpp +58 -0
  25. package/nitrogen/generated/android/c++/JToastHaptic.hpp +64 -0
  26. package/nitrogen/generated/android/c++/JToastOptions.hpp +88 -0
  27. package/nitrogen/generated/android/c++/JToastPreset.hpp +61 -0
  28. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosimpletoast/HybridNitroSimpleToastSpec.kt +54 -0
  29. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosimpletoast/ToastFrom.kt +23 -0
  30. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosimpletoast/ToastHaptic.kt +25 -0
  31. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosimpletoast/ToastOptions.kt +56 -0
  32. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosimpletoast/ToastPreset.kt +24 -0
  33. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosimpletoast/nitrosimpletoastOnLoad.kt +35 -0
  34. package/nitrogen/generated/android/nitrosimpletoast+autolinking.cmake +81 -0
  35. package/nitrogen/generated/android/nitrosimpletoast+autolinking.gradle +27 -0
  36. package/nitrogen/generated/android/nitrosimpletoastOnLoad.cpp +54 -0
  37. package/nitrogen/generated/android/nitrosimpletoastOnLoad.hpp +34 -0
  38. package/nitrogen/generated/ios/NitroSimpleToast+autolinking.rb +60 -0
  39. package/nitrogen/generated/ios/NitroSimpleToast-Swift-Cxx-Bridge.cpp +33 -0
  40. package/nitrogen/generated/ios/NitroSimpleToast-Swift-Cxx-Bridge.hpp +152 -0
  41. package/nitrogen/generated/ios/NitroSimpleToast-Swift-Cxx-Umbrella.hpp +57 -0
  42. package/nitrogen/generated/ios/NitroSimpleToastAutolinking.mm +33 -0
  43. package/nitrogen/generated/ios/NitroSimpleToastAutolinking.swift +26 -0
  44. package/nitrogen/generated/ios/c++/HybridNitroSimpleToastSpecSwift.cpp +11 -0
  45. package/nitrogen/generated/ios/c++/HybridNitroSimpleToastSpecSwift.hpp +92 -0
  46. package/nitrogen/generated/ios/swift/HybridNitroSimpleToastSpec.swift +55 -0
  47. package/nitrogen/generated/ios/swift/HybridNitroSimpleToastSpec_cxx.swift +137 -0
  48. package/nitrogen/generated/ios/swift/ToastFrom.swift +40 -0
  49. package/nitrogen/generated/ios/swift/ToastHaptic.swift +48 -0
  50. package/nitrogen/generated/ios/swift/ToastOptions.swift +116 -0
  51. package/nitrogen/generated/ios/swift/ToastPreset.swift +44 -0
  52. package/nitrogen/generated/shared/c++/HybridNitroSimpleToastSpec.cpp +21 -0
  53. package/nitrogen/generated/shared/c++/HybridNitroSimpleToastSpec.hpp +63 -0
  54. package/nitrogen/generated/shared/c++/ToastFrom.hpp +76 -0
  55. package/nitrogen/generated/shared/c++/ToastHaptic.hpp +84 -0
  56. package/nitrogen/generated/shared/c++/ToastOptions.hpp +116 -0
  57. package/nitrogen/generated/shared/c++/ToastPreset.hpp +80 -0
  58. package/package.json +174 -0
  59. package/src/NitroSimpleToast.nitro.ts +35 -0
  60. package/src/index.tsx +16 -0
@@ -0,0 +1,137 @@
1
+ ///
2
+ /// HybridNitroSimpleToastSpec_cxx.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
+ import NitroModules
9
+
10
+ /**
11
+ * A class implementation that bridges HybridNitroSimpleToastSpec over to C++.
12
+ * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
13
+ *
14
+ * Also, some Swift types need to be bridged with special handling:
15
+ * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
16
+ * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
17
+ * - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
18
+ */
19
+ open class HybridNitroSimpleToastSpec_cxx {
20
+ /**
21
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::nitrosimpletoast::bridge::swift`)
22
+ * from `NitroSimpleToast-Swift-Cxx-Bridge.hpp`.
23
+ * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
24
+ */
25
+ public typealias bridge = margelo.nitro.nitrosimpletoast.bridge.swift
26
+
27
+ /**
28
+ * Holds an instance of the `HybridNitroSimpleToastSpec` Swift protocol.
29
+ */
30
+ private var __implementation: any HybridNitroSimpleToastSpec
31
+
32
+ /**
33
+ * Holds a weak pointer to the C++ class that wraps the Swift class.
34
+ */
35
+ private var __cxxPart: bridge.std__weak_ptr_HybridNitroSimpleToastSpec_
36
+
37
+ /**
38
+ * Create a new `HybridNitroSimpleToastSpec_cxx` that wraps the given `HybridNitroSimpleToastSpec`.
39
+ * All properties and methods bridge to C++ types.
40
+ */
41
+ public init(_ implementation: any HybridNitroSimpleToastSpec) {
42
+ self.__implementation = implementation
43
+ self.__cxxPart = .init()
44
+ /* no base class */
45
+ }
46
+
47
+ /**
48
+ * Get the actual `HybridNitroSimpleToastSpec` instance this class wraps.
49
+ */
50
+ @inline(__always)
51
+ public func getHybridNitroSimpleToastSpec() -> any HybridNitroSimpleToastSpec {
52
+ return __implementation
53
+ }
54
+
55
+ /**
56
+ * Casts this instance to a retained unsafe raw pointer.
57
+ * This acquires one additional strong reference on the object!
58
+ */
59
+ public func toUnsafe() -> UnsafeMutableRawPointer {
60
+ return Unmanaged.passRetained(self).toOpaque()
61
+ }
62
+
63
+ /**
64
+ * Casts an unsafe pointer to a `HybridNitroSimpleToastSpec_cxx`.
65
+ * The pointer has to be a retained opaque `Unmanaged<HybridNitroSimpleToastSpec_cxx>`.
66
+ * This removes one strong reference from the object!
67
+ */
68
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridNitroSimpleToastSpec_cxx {
69
+ return Unmanaged<HybridNitroSimpleToastSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
70
+ }
71
+
72
+ /**
73
+ * Gets (or creates) the C++ part of this Hybrid Object.
74
+ * The C++ part is a `std::shared_ptr<HybridNitroSimpleToastSpec>`.
75
+ */
76
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridNitroSimpleToastSpec_ {
77
+ let cachedCxxPart = self.__cxxPart.lock()
78
+ if Bool(fromCxx: cachedCxxPart) {
79
+ return cachedCxxPart
80
+ } else {
81
+ let newCxxPart = bridge.create_std__shared_ptr_HybridNitroSimpleToastSpec_(self.toUnsafe())
82
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridNitroSimpleToastSpec_(newCxxPart)
83
+ return newCxxPart
84
+ }
85
+ }
86
+
87
+
88
+
89
+ /**
90
+ * Get the memory size of the Swift class (plus size of any other allocations)
91
+ * so the JS VM can properly track it and garbage-collect the JS object if needed.
92
+ */
93
+ @inline(__always)
94
+ public var memorySize: Int {
95
+ return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
96
+ }
97
+
98
+ /**
99
+ * Compares this object with the given [other] object for reference equality.
100
+ */
101
+ @inline(__always)
102
+ public func equals(other: HybridNitroSimpleToastSpec_cxx) -> Bool {
103
+ return self.__implementation === other.__implementation
104
+ }
105
+
106
+ /**
107
+ * Call dispose() on the Swift class.
108
+ * This _may_ be called manually from JS.
109
+ */
110
+ @inline(__always)
111
+ public func dispose() {
112
+ self.__implementation.dispose()
113
+ }
114
+
115
+ /**
116
+ * Call toString() on the Swift class.
117
+ */
118
+ @inline(__always)
119
+ public func toString() -> String {
120
+ return self.__implementation.toString()
121
+ }
122
+
123
+ // Properties
124
+
125
+
126
+ // Methods
127
+ @inline(__always)
128
+ public final func show(options: ToastOptions) -> bridge.Result_void_ {
129
+ do {
130
+ try self.__implementation.show(options: options)
131
+ return bridge.create_Result_void_()
132
+ } catch (let __error) {
133
+ let __exceptionPtr = __error.toCpp()
134
+ return bridge.create_Result_void_(__exceptionPtr)
135
+ }
136
+ }
137
+ }
@@ -0,0 +1,40 @@
1
+ ///
2
+ /// ToastFrom.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 `ToastFrom`, backed by a C++ enum.
10
+ */
11
+ public typealias ToastFrom = margelo.nitro.nitrosimpletoast.ToastFrom
12
+
13
+ public extension ToastFrom {
14
+ /**
15
+ * Get a ToastFrom 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 "top":
21
+ self = .top
22
+ case "bottom":
23
+ self = .bottom
24
+ default:
25
+ return nil
26
+ }
27
+ }
28
+
29
+ /**
30
+ * Get the String value this ToastFrom represents.
31
+ */
32
+ var stringValue: String {
33
+ switch self {
34
+ case .top:
35
+ return "top"
36
+ case .bottom:
37
+ return "bottom"
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,48 @@
1
+ ///
2
+ /// ToastHaptic.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 `ToastHaptic`, backed by a C++ enum.
10
+ */
11
+ public typealias ToastHaptic = margelo.nitro.nitrosimpletoast.ToastHaptic
12
+
13
+ public extension ToastHaptic {
14
+ /**
15
+ * Get a ToastHaptic 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 "error":
21
+ self = .error
22
+ case "none":
23
+ self = .none
24
+ case "success":
25
+ self = .success
26
+ case "warning":
27
+ self = .warning
28
+ default:
29
+ return nil
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Get the String value this ToastHaptic represents.
35
+ */
36
+ var stringValue: String {
37
+ switch self {
38
+ case .error:
39
+ return "error"
40
+ case .none:
41
+ return "none"
42
+ case .success:
43
+ return "success"
44
+ case .warning:
45
+ return "warning"
46
+ }
47
+ }
48
+ }
@@ -0,0 +1,116 @@
1
+ ///
2
+ /// ToastOptions.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
+ import NitroModules
9
+
10
+ /**
11
+ * Represents an instance of `ToastOptions`, backed by a C++ struct.
12
+ */
13
+ public typealias ToastOptions = margelo.nitro.nitrosimpletoast.ToastOptions
14
+
15
+ public extension ToastOptions {
16
+ private typealias bridge = margelo.nitro.nitrosimpletoast.bridge.swift
17
+
18
+ /**
19
+ * Create a new instance of `ToastOptions`.
20
+ */
21
+ init(title: String, message: String?, preset: ToastPreset?, duration: Double?, haptic: ToastHaptic?, shouldDismissByDrag: Bool?, from: ToastFrom?) {
22
+ self.init(std.string(title), { () -> bridge.std__optional_std__string_ in
23
+ if let __unwrappedValue = message {
24
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
25
+ } else {
26
+ return .init()
27
+ }
28
+ }(), { () -> bridge.std__optional_ToastPreset_ in
29
+ if let __unwrappedValue = preset {
30
+ return bridge.create_std__optional_ToastPreset_(__unwrappedValue)
31
+ } else {
32
+ return .init()
33
+ }
34
+ }(), { () -> bridge.std__optional_double_ in
35
+ if let __unwrappedValue = duration {
36
+ return bridge.create_std__optional_double_(__unwrappedValue)
37
+ } else {
38
+ return .init()
39
+ }
40
+ }(), { () -> bridge.std__optional_ToastHaptic_ in
41
+ if let __unwrappedValue = haptic {
42
+ return bridge.create_std__optional_ToastHaptic_(__unwrappedValue)
43
+ } else {
44
+ return .init()
45
+ }
46
+ }(), { () -> bridge.std__optional_bool_ in
47
+ if let __unwrappedValue = shouldDismissByDrag {
48
+ return bridge.create_std__optional_bool_(__unwrappedValue)
49
+ } else {
50
+ return .init()
51
+ }
52
+ }(), { () -> bridge.std__optional_ToastFrom_ in
53
+ if let __unwrappedValue = from {
54
+ return bridge.create_std__optional_ToastFrom_(__unwrappedValue)
55
+ } else {
56
+ return .init()
57
+ }
58
+ }())
59
+ }
60
+
61
+ @inline(__always)
62
+ var title: String {
63
+ return String(self.__title)
64
+ }
65
+
66
+ @inline(__always)
67
+ var message: String? {
68
+ return { () -> String? in
69
+ if bridge.has_value_std__optional_std__string_(self.__message) {
70
+ let __unwrapped = bridge.get_std__optional_std__string_(self.__message)
71
+ return String(__unwrapped)
72
+ } else {
73
+ return nil
74
+ }
75
+ }()
76
+ }
77
+
78
+ @inline(__always)
79
+ var preset: ToastPreset? {
80
+ return self.__preset.value
81
+ }
82
+
83
+ @inline(__always)
84
+ var duration: Double? {
85
+ return { () -> Double? in
86
+ if bridge.has_value_std__optional_double_(self.__duration) {
87
+ let __unwrapped = bridge.get_std__optional_double_(self.__duration)
88
+ return __unwrapped
89
+ } else {
90
+ return nil
91
+ }
92
+ }()
93
+ }
94
+
95
+ @inline(__always)
96
+ var haptic: ToastHaptic? {
97
+ return self.__haptic.value
98
+ }
99
+
100
+ @inline(__always)
101
+ var shouldDismissByDrag: Bool? {
102
+ return { () -> Bool? in
103
+ if bridge.has_value_std__optional_bool_(self.__shouldDismissByDrag) {
104
+ let __unwrapped = bridge.get_std__optional_bool_(self.__shouldDismissByDrag)
105
+ return __unwrapped
106
+ } else {
107
+ return nil
108
+ }
109
+ }()
110
+ }
111
+
112
+ @inline(__always)
113
+ var from: ToastFrom? {
114
+ return self.__from.value
115
+ }
116
+ }
@@ -0,0 +1,44 @@
1
+ ///
2
+ /// ToastPreset.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 `ToastPreset`, backed by a C++ enum.
10
+ */
11
+ public typealias ToastPreset = margelo.nitro.nitrosimpletoast.ToastPreset
12
+
13
+ public extension ToastPreset {
14
+ /**
15
+ * Get a ToastPreset 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 "done":
21
+ self = .done
22
+ case "error":
23
+ self = .error
24
+ case "none":
25
+ self = .none
26
+ default:
27
+ return nil
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Get the String value this ToastPreset represents.
33
+ */
34
+ var stringValue: String {
35
+ switch self {
36
+ case .done:
37
+ return "done"
38
+ case .error:
39
+ return "error"
40
+ case .none:
41
+ return "none"
42
+ }
43
+ }
44
+ }
@@ -0,0 +1,21 @@
1
+ ///
2
+ /// HybridNitroSimpleToastSpec.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 "HybridNitroSimpleToastSpec.hpp"
9
+
10
+ namespace margelo::nitro::nitrosimpletoast {
11
+
12
+ void HybridNitroSimpleToastSpec::loadHybridMethods() {
13
+ // load base methods/properties
14
+ HybridObject::loadHybridMethods();
15
+ // load custom methods/properties
16
+ registerHybrids(this, [](Prototype& prototype) {
17
+ prototype.registerHybridMethod("show", &HybridNitroSimpleToastSpec::show);
18
+ });
19
+ }
20
+
21
+ } // namespace margelo::nitro::nitrosimpletoast
@@ -0,0 +1,63 @@
1
+ ///
2
+ /// HybridNitroSimpleToastSpec.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 `ToastOptions` to properly resolve imports.
17
+ namespace margelo::nitro::nitrosimpletoast { struct ToastOptions; }
18
+
19
+ #include "ToastOptions.hpp"
20
+
21
+ namespace margelo::nitro::nitrosimpletoast {
22
+
23
+ using namespace margelo::nitro;
24
+
25
+ /**
26
+ * An abstract base class for `NitroSimpleToast`
27
+ * Inherit this class to create instances of `HybridNitroSimpleToastSpec` in C++.
28
+ * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
29
+ * @example
30
+ * ```cpp
31
+ * class HybridNitroSimpleToast: public HybridNitroSimpleToastSpec {
32
+ * public:
33
+ * HybridNitroSimpleToast(...): HybridObject(TAG) { ... }
34
+ * // ...
35
+ * };
36
+ * ```
37
+ */
38
+ class HybridNitroSimpleToastSpec: public virtual HybridObject {
39
+ public:
40
+ // Constructor
41
+ explicit HybridNitroSimpleToastSpec(): HybridObject(TAG) { }
42
+
43
+ // Destructor
44
+ ~HybridNitroSimpleToastSpec() override = default;
45
+
46
+ public:
47
+ // Properties
48
+
49
+
50
+ public:
51
+ // Methods
52
+ virtual void show(const ToastOptions& options) = 0;
53
+
54
+ protected:
55
+ // Hybrid Setup
56
+ void loadHybridMethods() override;
57
+
58
+ protected:
59
+ // Tag for logging
60
+ static constexpr auto TAG = "NitroSimpleToast";
61
+ };
62
+
63
+ } // namespace margelo::nitro::nitrosimpletoast
@@ -0,0 +1,76 @@
1
+ ///
2
+ /// ToastFrom.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::nitrosimpletoast {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (ToastFrom).
30
+ */
31
+ enum class ToastFrom {
32
+ TOP SWIFT_NAME(top) = 0,
33
+ BOTTOM SWIFT_NAME(bottom) = 1,
34
+ } CLOSED_ENUM;
35
+
36
+ } // namespace margelo::nitro::nitrosimpletoast
37
+
38
+ namespace margelo::nitro {
39
+
40
+ // C++ ToastFrom <> JS ToastFrom (union)
41
+ template <>
42
+ struct JSIConverter<margelo::nitro::nitrosimpletoast::ToastFrom> final {
43
+ static inline margelo::nitro::nitrosimpletoast::ToastFrom 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("top"): return margelo::nitro::nitrosimpletoast::ToastFrom::TOP;
47
+ case hashString("bottom"): return margelo::nitro::nitrosimpletoast::ToastFrom::BOTTOM;
48
+ default: [[unlikely]]
49
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum ToastFrom - invalid value!");
50
+ }
51
+ }
52
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::nitrosimpletoast::ToastFrom arg) {
53
+ switch (arg) {
54
+ case margelo::nitro::nitrosimpletoast::ToastFrom::TOP: return JSIConverter<std::string>::toJSI(runtime, "top");
55
+ case margelo::nitro::nitrosimpletoast::ToastFrom::BOTTOM: return JSIConverter<std::string>::toJSI(runtime, "bottom");
56
+ default: [[unlikely]]
57
+ throw std::invalid_argument("Cannot convert ToastFrom 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("top"):
68
+ case hashString("bottom"):
69
+ return true;
70
+ default:
71
+ return false;
72
+ }
73
+ }
74
+ };
75
+
76
+ } // namespace margelo::nitro
@@ -0,0 +1,84 @@
1
+ ///
2
+ /// ToastHaptic.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::nitrosimpletoast {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (ToastHaptic).
30
+ */
31
+ enum class ToastHaptic {
32
+ ERROR SWIFT_NAME(error) = 0,
33
+ NONE SWIFT_NAME(none) = 1,
34
+ SUCCESS SWIFT_NAME(success) = 2,
35
+ WARNING SWIFT_NAME(warning) = 3,
36
+ } CLOSED_ENUM;
37
+
38
+ } // namespace margelo::nitro::nitrosimpletoast
39
+
40
+ namespace margelo::nitro {
41
+
42
+ // C++ ToastHaptic <> JS ToastHaptic (union)
43
+ template <>
44
+ struct JSIConverter<margelo::nitro::nitrosimpletoast::ToastHaptic> final {
45
+ static inline margelo::nitro::nitrosimpletoast::ToastHaptic 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("error"): return margelo::nitro::nitrosimpletoast::ToastHaptic::ERROR;
49
+ case hashString("none"): return margelo::nitro::nitrosimpletoast::ToastHaptic::NONE;
50
+ case hashString("success"): return margelo::nitro::nitrosimpletoast::ToastHaptic::SUCCESS;
51
+ case hashString("warning"): return margelo::nitro::nitrosimpletoast::ToastHaptic::WARNING;
52
+ default: [[unlikely]]
53
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum ToastHaptic - invalid value!");
54
+ }
55
+ }
56
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::nitrosimpletoast::ToastHaptic arg) {
57
+ switch (arg) {
58
+ case margelo::nitro::nitrosimpletoast::ToastHaptic::ERROR: return JSIConverter<std::string>::toJSI(runtime, "error");
59
+ case margelo::nitro::nitrosimpletoast::ToastHaptic::NONE: return JSIConverter<std::string>::toJSI(runtime, "none");
60
+ case margelo::nitro::nitrosimpletoast::ToastHaptic::SUCCESS: return JSIConverter<std::string>::toJSI(runtime, "success");
61
+ case margelo::nitro::nitrosimpletoast::ToastHaptic::WARNING: return JSIConverter<std::string>::toJSI(runtime, "warning");
62
+ default: [[unlikely]]
63
+ throw std::invalid_argument("Cannot convert ToastHaptic 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("error"):
74
+ case hashString("none"):
75
+ case hashString("success"):
76
+ case hashString("warning"):
77
+ return true;
78
+ default:
79
+ return false;
80
+ }
81
+ }
82
+ };
83
+
84
+ } // namespace margelo::nitro