@kaleem766/react-native-incoming-call 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 (55) hide show
  1. package/IncomingCall.podspec +29 -0
  2. package/LICENSE +20 -0
  3. package/README.md +280 -0
  4. package/android/CMakeLists.txt +24 -0
  5. package/android/build.gradle +118 -0
  6. package/android/src/main/AndroidManifest.xml +35 -0
  7. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  8. package/android/src/main/java/com/margelo/nitro/incomingcall/IncomingCall.kt +219 -0
  9. package/android/src/main/java/com/margelo/nitro/incomingcall/IncomingCallActivity.kt +314 -0
  10. package/android/src/main/java/com/margelo/nitro/incomingcall/IncomingCallModule.kt +152 -0
  11. package/android/src/main/java/com/margelo/nitro/incomingcall/IncomingCallPackage.kt +31 -0
  12. package/android/src/main/java/com/margelo/nitro/incomingcall/IncomingCallService.kt +109 -0
  13. package/ios/IncomingCall.swift +28 -0
  14. package/lib/module/IncomingCall.nitro.js +4 -0
  15. package/lib/module/IncomingCall.nitro.js.map +1 -0
  16. package/lib/module/index.js +137 -0
  17. package/lib/module/index.js.map +1 -0
  18. package/lib/module/package.json +1 -0
  19. package/lib/typescript/package.json +1 -0
  20. package/lib/typescript/src/IncomingCall.nitro.d.ts +21 -0
  21. package/lib/typescript/src/IncomingCall.nitro.d.ts.map +1 -0
  22. package/lib/typescript/src/index.d.ts +43 -0
  23. package/lib/typescript/src/index.d.ts.map +1 -0
  24. package/nitro.json +17 -0
  25. package/nitrogen/generated/android/c++/JHybridIncomingCallSpec.cpp +101 -0
  26. package/nitrogen/generated/android/c++/JHybridIncomingCallSpec.hpp +73 -0
  27. package/nitrogen/generated/android/c++/views/JHybridIncomingCallStateUpdater.cpp +72 -0
  28. package/nitrogen/generated/android/c++/views/JHybridIncomingCallStateUpdater.hpp +49 -0
  29. package/nitrogen/generated/android/incomingcall+autolinking.cmake +83 -0
  30. package/nitrogen/generated/android/incomingcall+autolinking.gradle +27 -0
  31. package/nitrogen/generated/android/incomingcallOnLoad.cpp +56 -0
  32. package/nitrogen/generated/android/incomingcallOnLoad.hpp +34 -0
  33. package/nitrogen/generated/android/kotlin/com/margelo/nitro/incomingcall/HybridIncomingCallSpec.kt +87 -0
  34. package/nitrogen/generated/android/kotlin/com/margelo/nitro/incomingcall/incomingcallOnLoad.kt +35 -0
  35. package/nitrogen/generated/android/kotlin/com/margelo/nitro/incomingcall/views/HybridIncomingCallManager.kt +70 -0
  36. package/nitrogen/generated/android/kotlin/com/margelo/nitro/incomingcall/views/HybridIncomingCallStateUpdater.kt +23 -0
  37. package/nitrogen/generated/ios/IncomingCall+autolinking.rb +60 -0
  38. package/nitrogen/generated/ios/IncomingCall-Swift-Cxx-Bridge.cpp +33 -0
  39. package/nitrogen/generated/ios/IncomingCall-Swift-Cxx-Bridge.hpp +83 -0
  40. package/nitrogen/generated/ios/IncomingCall-Swift-Cxx-Umbrella.hpp +45 -0
  41. package/nitrogen/generated/ios/IncomingCallAutolinking.mm +33 -0
  42. package/nitrogen/generated/ios/IncomingCallAutolinking.swift +26 -0
  43. package/nitrogen/generated/ios/c++/HybridIncomingCallSpecSwift.cpp +11 -0
  44. package/nitrogen/generated/ios/c++/HybridIncomingCallSpecSwift.hpp +121 -0
  45. package/nitrogen/generated/ios/c++/views/HybridIncomingCallComponent.mm +127 -0
  46. package/nitrogen/generated/ios/swift/HybridIncomingCallSpec.swift +60 -0
  47. package/nitrogen/generated/ios/swift/HybridIncomingCallSpec_cxx.swift +270 -0
  48. package/nitrogen/generated/shared/c++/HybridIncomingCallSpec.cpp +32 -0
  49. package/nitrogen/generated/shared/c++/HybridIncomingCallSpec.hpp +73 -0
  50. package/nitrogen/generated/shared/c++/views/HybridIncomingCallComponent.cpp +127 -0
  51. package/nitrogen/generated/shared/c++/views/HybridIncomingCallComponent.hpp +115 -0
  52. package/nitrogen/generated/shared/json/IncomingCallConfig.json +14 -0
  53. package/package.json +180 -0
  54. package/src/IncomingCall.nitro.ts +27 -0
  55. package/src/index.tsx +173 -0
@@ -0,0 +1,270 @@
1
+ ///
2
+ /// HybridIncomingCallSpec_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 HybridIncomingCallSpec 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 HybridIncomingCallSpec_cxx {
20
+ /**
21
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::incomingcall::bridge::swift`)
22
+ * from `IncomingCall-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.incomingcall.bridge.swift
26
+
27
+ /**
28
+ * Holds an instance of the `HybridIncomingCallSpec` Swift protocol.
29
+ */
30
+ private var __implementation: any HybridIncomingCallSpec
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_HybridIncomingCallSpec_
36
+
37
+ /**
38
+ * Create a new `HybridIncomingCallSpec_cxx` that wraps the given `HybridIncomingCallSpec`.
39
+ * All properties and methods bridge to C++ types.
40
+ */
41
+ public init(_ implementation: any HybridIncomingCallSpec) {
42
+ self.__implementation = implementation
43
+ self.__cxxPart = .init()
44
+ /* no base class */
45
+ }
46
+
47
+ /**
48
+ * Get the actual `HybridIncomingCallSpec` instance this class wraps.
49
+ */
50
+ @inline(__always)
51
+ public func getHybridIncomingCallSpec() -> any HybridIncomingCallSpec {
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 `HybridIncomingCallSpec_cxx`.
65
+ * The pointer has to be a retained opaque `Unmanaged<HybridIncomingCallSpec_cxx>`.
66
+ * This removes one strong reference from the object!
67
+ */
68
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridIncomingCallSpec_cxx {
69
+ return Unmanaged<HybridIncomingCallSpec_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<HybridIncomingCallSpec>`.
75
+ */
76
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridIncomingCallSpec_ {
77
+ let cachedCxxPart = self.__cxxPart.lock()
78
+ if Bool(fromCxx: cachedCxxPart) {
79
+ return cachedCxxPart
80
+ } else {
81
+ let newCxxPart = bridge.create_std__shared_ptr_HybridIncomingCallSpec_(self.toUnsafe())
82
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridIncomingCallSpec_(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: HybridIncomingCallSpec_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
+ public final var color: std.string {
125
+ @inline(__always)
126
+ get {
127
+ return std.string(self.__implementation.color)
128
+ }
129
+ @inline(__always)
130
+ set {
131
+ self.__implementation.color = String(newValue)
132
+ }
133
+ }
134
+
135
+ public final var callerName: bridge.std__optional_std__string_ {
136
+ @inline(__always)
137
+ get {
138
+ return { () -> bridge.std__optional_std__string_ in
139
+ if let __unwrappedValue = self.__implementation.callerName {
140
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
141
+ } else {
142
+ return .init()
143
+ }
144
+ }()
145
+ }
146
+ @inline(__always)
147
+ set {
148
+ self.__implementation.callerName = { () -> String? in
149
+ if bridge.has_value_std__optional_std__string_(newValue) {
150
+ let __unwrapped = bridge.get_std__optional_std__string_(newValue)
151
+ return String(__unwrapped)
152
+ } else {
153
+ return nil
154
+ }
155
+ }()
156
+ }
157
+ }
158
+
159
+ public final var avatar: bridge.std__optional_std__string_ {
160
+ @inline(__always)
161
+ get {
162
+ return { () -> bridge.std__optional_std__string_ in
163
+ if let __unwrappedValue = self.__implementation.avatar {
164
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
165
+ } else {
166
+ return .init()
167
+ }
168
+ }()
169
+ }
170
+ @inline(__always)
171
+ set {
172
+ self.__implementation.avatar = { () -> String? in
173
+ if bridge.has_value_std__optional_std__string_(newValue) {
174
+ let __unwrapped = bridge.get_std__optional_std__string_(newValue)
175
+ return String(__unwrapped)
176
+ } else {
177
+ return nil
178
+ }
179
+ }()
180
+ }
181
+ }
182
+
183
+ public final var callType: bridge.std__optional_std__string_ {
184
+ @inline(__always)
185
+ get {
186
+ return { () -> bridge.std__optional_std__string_ in
187
+ if let __unwrappedValue = self.__implementation.callType {
188
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
189
+ } else {
190
+ return .init()
191
+ }
192
+ }()
193
+ }
194
+ @inline(__always)
195
+ set {
196
+ self.__implementation.callType = { () -> String? in
197
+ if bridge.has_value_std__optional_std__string_(newValue) {
198
+ let __unwrapped = bridge.get_std__optional_std__string_(newValue)
199
+ return String(__unwrapped)
200
+ } else {
201
+ return nil
202
+ }
203
+ }()
204
+ }
205
+ }
206
+
207
+ public final var timeout: bridge.std__optional_double_ {
208
+ @inline(__always)
209
+ get {
210
+ return { () -> bridge.std__optional_double_ in
211
+ if let __unwrappedValue = self.__implementation.timeout {
212
+ return bridge.create_std__optional_double_(__unwrappedValue)
213
+ } else {
214
+ return .init()
215
+ }
216
+ }()
217
+ }
218
+ @inline(__always)
219
+ set {
220
+ self.__implementation.timeout = { () -> Double? in
221
+ if bridge.has_value_std__optional_double_(newValue) {
222
+ let __unwrapped = bridge.get_std__optional_double_(newValue)
223
+ return __unwrapped
224
+ } else {
225
+ return nil
226
+ }
227
+ }()
228
+ }
229
+ }
230
+
231
+ // Methods
232
+ @inline(__always)
233
+ public final func answerCall() -> bridge.Result_void_ {
234
+ do {
235
+ try self.__implementation.answerCall()
236
+ return bridge.create_Result_void_()
237
+ } catch (let __error) {
238
+ let __exceptionPtr = __error.toCpp()
239
+ return bridge.create_Result_void_(__exceptionPtr)
240
+ }
241
+ }
242
+
243
+ @inline(__always)
244
+ public final func rejectCall() -> bridge.Result_void_ {
245
+ do {
246
+ try self.__implementation.rejectCall()
247
+ return bridge.create_Result_void_()
248
+ } catch (let __error) {
249
+ let __exceptionPtr = __error.toCpp()
250
+ return bridge.create_Result_void_(__exceptionPtr)
251
+ }
252
+ }
253
+
254
+ public final func getView() -> UnsafeMutableRawPointer {
255
+ return Unmanaged.passRetained(__implementation.view).toOpaque()
256
+ }
257
+
258
+ public final func beforeUpdate() {
259
+ __implementation.beforeUpdate()
260
+ }
261
+
262
+ public final func afterUpdate() {
263
+ __implementation.afterUpdate()
264
+ }
265
+
266
+ public final func maybePrepareForRecycle() {
267
+ guard let recyclable = __implementation as? any RecyclableView else { return }
268
+ recyclable.prepareForRecycle()
269
+ }
270
+ }
@@ -0,0 +1,32 @@
1
+ ///
2
+ /// HybridIncomingCallSpec.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 "HybridIncomingCallSpec.hpp"
9
+
10
+ namespace margelo::nitro::incomingcall {
11
+
12
+ void HybridIncomingCallSpec::loadHybridMethods() {
13
+ // load base methods/properties
14
+ HybridObject::loadHybridMethods();
15
+ // load custom methods/properties
16
+ registerHybrids(this, [](Prototype& prototype) {
17
+ prototype.registerHybridGetter("color", &HybridIncomingCallSpec::getColor);
18
+ prototype.registerHybridSetter("color", &HybridIncomingCallSpec::setColor);
19
+ prototype.registerHybridGetter("callerName", &HybridIncomingCallSpec::getCallerName);
20
+ prototype.registerHybridSetter("callerName", &HybridIncomingCallSpec::setCallerName);
21
+ prototype.registerHybridGetter("avatar", &HybridIncomingCallSpec::getAvatar);
22
+ prototype.registerHybridSetter("avatar", &HybridIncomingCallSpec::setAvatar);
23
+ prototype.registerHybridGetter("callType", &HybridIncomingCallSpec::getCallType);
24
+ prototype.registerHybridSetter("callType", &HybridIncomingCallSpec::setCallType);
25
+ prototype.registerHybridGetter("timeout", &HybridIncomingCallSpec::getTimeout);
26
+ prototype.registerHybridSetter("timeout", &HybridIncomingCallSpec::setTimeout);
27
+ prototype.registerHybridMethod("answerCall", &HybridIncomingCallSpec::answerCall);
28
+ prototype.registerHybridMethod("rejectCall", &HybridIncomingCallSpec::rejectCall);
29
+ });
30
+ }
31
+
32
+ } // namespace margelo::nitro::incomingcall
@@ -0,0 +1,73 @@
1
+ ///
2
+ /// HybridIncomingCallSpec.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
+
17
+
18
+ #include <string>
19
+ #include <optional>
20
+
21
+ namespace margelo::nitro::incomingcall {
22
+
23
+ using namespace margelo::nitro;
24
+
25
+ /**
26
+ * An abstract base class for `IncomingCall`
27
+ * Inherit this class to create instances of `HybridIncomingCallSpec` in C++.
28
+ * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
29
+ * @example
30
+ * ```cpp
31
+ * class HybridIncomingCall: public HybridIncomingCallSpec {
32
+ * public:
33
+ * HybridIncomingCall(...): HybridObject(TAG) { ... }
34
+ * // ...
35
+ * };
36
+ * ```
37
+ */
38
+ class HybridIncomingCallSpec: public virtual HybridObject {
39
+ public:
40
+ // Constructor
41
+ explicit HybridIncomingCallSpec(): HybridObject(TAG) { }
42
+
43
+ // Destructor
44
+ ~HybridIncomingCallSpec() override = default;
45
+
46
+ public:
47
+ // Properties
48
+ virtual std::string getColor() = 0;
49
+ virtual void setColor(const std::string& color) = 0;
50
+ virtual std::optional<std::string> getCallerName() = 0;
51
+ virtual void setCallerName(const std::optional<std::string>& callerName) = 0;
52
+ virtual std::optional<std::string> getAvatar() = 0;
53
+ virtual void setAvatar(const std::optional<std::string>& avatar) = 0;
54
+ virtual std::optional<std::string> getCallType() = 0;
55
+ virtual void setCallType(const std::optional<std::string>& callType) = 0;
56
+ virtual std::optional<double> getTimeout() = 0;
57
+ virtual void setTimeout(std::optional<double> timeout) = 0;
58
+
59
+ public:
60
+ // Methods
61
+ virtual void answerCall() = 0;
62
+ virtual void rejectCall() = 0;
63
+
64
+ protected:
65
+ // Hybrid Setup
66
+ void loadHybridMethods() override;
67
+
68
+ protected:
69
+ // Tag for logging
70
+ static constexpr auto TAG = "IncomingCall";
71
+ };
72
+
73
+ } // namespace margelo::nitro::incomingcall
@@ -0,0 +1,127 @@
1
+ ///
2
+ /// HybridIncomingCallComponent.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 "HybridIncomingCallComponent.hpp"
9
+
10
+ #include <string>
11
+ #include <exception>
12
+ #include <utility>
13
+ #include <NitroModules/NitroDefines.hpp>
14
+ #include <NitroModules/JSIConverter.hpp>
15
+ #include <NitroModules/PropNameIDCache.hpp>
16
+ #include <react/renderer/core/RawValue.h>
17
+ #include <react/renderer/core/ShadowNode.h>
18
+ #include <react/renderer/core/ComponentDescriptor.h>
19
+ #include <react/renderer/components/view/ViewProps.h>
20
+
21
+ namespace margelo::nitro::incomingcall::views {
22
+
23
+ extern const char HybridIncomingCallComponentName[] = "IncomingCall";
24
+
25
+ HybridIncomingCallProps::HybridIncomingCallProps(const react::PropsParserContext& context,
26
+ const HybridIncomingCallProps& sourceProps,
27
+ const react::RawProps& rawProps):
28
+ react::ViewProps(context, sourceProps, rawProps, filterObjectKeys),
29
+ color([&]() -> CachedProp<std::string> {
30
+ try {
31
+ const react::RawValue* rawValue = rawProps.at("color", nullptr, nullptr);
32
+ if (rawValue == nullptr) return sourceProps.color;
33
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
34
+ return CachedProp<std::string>::fromRawValue(*runtime, value, sourceProps.color);
35
+ } catch (const std::exception& exc) {
36
+ throw std::runtime_error(std::string("IncomingCall.color: ") + exc.what());
37
+ }
38
+ }()),
39
+ callerName([&]() -> CachedProp<std::optional<std::string>> {
40
+ try {
41
+ const react::RawValue* rawValue = rawProps.at("callerName", nullptr, nullptr);
42
+ if (rawValue == nullptr) return sourceProps.callerName;
43
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
44
+ return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.callerName);
45
+ } catch (const std::exception& exc) {
46
+ throw std::runtime_error(std::string("IncomingCall.callerName: ") + exc.what());
47
+ }
48
+ }()),
49
+ avatar([&]() -> CachedProp<std::optional<std::string>> {
50
+ try {
51
+ const react::RawValue* rawValue = rawProps.at("avatar", nullptr, nullptr);
52
+ if (rawValue == nullptr) return sourceProps.avatar;
53
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
54
+ return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.avatar);
55
+ } catch (const std::exception& exc) {
56
+ throw std::runtime_error(std::string("IncomingCall.avatar: ") + exc.what());
57
+ }
58
+ }()),
59
+ callType([&]() -> CachedProp<std::optional<std::string>> {
60
+ try {
61
+ const react::RawValue* rawValue = rawProps.at("callType", nullptr, nullptr);
62
+ if (rawValue == nullptr) return sourceProps.callType;
63
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
64
+ return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.callType);
65
+ } catch (const std::exception& exc) {
66
+ throw std::runtime_error(std::string("IncomingCall.callType: ") + exc.what());
67
+ }
68
+ }()),
69
+ timeout([&]() -> CachedProp<std::optional<double>> {
70
+ try {
71
+ const react::RawValue* rawValue = rawProps.at("timeout", nullptr, nullptr);
72
+ if (rawValue == nullptr) return sourceProps.timeout;
73
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
74
+ return CachedProp<std::optional<double>>::fromRawValue(*runtime, value, sourceProps.timeout);
75
+ } catch (const std::exception& exc) {
76
+ throw std::runtime_error(std::string("IncomingCall.timeout: ") + exc.what());
77
+ }
78
+ }()),
79
+ hybridRef([&]() -> CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridIncomingCallSpec>& /* ref */)>>> {
80
+ try {
81
+ const react::RawValue* rawValue = rawProps.at("hybridRef", nullptr, nullptr);
82
+ if (rawValue == nullptr) return sourceProps.hybridRef;
83
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
84
+ return CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridIncomingCallSpec>& /* ref */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.hybridRef);
85
+ } catch (const std::exception& exc) {
86
+ throw std::runtime_error(std::string("IncomingCall.hybridRef: ") + exc.what());
87
+ }
88
+ }()) { }
89
+
90
+ bool HybridIncomingCallProps::filterObjectKeys(const std::string& propName) {
91
+ switch (hashString(propName)) {
92
+ case hashString("color"): return true;
93
+ case hashString("callerName"): return true;
94
+ case hashString("avatar"): return true;
95
+ case hashString("callType"): return true;
96
+ case hashString("timeout"): return true;
97
+ case hashString("hybridRef"): return true;
98
+ default: return false;
99
+ }
100
+ }
101
+
102
+ HybridIncomingCallComponentDescriptor::HybridIncomingCallComponentDescriptor(const react::ComponentDescriptorParameters& parameters)
103
+ : ConcreteComponentDescriptor(parameters,
104
+ react::RawPropsParser(/* enableJsiParser */ true)) {}
105
+
106
+ std::shared_ptr<const react::Props> HybridIncomingCallComponentDescriptor::cloneProps(const react::PropsParserContext& context,
107
+ const std::shared_ptr<const react::Props>& props,
108
+ react::RawProps rawProps) const {
109
+ // 1. Prepare raw props parser
110
+ rawProps.parse(rawPropsParser_);
111
+ // 2. Copy props with Nitro's cached copy constructor
112
+ return HybridIncomingCallShadowNode::Props(context, /* & */ rawProps, props);
113
+ }
114
+
115
+ #ifdef ANDROID
116
+ void HybridIncomingCallComponentDescriptor::adopt(react::ShadowNode& shadowNode) const {
117
+ // This is called immediately after `ShadowNode` is created, cloned or in progress.
118
+ // On Android, we need to wrap props in our state, which gets routed through Java and later unwrapped in JNI/C++.
119
+ auto& concreteShadowNode = static_cast<HybridIncomingCallShadowNode&>(shadowNode);
120
+ const std::shared_ptr<const HybridIncomingCallProps>& constProps = concreteShadowNode.getConcreteSharedProps();
121
+ const std::shared_ptr<HybridIncomingCallProps>& props = std::const_pointer_cast<HybridIncomingCallProps>(constProps);
122
+ HybridIncomingCallState state{props};
123
+ concreteShadowNode.setStateData(std::move(state));
124
+ }
125
+ #endif
126
+
127
+ } // namespace margelo::nitro::incomingcall::views
@@ -0,0 +1,115 @@
1
+ ///
2
+ /// HybridIncomingCallComponent.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 <optional>
11
+ #include <NitroModules/NitroDefines.hpp>
12
+ #include <NitroModules/NitroHash.hpp>
13
+ #include <NitroModules/CachedProp.hpp>
14
+ #include <react/renderer/core/ConcreteComponentDescriptor.h>
15
+ #include <react/renderer/core/PropsParserContext.h>
16
+ #include <react/renderer/components/view/ConcreteViewShadowNode.h>
17
+ #include <react/renderer/components/view/ViewProps.h>
18
+
19
+ #include <string>
20
+ #include <optional>
21
+ #include <memory>
22
+ #include "HybridIncomingCallSpec.hpp"
23
+ #include <functional>
24
+
25
+ namespace margelo::nitro::incomingcall::views {
26
+
27
+ using namespace facebook;
28
+
29
+ /**
30
+ * The name of the actual native View.
31
+ */
32
+ extern const char HybridIncomingCallComponentName[];
33
+
34
+ /**
35
+ * Props for the "IncomingCall" View.
36
+ */
37
+ class HybridIncomingCallProps final: public react::ViewProps {
38
+ public:
39
+ HybridIncomingCallProps() = default;
40
+ HybridIncomingCallProps(const react::PropsParserContext& context,
41
+ const HybridIncomingCallProps& sourceProps,
42
+ const react::RawProps& rawProps);
43
+
44
+ public:
45
+ CachedProp<std::string> color;
46
+ CachedProp<std::optional<std::string>> callerName;
47
+ CachedProp<std::optional<std::string>> avatar;
48
+ CachedProp<std::optional<std::string>> callType;
49
+ CachedProp<std::optional<double>> timeout;
50
+ CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridIncomingCallSpec>& /* ref */)>>> hybridRef;
51
+
52
+ private:
53
+ static bool filterObjectKeys(const std::string& propName);
54
+ };
55
+
56
+ /**
57
+ * State for the "IncomingCall" View.
58
+ */
59
+ class HybridIncomingCallState final {
60
+ public:
61
+ HybridIncomingCallState() = default;
62
+ explicit HybridIncomingCallState(const std::shared_ptr<HybridIncomingCallProps>& props):
63
+ _props(props) {}
64
+
65
+ public:
66
+ [[nodiscard]]
67
+ const std::shared_ptr<HybridIncomingCallProps>& getProps() const {
68
+ return _props;
69
+ }
70
+
71
+ public:
72
+ #ifdef ANDROID
73
+ HybridIncomingCallState(const HybridIncomingCallState& /* previousState */, folly::dynamic /* data */) {}
74
+ folly::dynamic getDynamic() const {
75
+ throw std::runtime_error("HybridIncomingCallState does not support folly!");
76
+ }
77
+ react::MapBuffer getMapBuffer() const {
78
+ throw std::runtime_error("HybridIncomingCallState does not support MapBuffer!");
79
+ };
80
+ #endif
81
+
82
+ private:
83
+ std::shared_ptr<HybridIncomingCallProps> _props;
84
+ };
85
+
86
+ /**
87
+ * The Shadow Node for the "IncomingCall" View.
88
+ */
89
+ using HybridIncomingCallShadowNode = react::ConcreteViewShadowNode<HybridIncomingCallComponentName /* "HybridIncomingCall" */,
90
+ HybridIncomingCallProps /* custom props */,
91
+ react::ViewEventEmitter /* default */,
92
+ HybridIncomingCallState /* custom state */>;
93
+
94
+ /**
95
+ * The Component Descriptor for the "IncomingCall" View.
96
+ */
97
+ class HybridIncomingCallComponentDescriptor final: public react::ConcreteComponentDescriptor<HybridIncomingCallShadowNode> {
98
+ public:
99
+ explicit HybridIncomingCallComponentDescriptor(const react::ComponentDescriptorParameters& parameters);
100
+
101
+ public:
102
+ /**
103
+ * A faster path for cloning props - reuses the caching logic from `HybridIncomingCallProps`.
104
+ */
105
+ std::shared_ptr<const react::Props> cloneProps(const react::PropsParserContext& context,
106
+ const std::shared_ptr<const react::Props>& props,
107
+ react::RawProps rawProps) const override;
108
+ #ifdef ANDROID
109
+ void adopt(react::ShadowNode& shadowNode) const override;
110
+ #endif
111
+ };
112
+
113
+ /* The actual view for "IncomingCall" needs to be implemented in platform-specific code. */
114
+
115
+ } // namespace margelo::nitro::incomingcall::views
@@ -0,0 +1,14 @@
1
+ {
2
+ "uiViewClassName": "IncomingCall",
3
+ "supportsRawText": false,
4
+ "bubblingEventTypes": {},
5
+ "directEventTypes": {},
6
+ "validAttributes": {
7
+ "color": true,
8
+ "callerName": true,
9
+ "avatar": true,
10
+ "callType": true,
11
+ "timeout": true,
12
+ "hybridRef": true
13
+ }
14
+ }