@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.
- package/IncomingCall.podspec +29 -0
- package/LICENSE +20 -0
- package/README.md +280 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +118 -0
- package/android/src/main/AndroidManifest.xml +35 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/incomingcall/IncomingCall.kt +219 -0
- package/android/src/main/java/com/margelo/nitro/incomingcall/IncomingCallActivity.kt +314 -0
- package/android/src/main/java/com/margelo/nitro/incomingcall/IncomingCallModule.kt +152 -0
- package/android/src/main/java/com/margelo/nitro/incomingcall/IncomingCallPackage.kt +31 -0
- package/android/src/main/java/com/margelo/nitro/incomingcall/IncomingCallService.kt +109 -0
- package/ios/IncomingCall.swift +28 -0
- package/lib/module/IncomingCall.nitro.js +4 -0
- package/lib/module/IncomingCall.nitro.js.map +1 -0
- package/lib/module/index.js +137 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/IncomingCall.nitro.d.ts +21 -0
- package/lib/typescript/src/IncomingCall.nitro.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +43 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/nitro.json +17 -0
- package/nitrogen/generated/android/c++/JHybridIncomingCallSpec.cpp +101 -0
- package/nitrogen/generated/android/c++/JHybridIncomingCallSpec.hpp +73 -0
- package/nitrogen/generated/android/c++/views/JHybridIncomingCallStateUpdater.cpp +72 -0
- package/nitrogen/generated/android/c++/views/JHybridIncomingCallStateUpdater.hpp +49 -0
- package/nitrogen/generated/android/incomingcall+autolinking.cmake +83 -0
- package/nitrogen/generated/android/incomingcall+autolinking.gradle +27 -0
- package/nitrogen/generated/android/incomingcallOnLoad.cpp +56 -0
- package/nitrogen/generated/android/incomingcallOnLoad.hpp +34 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/incomingcall/HybridIncomingCallSpec.kt +87 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/incomingcall/incomingcallOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/incomingcall/views/HybridIncomingCallManager.kt +70 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/incomingcall/views/HybridIncomingCallStateUpdater.kt +23 -0
- package/nitrogen/generated/ios/IncomingCall+autolinking.rb +60 -0
- package/nitrogen/generated/ios/IncomingCall-Swift-Cxx-Bridge.cpp +33 -0
- package/nitrogen/generated/ios/IncomingCall-Swift-Cxx-Bridge.hpp +83 -0
- package/nitrogen/generated/ios/IncomingCall-Swift-Cxx-Umbrella.hpp +45 -0
- package/nitrogen/generated/ios/IncomingCallAutolinking.mm +33 -0
- package/nitrogen/generated/ios/IncomingCallAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridIncomingCallSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridIncomingCallSpecSwift.hpp +121 -0
- package/nitrogen/generated/ios/c++/views/HybridIncomingCallComponent.mm +127 -0
- package/nitrogen/generated/ios/swift/HybridIncomingCallSpec.swift +60 -0
- package/nitrogen/generated/ios/swift/HybridIncomingCallSpec_cxx.swift +270 -0
- package/nitrogen/generated/shared/c++/HybridIncomingCallSpec.cpp +32 -0
- package/nitrogen/generated/shared/c++/HybridIncomingCallSpec.hpp +73 -0
- package/nitrogen/generated/shared/c++/views/HybridIncomingCallComponent.cpp +127 -0
- package/nitrogen/generated/shared/c++/views/HybridIncomingCallComponent.hpp +115 -0
- package/nitrogen/generated/shared/json/IncomingCallConfig.json +14 -0
- package/package.json +180 -0
- package/src/IncomingCall.nitro.ts +27 -0
- package/src/index.tsx +173 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// IncomingCall-Swift-Cxx-Bridge.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
|
+
// Forward declarations of C++ defined types
|
|
11
|
+
// Forward declaration of `HybridIncomingCallSpec` to properly resolve imports.
|
|
12
|
+
namespace margelo::nitro::incomingcall { class HybridIncomingCallSpec; }
|
|
13
|
+
|
|
14
|
+
// Forward declarations of Swift defined types
|
|
15
|
+
// Forward declaration of `HybridIncomingCallSpec_cxx` to properly resolve imports.
|
|
16
|
+
namespace IncomingCall { class HybridIncomingCallSpec_cxx; }
|
|
17
|
+
|
|
18
|
+
// Include C++ defined types
|
|
19
|
+
#include "HybridIncomingCallSpec.hpp"
|
|
20
|
+
#include <NitroModules/Result.hpp>
|
|
21
|
+
#include <exception>
|
|
22
|
+
#include <memory>
|
|
23
|
+
#include <optional>
|
|
24
|
+
#include <string>
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Contains specialized versions of C++ templated types so they can be accessed from Swift,
|
|
28
|
+
* as well as helper functions to interact with those C++ types from Swift.
|
|
29
|
+
*/
|
|
30
|
+
namespace margelo::nitro::incomingcall::bridge::swift {
|
|
31
|
+
|
|
32
|
+
// pragma MARK: std::optional<std::string>
|
|
33
|
+
/**
|
|
34
|
+
* Specialized version of `std::optional<std::string>`.
|
|
35
|
+
*/
|
|
36
|
+
using std__optional_std__string_ = std::optional<std::string>;
|
|
37
|
+
inline std::optional<std::string> create_std__optional_std__string_(const std::string& value) noexcept {
|
|
38
|
+
return std::optional<std::string>(value);
|
|
39
|
+
}
|
|
40
|
+
inline bool has_value_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
|
|
41
|
+
return optional.has_value();
|
|
42
|
+
}
|
|
43
|
+
inline std::string get_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
|
|
44
|
+
return optional.value();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// pragma MARK: std::optional<double>
|
|
48
|
+
/**
|
|
49
|
+
* Specialized version of `std::optional<double>`.
|
|
50
|
+
*/
|
|
51
|
+
using std__optional_double_ = std::optional<double>;
|
|
52
|
+
inline std::optional<double> create_std__optional_double_(const double& value) noexcept {
|
|
53
|
+
return std::optional<double>(value);
|
|
54
|
+
}
|
|
55
|
+
inline bool has_value_std__optional_double_(const std::optional<double>& optional) noexcept {
|
|
56
|
+
return optional.has_value();
|
|
57
|
+
}
|
|
58
|
+
inline double get_std__optional_double_(const std::optional<double>& optional) noexcept {
|
|
59
|
+
return optional.value();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// pragma MARK: std::shared_ptr<HybridIncomingCallSpec>
|
|
63
|
+
/**
|
|
64
|
+
* Specialized version of `std::shared_ptr<HybridIncomingCallSpec>`.
|
|
65
|
+
*/
|
|
66
|
+
using std__shared_ptr_HybridIncomingCallSpec_ = std::shared_ptr<HybridIncomingCallSpec>;
|
|
67
|
+
std::shared_ptr<HybridIncomingCallSpec> create_std__shared_ptr_HybridIncomingCallSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
|
|
68
|
+
void* NON_NULL get_std__shared_ptr_HybridIncomingCallSpec_(std__shared_ptr_HybridIncomingCallSpec_ cppType);
|
|
69
|
+
|
|
70
|
+
// pragma MARK: std::weak_ptr<HybridIncomingCallSpec>
|
|
71
|
+
using std__weak_ptr_HybridIncomingCallSpec_ = std::weak_ptr<HybridIncomingCallSpec>;
|
|
72
|
+
inline std__weak_ptr_HybridIncomingCallSpec_ weakify_std__shared_ptr_HybridIncomingCallSpec_(const std::shared_ptr<HybridIncomingCallSpec>& strong) noexcept { return strong; }
|
|
73
|
+
|
|
74
|
+
// pragma MARK: Result<void>
|
|
75
|
+
using Result_void_ = Result<void>;
|
|
76
|
+
inline Result_void_ create_Result_void_() noexcept {
|
|
77
|
+
return Result<void>::withValue();
|
|
78
|
+
}
|
|
79
|
+
inline Result_void_ create_Result_void_(const std::exception_ptr& error) noexcept {
|
|
80
|
+
return Result<void>::withError(error);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
} // namespace margelo::nitro::incomingcall::bridge::swift
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// IncomingCall-Swift-Cxx-Umbrella.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
|
+
// Forward declarations of C++ defined types
|
|
11
|
+
// Forward declaration of `HybridIncomingCallSpec` to properly resolve imports.
|
|
12
|
+
namespace margelo::nitro::incomingcall { class HybridIncomingCallSpec; }
|
|
13
|
+
|
|
14
|
+
// Include C++ defined types
|
|
15
|
+
#include "HybridIncomingCallSpec.hpp"
|
|
16
|
+
#include <NitroModules/Result.hpp>
|
|
17
|
+
#include <exception>
|
|
18
|
+
#include <memory>
|
|
19
|
+
#include <optional>
|
|
20
|
+
#include <string>
|
|
21
|
+
|
|
22
|
+
// C++ helpers for Swift
|
|
23
|
+
#include "IncomingCall-Swift-Cxx-Bridge.hpp"
|
|
24
|
+
|
|
25
|
+
// Common C++ types used in Swift
|
|
26
|
+
#include <NitroModules/ArrayBufferHolder.hpp>
|
|
27
|
+
#include <NitroModules/AnyMapUtils.hpp>
|
|
28
|
+
#include <NitroModules/RuntimeError.hpp>
|
|
29
|
+
#include <NitroModules/DateToChronoDate.hpp>
|
|
30
|
+
|
|
31
|
+
// Forward declarations of Swift defined types
|
|
32
|
+
// Forward declaration of `HybridIncomingCallSpec_cxx` to properly resolve imports.
|
|
33
|
+
namespace IncomingCall { class HybridIncomingCallSpec_cxx; }
|
|
34
|
+
|
|
35
|
+
// Include Swift defined types
|
|
36
|
+
#if __has_include("IncomingCall-Swift.h")
|
|
37
|
+
// This header is generated by Xcode/Swift on every app build.
|
|
38
|
+
// If it cannot be found, make sure the Swift module's name (= podspec name) is actually "IncomingCall".
|
|
39
|
+
#include "IncomingCall-Swift.h"
|
|
40
|
+
// Same as above, but used when building with frameworks (`use_frameworks`)
|
|
41
|
+
#elif __has_include(<IncomingCall/IncomingCall-Swift.h>)
|
|
42
|
+
#include <IncomingCall/IncomingCall-Swift.h>
|
|
43
|
+
#else
|
|
44
|
+
#error IncomingCall's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "IncomingCall", and try building the app first.
|
|
45
|
+
#endif
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// IncomingCallAutolinking.mm
|
|
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 <Foundation/Foundation.h>
|
|
9
|
+
#import <NitroModules/HybridObjectRegistry.hpp>
|
|
10
|
+
#import "IncomingCall-Swift-Cxx-Umbrella.hpp"
|
|
11
|
+
#import <type_traits>
|
|
12
|
+
|
|
13
|
+
#include "HybridIncomingCallSpecSwift.hpp"
|
|
14
|
+
|
|
15
|
+
@interface IncomingCallAutolinking : NSObject
|
|
16
|
+
@end
|
|
17
|
+
|
|
18
|
+
@implementation IncomingCallAutolinking
|
|
19
|
+
|
|
20
|
+
+ (void) load {
|
|
21
|
+
using namespace margelo::nitro;
|
|
22
|
+
using namespace margelo::nitro::incomingcall;
|
|
23
|
+
|
|
24
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
25
|
+
"IncomingCall",
|
|
26
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
27
|
+
std::shared_ptr<HybridIncomingCallSpec> hybridObject = IncomingCall::IncomingCallAutolinking::createIncomingCall();
|
|
28
|
+
return hybridObject;
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// IncomingCallAutolinking.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
|
+
// TODO: Use empty enums once Swift supports exporting them as namespaces
|
|
11
|
+
// See: https://github.com/swiftlang/swift/pull/83616
|
|
12
|
+
public final class IncomingCallAutolinking {
|
|
13
|
+
public typealias bridge = margelo.nitro.incomingcall.bridge.swift
|
|
14
|
+
|
|
15
|
+
public static func createIncomingCall() -> bridge.std__shared_ptr_HybridIncomingCallSpec_ {
|
|
16
|
+
let hybridObject = HybridIncomingCall()
|
|
17
|
+
return { () -> bridge.std__shared_ptr_HybridIncomingCallSpec_ in
|
|
18
|
+
let __cxxWrapped = hybridObject.getCxxWrapper()
|
|
19
|
+
return __cxxWrapped.getCxxPart()
|
|
20
|
+
}()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public static func isIncomingCallRecyclable() -> Bool {
|
|
24
|
+
return HybridIncomingCall.self is any RecyclableView.Type
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridIncomingCallSpecSwift.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 "HybridIncomingCallSpecSwift.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::incomingcall {
|
|
11
|
+
} // namespace margelo::nitro::incomingcall
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridIncomingCallSpecSwift.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 "HybridIncomingCallSpec.hpp"
|
|
11
|
+
|
|
12
|
+
// Forward declaration of `HybridIncomingCallSpec_cxx` to properly resolve imports.
|
|
13
|
+
namespace IncomingCall { class HybridIncomingCallSpec_cxx; }
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
#include <string>
|
|
18
|
+
#include <optional>
|
|
19
|
+
|
|
20
|
+
#include "IncomingCall-Swift-Cxx-Umbrella.hpp"
|
|
21
|
+
|
|
22
|
+
namespace margelo::nitro::incomingcall {
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The C++ part of HybridIncomingCallSpec_cxx.swift.
|
|
26
|
+
*
|
|
27
|
+
* HybridIncomingCallSpecSwift (C++) accesses HybridIncomingCallSpec_cxx (Swift), and might
|
|
28
|
+
* contain some additional bridging code for C++ <> Swift interop.
|
|
29
|
+
*
|
|
30
|
+
* Since this obviously introduces an overhead, I hope at some point in
|
|
31
|
+
* the future, HybridIncomingCallSpec_cxx can directly inherit from the C++ class HybridIncomingCallSpec
|
|
32
|
+
* to simplify the whole structure and memory management.
|
|
33
|
+
*/
|
|
34
|
+
class HybridIncomingCallSpecSwift: public virtual HybridIncomingCallSpec {
|
|
35
|
+
public:
|
|
36
|
+
// Constructor from a Swift instance
|
|
37
|
+
explicit HybridIncomingCallSpecSwift(const IncomingCall::HybridIncomingCallSpec_cxx& swiftPart):
|
|
38
|
+
HybridObject(HybridIncomingCallSpec::TAG),
|
|
39
|
+
_swiftPart(swiftPart) { }
|
|
40
|
+
|
|
41
|
+
public:
|
|
42
|
+
// Get the Swift part
|
|
43
|
+
inline IncomingCall::HybridIncomingCallSpec_cxx& getSwiftPart() noexcept {
|
|
44
|
+
return _swiftPart;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public:
|
|
48
|
+
inline size_t getExternalMemorySize() noexcept override {
|
|
49
|
+
return _swiftPart.getMemorySize();
|
|
50
|
+
}
|
|
51
|
+
bool equals(const std::shared_ptr<HybridObject>& other) override {
|
|
52
|
+
if (auto otherCast = std::dynamic_pointer_cast<HybridIncomingCallSpecSwift>(other)) {
|
|
53
|
+
return _swiftPart.equals(otherCast->_swiftPart);
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
void dispose() noexcept override {
|
|
58
|
+
_swiftPart.dispose();
|
|
59
|
+
}
|
|
60
|
+
std::string toString() override {
|
|
61
|
+
return _swiftPart.toString();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public:
|
|
65
|
+
// Properties
|
|
66
|
+
inline std::string getColor() noexcept override {
|
|
67
|
+
auto __result = _swiftPart.getColor();
|
|
68
|
+
return __result;
|
|
69
|
+
}
|
|
70
|
+
inline void setColor(const std::string& color) noexcept override {
|
|
71
|
+
_swiftPart.setColor(color);
|
|
72
|
+
}
|
|
73
|
+
inline std::optional<std::string> getCallerName() noexcept override {
|
|
74
|
+
auto __result = _swiftPart.getCallerName();
|
|
75
|
+
return __result;
|
|
76
|
+
}
|
|
77
|
+
inline void setCallerName(const std::optional<std::string>& callerName) noexcept override {
|
|
78
|
+
_swiftPart.setCallerName(callerName);
|
|
79
|
+
}
|
|
80
|
+
inline std::optional<std::string> getAvatar() noexcept override {
|
|
81
|
+
auto __result = _swiftPart.getAvatar();
|
|
82
|
+
return __result;
|
|
83
|
+
}
|
|
84
|
+
inline void setAvatar(const std::optional<std::string>& avatar) noexcept override {
|
|
85
|
+
_swiftPart.setAvatar(avatar);
|
|
86
|
+
}
|
|
87
|
+
inline std::optional<std::string> getCallType() noexcept override {
|
|
88
|
+
auto __result = _swiftPart.getCallType();
|
|
89
|
+
return __result;
|
|
90
|
+
}
|
|
91
|
+
inline void setCallType(const std::optional<std::string>& callType) noexcept override {
|
|
92
|
+
_swiftPart.setCallType(callType);
|
|
93
|
+
}
|
|
94
|
+
inline std::optional<double> getTimeout() noexcept override {
|
|
95
|
+
auto __result = _swiftPart.getTimeout();
|
|
96
|
+
return __result;
|
|
97
|
+
}
|
|
98
|
+
inline void setTimeout(std::optional<double> timeout) noexcept override {
|
|
99
|
+
_swiftPart.setTimeout(timeout);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
public:
|
|
103
|
+
// Methods
|
|
104
|
+
inline void answerCall() override {
|
|
105
|
+
auto __result = _swiftPart.answerCall();
|
|
106
|
+
if (__result.hasError()) [[unlikely]] {
|
|
107
|
+
std::rethrow_exception(__result.error());
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
inline void rejectCall() override {
|
|
111
|
+
auto __result = _swiftPart.rejectCall();
|
|
112
|
+
if (__result.hasError()) [[unlikely]] {
|
|
113
|
+
std::rethrow_exception(__result.error());
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
private:
|
|
118
|
+
IncomingCall::HybridIncomingCallSpec_cxx _swiftPart;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
} // namespace margelo::nitro::incomingcall
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridIncomingCallComponent.mm
|
|
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 "HybridIncomingCallComponent.hpp"
|
|
9
|
+
#import <memory>
|
|
10
|
+
#import <react/renderer/componentregistry/ComponentDescriptorProvider.h>
|
|
11
|
+
#import <React/RCTViewComponentView.h>
|
|
12
|
+
#import <React/RCTComponentViewFactory.h>
|
|
13
|
+
#import <React/UIView+ComponentViewProtocol.h>
|
|
14
|
+
#import <NitroModules/NitroDefines.hpp>
|
|
15
|
+
#import <UIKit/UIKit.h>
|
|
16
|
+
|
|
17
|
+
#import "HybridIncomingCallSpecSwift.hpp"
|
|
18
|
+
#import "IncomingCall-Swift-Cxx-Umbrella.hpp"
|
|
19
|
+
|
|
20
|
+
using namespace facebook;
|
|
21
|
+
using namespace margelo::nitro::incomingcall;
|
|
22
|
+
using namespace margelo::nitro::incomingcall::views;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Represents the React Native View holder for the Nitro "IncomingCall" HybridView.
|
|
26
|
+
*/
|
|
27
|
+
@interface HybridIncomingCallComponent: RCTViewComponentView
|
|
28
|
+
+ (BOOL)shouldBeRecycled;
|
|
29
|
+
@end
|
|
30
|
+
|
|
31
|
+
@implementation HybridIncomingCallComponent {
|
|
32
|
+
std::shared_ptr<HybridIncomingCallSpecSwift> _hybridView;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
+ (void) load {
|
|
36
|
+
[super load];
|
|
37
|
+
[RCTComponentViewFactory.currentComponentViewFactory registerComponentViewClass:[HybridIncomingCallComponent class]];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
+ (react::ComponentDescriptorProvider) componentDescriptorProvider {
|
|
41
|
+
return react::concreteComponentDescriptorProvider<HybridIncomingCallComponentDescriptor>();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
- (instancetype) init {
|
|
45
|
+
if (self = [super init]) {
|
|
46
|
+
std::shared_ptr<HybridIncomingCallSpec> hybridView = IncomingCall::IncomingCallAutolinking::createIncomingCall();
|
|
47
|
+
_hybridView = std::dynamic_pointer_cast<HybridIncomingCallSpecSwift>(hybridView);
|
|
48
|
+
[self updateView];
|
|
49
|
+
}
|
|
50
|
+
return self;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
- (void) updateView {
|
|
54
|
+
// 1. Get Swift part
|
|
55
|
+
IncomingCall::HybridIncomingCallSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
56
|
+
|
|
57
|
+
// 2. Get UIView*
|
|
58
|
+
void* viewUnsafe = swiftPart.getView();
|
|
59
|
+
UIView* view = (__bridge_transfer UIView*) viewUnsafe;
|
|
60
|
+
|
|
61
|
+
// 3. Update RCTViewComponentView's [contentView]
|
|
62
|
+
[self setContentView:view];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
- (void) updateProps:(const std::shared_ptr<const react::Props>&)props
|
|
66
|
+
oldProps:(const std::shared_ptr<const react::Props>&)oldProps {
|
|
67
|
+
// 1. Downcast props
|
|
68
|
+
const auto& newViewPropsConst = *std::static_pointer_cast<HybridIncomingCallProps const>(props);
|
|
69
|
+
auto& newViewProps = const_cast<HybridIncomingCallProps&>(newViewPropsConst);
|
|
70
|
+
IncomingCall::HybridIncomingCallSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
71
|
+
|
|
72
|
+
// 2. Update each prop individually
|
|
73
|
+
swiftPart.beforeUpdate();
|
|
74
|
+
|
|
75
|
+
// color: string
|
|
76
|
+
if (newViewProps.color.isDirty) {
|
|
77
|
+
swiftPart.setColor(newViewProps.color.value);
|
|
78
|
+
newViewProps.color.isDirty = false;
|
|
79
|
+
}
|
|
80
|
+
// callerName: optional
|
|
81
|
+
if (newViewProps.callerName.isDirty) {
|
|
82
|
+
swiftPart.setCallerName(newViewProps.callerName.value);
|
|
83
|
+
newViewProps.callerName.isDirty = false;
|
|
84
|
+
}
|
|
85
|
+
// avatar: optional
|
|
86
|
+
if (newViewProps.avatar.isDirty) {
|
|
87
|
+
swiftPart.setAvatar(newViewProps.avatar.value);
|
|
88
|
+
newViewProps.avatar.isDirty = false;
|
|
89
|
+
}
|
|
90
|
+
// callType: optional
|
|
91
|
+
if (newViewProps.callType.isDirty) {
|
|
92
|
+
swiftPart.setCallType(newViewProps.callType.value);
|
|
93
|
+
newViewProps.callType.isDirty = false;
|
|
94
|
+
}
|
|
95
|
+
// timeout: optional
|
|
96
|
+
if (newViewProps.timeout.isDirty) {
|
|
97
|
+
swiftPart.setTimeout(newViewProps.timeout.value);
|
|
98
|
+
newViewProps.timeout.isDirty = false;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
swiftPart.afterUpdate();
|
|
102
|
+
|
|
103
|
+
// 3. Update hybridRef if it changed
|
|
104
|
+
if (newViewProps.hybridRef.isDirty) {
|
|
105
|
+
// hybridRef changed - call it with new this
|
|
106
|
+
const auto& maybeFunc = newViewProps.hybridRef.value;
|
|
107
|
+
if (maybeFunc.has_value()) {
|
|
108
|
+
maybeFunc.value()(_hybridView);
|
|
109
|
+
}
|
|
110
|
+
newViewProps.hybridRef.isDirty = false;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// 4. Continue in base class
|
|
114
|
+
[super updateProps:props oldProps:oldProps];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
+ (BOOL)shouldBeRecycled {
|
|
118
|
+
return IncomingCall::IncomingCallAutolinking::isIncomingCallRecyclable();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
- (void)prepareForRecycle {
|
|
122
|
+
[super prepareForRecycle];
|
|
123
|
+
IncomingCall::HybridIncomingCallSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
124
|
+
swiftPart.maybePrepareForRecycle();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
@end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridIncomingCallSpec.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
|
+
/// See ``HybridIncomingCallSpec``
|
|
11
|
+
public protocol HybridIncomingCallSpec_protocol: HybridObject, HybridView {
|
|
12
|
+
// Properties
|
|
13
|
+
var color: String { get set }
|
|
14
|
+
var callerName: String? { get set }
|
|
15
|
+
var avatar: String? { get set }
|
|
16
|
+
var callType: String? { get set }
|
|
17
|
+
var timeout: Double? { get set }
|
|
18
|
+
|
|
19
|
+
// Methods
|
|
20
|
+
func answerCall() throws -> Void
|
|
21
|
+
func rejectCall() throws -> Void
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public extension HybridIncomingCallSpec_protocol {
|
|
25
|
+
/// Default implementation of ``HybridObject.toString``
|
|
26
|
+
func toString() -> String {
|
|
27
|
+
return "[HybridObject IncomingCall]"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/// See ``HybridIncomingCallSpec``
|
|
32
|
+
open class HybridIncomingCallSpec_base {
|
|
33
|
+
private weak var cxxWrapper: HybridIncomingCallSpec_cxx? = nil
|
|
34
|
+
public init() { }
|
|
35
|
+
public func getCxxWrapper() -> HybridIncomingCallSpec_cxx {
|
|
36
|
+
#if DEBUG
|
|
37
|
+
guard self is any HybridIncomingCallSpec else {
|
|
38
|
+
fatalError("`self` is not a `HybridIncomingCallSpec`! Did you accidentally inherit from `HybridIncomingCallSpec_base` instead of `HybridIncomingCallSpec`?")
|
|
39
|
+
}
|
|
40
|
+
#endif
|
|
41
|
+
if let cxxWrapper = self.cxxWrapper {
|
|
42
|
+
return cxxWrapper
|
|
43
|
+
} else {
|
|
44
|
+
let cxxWrapper = HybridIncomingCallSpec_cxx(self as! any HybridIncomingCallSpec)
|
|
45
|
+
self.cxxWrapper = cxxWrapper
|
|
46
|
+
return cxxWrapper
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* A Swift base-protocol representing the IncomingCall HybridObject.
|
|
53
|
+
* Implement this protocol to create Swift-based instances of IncomingCall.
|
|
54
|
+
* ```swift
|
|
55
|
+
* class HybridIncomingCall : HybridIncomingCallSpec {
|
|
56
|
+
* // ...
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
public typealias HybridIncomingCallSpec = HybridIncomingCallSpec_protocol & HybridIncomingCallSpec_base
|