@onekeyfe/react-native-image 6.7.0-21 → 6.7.0-23
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/README.md +12 -0
- package/android/build.gradle +3 -1
- package/android/src/main/java/com/margelo/nitro/onekeyimage/OneKeyIcon.kt +93 -0
- package/android/src/main/java/com/margelo/nitro/onekeyimage/OneKeyImageGlideRegistry.kt +1 -1
- package/android/src/main/java/com/margelo/nitro/onekeyimage/OneKeyImagePackage.kt +2 -1
- package/android/src/main/java/com/margelo/nitro/onekeyimage/OneKeyNamedSVG.kt +217 -0
- package/android/src/main/java/com/margelo/nitro/onekeyimage/OneKeySVG.kt +31 -0
- package/ios/OneKeyIcon.swift +90 -0
- package/ios/OneKeyImageCoderBridge.h +4 -0
- package/ios/OneKeyImageCoderBridge.m +9 -0
- package/ios/OneKeyNamedSVG.swift +282 -0
- package/ios/tests/OneKeyIconTests.swift +484 -0
- package/lib/module/OneKeyIcon.nitro.js +4 -0
- package/lib/module/icon/assetUrls.js +13 -0
- package/lib/module/icon/dom.js +21 -0
- package/lib/module/icon/index.js +29 -0
- package/lib/module/icon/index.web.js +32 -0
- package/lib/module/icon/props.js +22 -0
- package/lib/module/package.json +6 -1
- package/lib/nitrogen/generated/android/c++/JHybridOneKeyIconSpec.cpp +67 -0
- package/lib/nitrogen/generated/android/c++/JHybridOneKeyIconSpec.hpp +66 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridOneKeyIconStateUpdater.cpp +79 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridOneKeyIconStateUpdater.hpp +54 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/onekeyimage/HybridOneKeyIconSpec.kt +65 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/onekeyimage/views/HybridOneKeyIconManager.kt +96 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/onekeyimage/views/HybridOneKeyIconStateUpdater.kt +23 -0
- package/lib/nitrogen/generated/android/onekeyimage+autolinking.cmake +4 -0
- package/lib/nitrogen/generated/android/onekeyimageOnLoad.cpp +18 -0
- package/lib/nitrogen/generated/ios/OneKeyImage-Swift-Cxx-Bridge.cpp +17 -0
- package/lib/nitrogen/generated/ios/OneKeyImage-Swift-Cxx-Bridge.hpp +32 -15
- package/lib/nitrogen/generated/ios/OneKeyImage-Swift-Cxx-Umbrella.hpp +5 -0
- package/lib/nitrogen/generated/ios/OneKeyImageAutolinking.mm +8 -0
- package/lib/nitrogen/generated/ios/OneKeyImageAutolinking.swift +12 -0
- package/lib/nitrogen/generated/ios/c++/HybridOneKeyIconSpecSwift.cpp +11 -0
- package/lib/nitrogen/generated/ios/c++/HybridOneKeyIconSpecSwift.hpp +89 -0
- package/lib/nitrogen/generated/ios/c++/views/HybridOneKeyIconComponent.mm +150 -0
- package/lib/nitrogen/generated/ios/swift/HybridOneKeyIconSpec.swift +56 -0
- package/lib/nitrogen/generated/ios/swift/HybridOneKeyIconSpec_cxx.swift +193 -0
- package/lib/nitrogen/generated/shared/c++/HybridOneKeyIconSpec.cpp +24 -0
- package/lib/nitrogen/generated/shared/c++/HybridOneKeyIconSpec.hpp +66 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridOneKeyIconComponent.cpp +36 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridOneKeyIconComponent.hpp +88 -0
- package/lib/nitrogen/generated/shared/json/OneKeyIconConfig.json +11 -0
- package/lib/typescript/src/OneKeyIcon.nitro.d.ts +7 -0
- package/lib/typescript/src/icon/assetUrls.d.ts +2 -0
- package/lib/typescript/src/icon/dom.d.ts +3 -0
- package/lib/typescript/src/icon/index.d.ts +12 -0
- package/lib/typescript/src/icon/index.web.d.ts +6 -0
- package/lib/typescript/src/icon/props.d.ts +8 -0
- package/lib/typescript/src/index.d.ts +1 -1
- package/nitro.json +10 -0
- package/nitrogen/generated/android/c++/JHybridOneKeyIconSpec.cpp +67 -0
- package/nitrogen/generated/android/c++/JHybridOneKeyIconSpec.hpp +66 -0
- package/nitrogen/generated/android/c++/views/JHybridOneKeyIconStateUpdater.cpp +79 -0
- package/nitrogen/generated/android/c++/views/JHybridOneKeyIconStateUpdater.hpp +54 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/onekeyimage/HybridOneKeyIconSpec.kt +65 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/onekeyimage/views/HybridOneKeyIconManager.kt +96 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/onekeyimage/views/HybridOneKeyIconStateUpdater.kt +23 -0
- package/nitrogen/generated/android/onekeyimage+autolinking.cmake +4 -0
- package/nitrogen/generated/android/onekeyimageOnLoad.cpp +18 -0
- package/nitrogen/generated/ios/OneKeyImage-Swift-Cxx-Bridge.cpp +17 -0
- package/nitrogen/generated/ios/OneKeyImage-Swift-Cxx-Bridge.hpp +32 -15
- package/nitrogen/generated/ios/OneKeyImage-Swift-Cxx-Umbrella.hpp +5 -0
- package/nitrogen/generated/ios/OneKeyImageAutolinking.mm +8 -0
- package/nitrogen/generated/ios/OneKeyImageAutolinking.swift +12 -0
- package/nitrogen/generated/ios/c++/HybridOneKeyIconSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridOneKeyIconSpecSwift.hpp +89 -0
- package/nitrogen/generated/ios/c++/views/HybridOneKeyIconComponent.mm +150 -0
- package/nitrogen/generated/ios/swift/HybridOneKeyIconSpec.swift +56 -0
- package/nitrogen/generated/ios/swift/HybridOneKeyIconSpec_cxx.swift +193 -0
- package/nitrogen/generated/shared/c++/HybridOneKeyIconSpec.cpp +24 -0
- package/nitrogen/generated/shared/c++/HybridOneKeyIconSpec.hpp +66 -0
- package/nitrogen/generated/shared/c++/views/HybridOneKeyIconComponent.cpp +36 -0
- package/nitrogen/generated/shared/c++/views/HybridOneKeyIconComponent.hpp +88 -0
- package/nitrogen/generated/shared/json/OneKeyIconConfig.json +11 -0
- package/package.json +47 -14
- package/scripts/configure-icon-imports.mjs +7 -0
- package/scripts/icon-fixtures.test.mjs +398 -0
- package/src/OneKeyIcon.nitro.ts +8 -0
- package/src/icon/assetUrls.ts +13 -0
- package/src/icon/dom.ts +21 -0
- package/src/icon/index.tsx +38 -0
- package/src/icon/index.web.tsx +36 -0
- package/src/icon/props.ts +38 -0
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
#include <fbjni/fbjni.h>
|
|
16
16
|
#include <NitroModules/HybridObjectRegistry.hpp>
|
|
17
17
|
|
|
18
|
+
#include "JHybridOneKeyIconSpec.hpp"
|
|
19
|
+
#include "views/JHybridOneKeyIconStateUpdater.hpp"
|
|
18
20
|
#include "JHybridOneKeyImageCacheSpec.hpp"
|
|
19
21
|
#include "JHybridOneKeyImageSpec.hpp"
|
|
20
22
|
#include "JFunc_void.hpp"
|
|
@@ -47,12 +49,22 @@ struct JHybridOneKeyImageCacheSpecImpl: public jni::JavaClass<JHybridOneKeyImage
|
|
|
47
49
|
return javaPart->getJHybridOneKeyImageCacheSpec();
|
|
48
50
|
}
|
|
49
51
|
};
|
|
52
|
+
struct JHybridOneKeyIconSpecImpl: public jni::JavaClass<JHybridOneKeyIconSpecImpl, JHybridOneKeyIconSpec::JavaPart> {
|
|
53
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/onekeyimage/HybridOneKeyIcon;";
|
|
54
|
+
static std::shared_ptr<JHybridOneKeyIconSpec> create() {
|
|
55
|
+
static const auto constructorFn = javaClassStatic()->getConstructor<JHybridOneKeyIconSpecImpl::javaobject()>();
|
|
56
|
+
jni::local_ref<JHybridOneKeyIconSpec::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn);
|
|
57
|
+
return javaPart->getJHybridOneKeyIconSpec();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
50
60
|
|
|
51
61
|
void registerAllNatives() {
|
|
52
62
|
using namespace margelo::nitro;
|
|
53
63
|
using namespace margelo::nitro::onekeyimage;
|
|
54
64
|
|
|
55
65
|
// Register native JNI methods
|
|
66
|
+
margelo::nitro::onekeyimage::JHybridOneKeyIconSpec::CxxPart::registerNatives();
|
|
67
|
+
margelo::nitro::onekeyimage::views::JHybridOneKeyIconStateUpdater::registerNatives();
|
|
56
68
|
margelo::nitro::onekeyimage::JHybridOneKeyImageCacheSpec::CxxPart::registerNatives();
|
|
57
69
|
margelo::nitro::onekeyimage::JHybridOneKeyImageSpec::CxxPart::registerNatives();
|
|
58
70
|
margelo::nitro::onekeyimage::JFunc_void_cxx::registerNatives();
|
|
@@ -73,6 +85,12 @@ void registerAllNatives() {
|
|
|
73
85
|
return JHybridOneKeyImageCacheSpecImpl::create();
|
|
74
86
|
}
|
|
75
87
|
);
|
|
88
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
89
|
+
"OneKeyIcon",
|
|
90
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
91
|
+
return JHybridOneKeyIconSpecImpl::create();
|
|
92
|
+
}
|
|
93
|
+
);
|
|
76
94
|
}
|
|
77
95
|
|
|
78
96
|
} // namespace margelo::nitro::onekeyimage
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
#include "OneKeyImage-Swift-Cxx-Bridge.hpp"
|
|
9
9
|
|
|
10
10
|
// Include C++ implementation defined types
|
|
11
|
+
#include "HybridOneKeyIconSpecSwift.hpp"
|
|
11
12
|
#include "HybridOneKeyImageCacheSpecSwift.hpp"
|
|
12
13
|
#include "HybridOneKeyImageSpecSwift.hpp"
|
|
13
14
|
#include "OneKeyImage-Swift-Cxx-Umbrella.hpp"
|
|
@@ -15,6 +16,22 @@
|
|
|
15
16
|
|
|
16
17
|
namespace margelo::nitro::onekeyimage::bridge::swift {
|
|
17
18
|
|
|
19
|
+
// pragma MARK: std::shared_ptr<HybridOneKeyIconSpec>
|
|
20
|
+
std::shared_ptr<HybridOneKeyIconSpec> create_std__shared_ptr_HybridOneKeyIconSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
|
|
21
|
+
OneKeyImage::HybridOneKeyIconSpec_cxx swiftPart = OneKeyImage::HybridOneKeyIconSpec_cxx::fromUnsafe(swiftUnsafePointer);
|
|
22
|
+
return std::make_shared<margelo::nitro::onekeyimage::HybridOneKeyIconSpecSwift>(swiftPart);
|
|
23
|
+
}
|
|
24
|
+
void* NON_NULL get_std__shared_ptr_HybridOneKeyIconSpec_(std__shared_ptr_HybridOneKeyIconSpec_ cppType) {
|
|
25
|
+
std::shared_ptr<margelo::nitro::onekeyimage::HybridOneKeyIconSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::onekeyimage::HybridOneKeyIconSpecSwift>(cppType);
|
|
26
|
+
#ifdef NITRO_DEBUG
|
|
27
|
+
if (swiftWrapper == nullptr) [[unlikely]] {
|
|
28
|
+
throw std::runtime_error("Class \"HybridOneKeyIconSpec\" is not implemented in Swift!");
|
|
29
|
+
}
|
|
30
|
+
#endif
|
|
31
|
+
OneKeyImage::HybridOneKeyIconSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
|
|
32
|
+
return swiftPart.toUnsafe();
|
|
33
|
+
}
|
|
34
|
+
|
|
18
35
|
// pragma MARK: std::function<void(bool /* result */)>
|
|
19
36
|
Func_void_bool create_Func_void_bool(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
20
37
|
auto swiftClosure = OneKeyImage::Func_void_bool::fromUnsafe(swiftClosureWrapper);
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
10
|
// Forward declarations of C++ defined types
|
|
11
|
+
// Forward declaration of `HybridOneKeyIconSpec` to properly resolve imports.
|
|
12
|
+
namespace margelo::nitro::onekeyimage { class HybridOneKeyIconSpec; }
|
|
11
13
|
// Forward declaration of `HybridOneKeyImageCacheSpec` to properly resolve imports.
|
|
12
14
|
namespace margelo::nitro::onekeyimage { class HybridOneKeyImageCacheSpec; }
|
|
13
15
|
// Forward declaration of `HybridOneKeyImageSpec` to properly resolve imports.
|
|
@@ -26,12 +28,15 @@ namespace margelo::nitro::onekeyimage { struct OneKeyImagePreloadSource; }
|
|
|
26
28
|
namespace margelo::nitro::onekeyimage { enum class OneKeyImageVariant; }
|
|
27
29
|
|
|
28
30
|
// Forward declarations of Swift defined types
|
|
31
|
+
// Forward declaration of `HybridOneKeyIconSpec_cxx` to properly resolve imports.
|
|
32
|
+
namespace OneKeyImage { class HybridOneKeyIconSpec_cxx; }
|
|
29
33
|
// Forward declaration of `HybridOneKeyImageCacheSpec_cxx` to properly resolve imports.
|
|
30
34
|
namespace OneKeyImage { class HybridOneKeyImageCacheSpec_cxx; }
|
|
31
35
|
// Forward declaration of `HybridOneKeyImageSpec_cxx` to properly resolve imports.
|
|
32
36
|
namespace OneKeyImage { class HybridOneKeyImageSpec_cxx; }
|
|
33
37
|
|
|
34
38
|
// Include C++ defined types
|
|
39
|
+
#include "HybridOneKeyIconSpec.hpp"
|
|
35
40
|
#include "HybridOneKeyImageCacheSpec.hpp"
|
|
36
41
|
#include "HybridOneKeyImageSpec.hpp"
|
|
37
42
|
#include "OneKeyImageCachePolicy.hpp"
|
|
@@ -56,6 +61,33 @@ namespace OneKeyImage { class HybridOneKeyImageSpec_cxx; }
|
|
|
56
61
|
*/
|
|
57
62
|
namespace margelo::nitro::onekeyimage::bridge::swift {
|
|
58
63
|
|
|
64
|
+
// pragma MARK: std::optional<std::string>
|
|
65
|
+
/**
|
|
66
|
+
* Specialized version of `std::optional<std::string>`.
|
|
67
|
+
*/
|
|
68
|
+
using std__optional_std__string_ = std::optional<std::string>;
|
|
69
|
+
inline std::optional<std::string> create_std__optional_std__string_(const std::string& value) noexcept {
|
|
70
|
+
return std::optional<std::string>(value);
|
|
71
|
+
}
|
|
72
|
+
inline bool has_value_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
|
|
73
|
+
return optional.has_value();
|
|
74
|
+
}
|
|
75
|
+
inline std::string get_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
|
|
76
|
+
return optional.value();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// pragma MARK: std::shared_ptr<HybridOneKeyIconSpec>
|
|
80
|
+
/**
|
|
81
|
+
* Specialized version of `std::shared_ptr<HybridOneKeyIconSpec>`.
|
|
82
|
+
*/
|
|
83
|
+
using std__shared_ptr_HybridOneKeyIconSpec_ = std::shared_ptr<HybridOneKeyIconSpec>;
|
|
84
|
+
std::shared_ptr<HybridOneKeyIconSpec> create_std__shared_ptr_HybridOneKeyIconSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
|
|
85
|
+
void* NON_NULL get_std__shared_ptr_HybridOneKeyIconSpec_(std__shared_ptr_HybridOneKeyIconSpec_ cppType);
|
|
86
|
+
|
|
87
|
+
// pragma MARK: std::weak_ptr<HybridOneKeyIconSpec>
|
|
88
|
+
using std__weak_ptr_HybridOneKeyIconSpec_ = std::weak_ptr<HybridOneKeyIconSpec>;
|
|
89
|
+
inline std__weak_ptr_HybridOneKeyIconSpec_ weakify_std__shared_ptr_HybridOneKeyIconSpec_(const std::shared_ptr<HybridOneKeyIconSpec>& strong) noexcept { return strong; }
|
|
90
|
+
|
|
59
91
|
// pragma MARK: std::shared_ptr<Promise<bool>>
|
|
60
92
|
/**
|
|
61
93
|
* Specialized version of `std::shared_ptr<Promise<bool>>`.
|
|
@@ -112,21 +144,6 @@ namespace margelo::nitro::onekeyimage::bridge::swift {
|
|
|
112
144
|
return Func_void_std__exception_ptr_Wrapper(std::move(value));
|
|
113
145
|
}
|
|
114
146
|
|
|
115
|
-
// pragma MARK: std::optional<std::string>
|
|
116
|
-
/**
|
|
117
|
-
* Specialized version of `std::optional<std::string>`.
|
|
118
|
-
*/
|
|
119
|
-
using std__optional_std__string_ = std::optional<std::string>;
|
|
120
|
-
inline std::optional<std::string> create_std__optional_std__string_(const std::string& value) noexcept {
|
|
121
|
-
return std::optional<std::string>(value);
|
|
122
|
-
}
|
|
123
|
-
inline bool has_value_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
|
|
124
|
-
return optional.has_value();
|
|
125
|
-
}
|
|
126
|
-
inline std::string get_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
|
|
127
|
-
return optional.value();
|
|
128
|
-
}
|
|
129
|
-
|
|
130
147
|
// pragma MARK: std::optional<OneKeyImageCachePolicy>
|
|
131
148
|
/**
|
|
132
149
|
* Specialized version of `std::optional<OneKeyImageCachePolicy>`.
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
10
|
// Forward declarations of C++ defined types
|
|
11
|
+
// Forward declaration of `HybridOneKeyIconSpec` to properly resolve imports.
|
|
12
|
+
namespace margelo::nitro::onekeyimage { class HybridOneKeyIconSpec; }
|
|
11
13
|
// Forward declaration of `HybridOneKeyImageCacheSpec` to properly resolve imports.
|
|
12
14
|
namespace margelo::nitro::onekeyimage { class HybridOneKeyImageCacheSpec; }
|
|
13
15
|
// Forward declaration of `HybridOneKeyImageSpec` to properly resolve imports.
|
|
@@ -26,6 +28,7 @@ namespace margelo::nitro::onekeyimage { struct OneKeyImagePreloadSource; }
|
|
|
26
28
|
namespace margelo::nitro::onekeyimage { enum class OneKeyImageVariant; }
|
|
27
29
|
|
|
28
30
|
// Include C++ defined types
|
|
31
|
+
#include "HybridOneKeyIconSpec.hpp"
|
|
29
32
|
#include "HybridOneKeyImageCacheSpec.hpp"
|
|
30
33
|
#include "HybridOneKeyImageSpec.hpp"
|
|
31
34
|
#include "OneKeyImageCachePolicy.hpp"
|
|
@@ -53,6 +56,8 @@ namespace margelo::nitro::onekeyimage { enum class OneKeyImageVariant; }
|
|
|
53
56
|
#include <NitroModules/DateToChronoDate.hpp>
|
|
54
57
|
|
|
55
58
|
// Forward declarations of Swift defined types
|
|
59
|
+
// Forward declaration of `HybridOneKeyIconSpec_cxx` to properly resolve imports.
|
|
60
|
+
namespace OneKeyImage { class HybridOneKeyIconSpec_cxx; }
|
|
56
61
|
// Forward declaration of `HybridOneKeyImageCacheSpec_cxx` to properly resolve imports.
|
|
57
62
|
namespace OneKeyImage { class HybridOneKeyImageCacheSpec_cxx; }
|
|
58
63
|
// Forward declaration of `HybridOneKeyImageSpec_cxx` to properly resolve imports.
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
#include "HybridOneKeyImageSpecSwift.hpp"
|
|
14
14
|
#include "HybridOneKeyImageCacheSpecSwift.hpp"
|
|
15
|
+
#include "HybridOneKeyIconSpecSwift.hpp"
|
|
15
16
|
|
|
16
17
|
@interface OneKeyImageAutolinking : NSObject
|
|
17
18
|
@end
|
|
@@ -36,6 +37,13 @@
|
|
|
36
37
|
return hybridObject;
|
|
37
38
|
}
|
|
38
39
|
);
|
|
40
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
41
|
+
"OneKeyIcon",
|
|
42
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
43
|
+
std::shared_ptr<HybridOneKeyIconSpec> hybridObject = OneKeyImage::OneKeyImageAutolinking::createOneKeyIcon();
|
|
44
|
+
return hybridObject;
|
|
45
|
+
}
|
|
46
|
+
);
|
|
39
47
|
}
|
|
40
48
|
|
|
41
49
|
@end
|
|
@@ -35,4 +35,16 @@ public final class OneKeyImageAutolinking {
|
|
|
35
35
|
public static func isOneKeyImageCacheRecyclable() -> Bool {
|
|
36
36
|
return HybridOneKeyImageCache.self is any RecyclableView.Type
|
|
37
37
|
}
|
|
38
|
+
|
|
39
|
+
public static func createOneKeyIcon() -> bridge.std__shared_ptr_HybridOneKeyIconSpec_ {
|
|
40
|
+
let hybridObject = HybridOneKeyIcon()
|
|
41
|
+
return { () -> bridge.std__shared_ptr_HybridOneKeyIconSpec_ in
|
|
42
|
+
let __cxxWrapped = hybridObject.getCxxWrapper()
|
|
43
|
+
return __cxxWrapped.getCxxPart()
|
|
44
|
+
}()
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public static func isOneKeyIconRecyclable() -> Bool {
|
|
48
|
+
return HybridOneKeyIcon.self is any RecyclableView.Type
|
|
49
|
+
}
|
|
38
50
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridOneKeyIconSpecSwift.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 "HybridOneKeyIconSpecSwift.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::onekeyimage {
|
|
11
|
+
} // namespace margelo::nitro::onekeyimage
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridOneKeyIconSpecSwift.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 "HybridOneKeyIconSpec.hpp"
|
|
11
|
+
|
|
12
|
+
// Forward declaration of `HybridOneKeyIconSpec_cxx` to properly resolve imports.
|
|
13
|
+
namespace OneKeyImage { class HybridOneKeyIconSpec_cxx; }
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
#include <string>
|
|
18
|
+
#include <optional>
|
|
19
|
+
|
|
20
|
+
#include "OneKeyImage-Swift-Cxx-Umbrella.hpp"
|
|
21
|
+
|
|
22
|
+
namespace margelo::nitro::onekeyimage {
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The C++ part of HybridOneKeyIconSpec_cxx.swift.
|
|
26
|
+
*
|
|
27
|
+
* HybridOneKeyIconSpecSwift (C++) accesses HybridOneKeyIconSpec_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, HybridOneKeyIconSpec_cxx can directly inherit from the C++ class HybridOneKeyIconSpec
|
|
32
|
+
* to simplify the whole structure and memory management.
|
|
33
|
+
*/
|
|
34
|
+
class HybridOneKeyIconSpecSwift: public virtual HybridOneKeyIconSpec {
|
|
35
|
+
public:
|
|
36
|
+
// Constructor from a Swift instance
|
|
37
|
+
explicit HybridOneKeyIconSpecSwift(const OneKeyImage::HybridOneKeyIconSpec_cxx& swiftPart):
|
|
38
|
+
HybridObject(HybridOneKeyIconSpec::TAG),
|
|
39
|
+
_swiftPart(swiftPart) { }
|
|
40
|
+
|
|
41
|
+
public:
|
|
42
|
+
// Get the Swift part
|
|
43
|
+
inline OneKeyImage::HybridOneKeyIconSpec_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<HybridOneKeyIconSpecSwift>(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::optional<std::string> getIconName() noexcept override {
|
|
67
|
+
auto __result = _swiftPart.getIconName();
|
|
68
|
+
return __result;
|
|
69
|
+
}
|
|
70
|
+
inline void setIconName(const std::optional<std::string>& iconName) noexcept override {
|
|
71
|
+
_swiftPart.setIconName(iconName);
|
|
72
|
+
}
|
|
73
|
+
inline std::optional<std::string> getResolvedColor() noexcept override {
|
|
74
|
+
auto __result = _swiftPart.getResolvedColor();
|
|
75
|
+
return __result;
|
|
76
|
+
}
|
|
77
|
+
inline void setResolvedColor(const std::optional<std::string>& resolvedColor) noexcept override {
|
|
78
|
+
_swiftPart.setResolvedColor(resolvedColor);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public:
|
|
82
|
+
// Methods
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
private:
|
|
86
|
+
OneKeyImage::HybridOneKeyIconSpec_cxx _swiftPart;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
} // namespace margelo::nitro::onekeyimage
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridOneKeyIconComponent.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 "HybridOneKeyIconComponent.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 "HybridOneKeyIconSpecSwift.hpp"
|
|
18
|
+
#import "OneKeyImage-Swift-Cxx-Umbrella.hpp"
|
|
19
|
+
|
|
20
|
+
#if __has_include(<cxxreact/ReactNativeVersion.h>)
|
|
21
|
+
#include <cxxreact/ReactNativeVersion.h>
|
|
22
|
+
#if REACT_NATIVE_VERSION_MINOR >= 82
|
|
23
|
+
#define ENABLE_RCT_COMPONENT_VIEW_INVALIDATE
|
|
24
|
+
#endif
|
|
25
|
+
#endif
|
|
26
|
+
|
|
27
|
+
using namespace facebook;
|
|
28
|
+
using namespace margelo::nitro::onekeyimage;
|
|
29
|
+
using namespace margelo::nitro::onekeyimage::views;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Represents the React Native View holder for the Nitro "OneKeyIcon" HybridView.
|
|
33
|
+
*/
|
|
34
|
+
@interface HybridOneKeyIconComponent: RCTViewComponentView
|
|
35
|
+
+ (BOOL)shouldBeRecycled;
|
|
36
|
+
@end
|
|
37
|
+
|
|
38
|
+
@implementation HybridOneKeyIconComponent {
|
|
39
|
+
std::shared_ptr<HybridOneKeyIconSpecSwift> _hybridView;
|
|
40
|
+
BOOL _didDropView;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
+ (void) load {
|
|
44
|
+
[super load];
|
|
45
|
+
[RCTComponentViewFactory.currentComponentViewFactory registerComponentViewClass:[HybridOneKeyIconComponent class]];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
+ (react::ComponentDescriptorProvider) componentDescriptorProvider {
|
|
49
|
+
return react::concreteComponentDescriptorProvider<HybridOneKeyIconComponentDescriptor>();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
- (instancetype) init {
|
|
53
|
+
if (self = [super init]) {
|
|
54
|
+
_props = HybridOneKeyIconShadowNode::defaultSharedProps();
|
|
55
|
+
std::shared_ptr<HybridOneKeyIconSpec> hybridView = OneKeyImage::OneKeyImageAutolinking::createOneKeyIcon();
|
|
56
|
+
_hybridView = std::dynamic_pointer_cast<HybridOneKeyIconSpecSwift>(hybridView);
|
|
57
|
+
[self updateView];
|
|
58
|
+
}
|
|
59
|
+
return self;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
- (void) updateView {
|
|
63
|
+
// 1. Get Swift part
|
|
64
|
+
OneKeyImage::HybridOneKeyIconSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
65
|
+
|
|
66
|
+
// 2. Get UIView*
|
|
67
|
+
void* viewUnsafe = swiftPart.getView();
|
|
68
|
+
UIView* view = (__bridge_transfer UIView*) viewUnsafe;
|
|
69
|
+
|
|
70
|
+
// 3. Update RCTViewComponentView's [contentView]
|
|
71
|
+
[self setContentView:view];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
- (void) notifyOnDropView {
|
|
75
|
+
// A recycled component can later be invalidated. Notify only once per mount.
|
|
76
|
+
if (_didDropView) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
OneKeyImage::HybridOneKeyIconSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
80
|
+
swiftPart.onDropView();
|
|
81
|
+
_didDropView = YES;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
- (void) updateProps:(const std::shared_ptr<const react::Props>&)props
|
|
85
|
+
oldProps:(const std::shared_ptr<const react::Props>&)oldProps {
|
|
86
|
+
// A props update marks a newly mounted or still-active component.
|
|
87
|
+
_didDropView = NO;
|
|
88
|
+
|
|
89
|
+
// 1. Downcast props
|
|
90
|
+
const auto& newViewProps = *std::static_pointer_cast<const HybridOneKeyIconProps>(props);
|
|
91
|
+
const auto* oldViewProps = static_cast<const HybridOneKeyIconProps*>(oldProps.get());
|
|
92
|
+
OneKeyImage::HybridOneKeyIconSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
93
|
+
|
|
94
|
+
// 2. Update only props that differ from the previous Props snapshot.
|
|
95
|
+
const bool hasTransactionPropChanges = oldViewProps == nullptr
|
|
96
|
+
? newViewProps.hasAnyProvidedProps()
|
|
97
|
+
: !newViewProps.hasSameProps(*oldViewProps);
|
|
98
|
+
if (hasTransactionPropChanges) {
|
|
99
|
+
swiftPart.beforeUpdate();
|
|
100
|
+
|
|
101
|
+
// iconName: optional
|
|
102
|
+
if (oldViewProps == nullptr
|
|
103
|
+
? newViewProps.iconName.isProvided()
|
|
104
|
+
: !newViewProps.iconName.hasSameValue(oldViewProps->iconName)) {
|
|
105
|
+
swiftPart.setIconName(newViewProps.iconName.get());
|
|
106
|
+
}
|
|
107
|
+
// resolvedColor: optional
|
|
108
|
+
if (oldViewProps == nullptr
|
|
109
|
+
? newViewProps.resolvedColor.isProvided()
|
|
110
|
+
: !newViewProps.resolvedColor.hasSameValue(oldViewProps->resolvedColor)) {
|
|
111
|
+
swiftPart.setResolvedColor(newViewProps.resolvedColor.get());
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Update hybridRef if it changed
|
|
115
|
+
if (oldViewProps == nullptr
|
|
116
|
+
? newViewProps.hybridRef.isProvided()
|
|
117
|
+
: !newViewProps.hybridRef.hasSameValue(oldViewProps->hybridRef)) {
|
|
118
|
+
// hybridRef changed - call it with new this
|
|
119
|
+
const auto& maybeFunc = newViewProps.hybridRef.get();
|
|
120
|
+
if (maybeFunc.has_value()) {
|
|
121
|
+
maybeFunc.value()(_hybridView);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
swiftPart.afterUpdate();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// 3. Continue in base class
|
|
129
|
+
[super updateProps:props oldProps:oldProps];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
+ (BOOL)shouldBeRecycled {
|
|
133
|
+
return OneKeyImage::OneKeyImageAutolinking::isOneKeyIconRecyclable();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
- (void)prepareForRecycle {
|
|
137
|
+
[self notifyOnDropView];
|
|
138
|
+
[super prepareForRecycle];
|
|
139
|
+
OneKeyImage::HybridOneKeyIconSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
140
|
+
swiftPart.maybePrepareForRecycle();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
#ifdef ENABLE_RCT_COMPONENT_VIEW_INVALIDATE
|
|
144
|
+
- (void)invalidate {
|
|
145
|
+
[self notifyOnDropView];
|
|
146
|
+
[super invalidate];
|
|
147
|
+
}
|
|
148
|
+
#endif
|
|
149
|
+
|
|
150
|
+
@end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridOneKeyIconSpec.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 ``HybridOneKeyIconSpec``
|
|
11
|
+
public protocol HybridOneKeyIconSpec_protocol: HybridObject, HybridView {
|
|
12
|
+
// Properties
|
|
13
|
+
var iconName: String? { get set }
|
|
14
|
+
var resolvedColor: String? { get set }
|
|
15
|
+
|
|
16
|
+
// Methods
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public extension HybridOneKeyIconSpec_protocol {
|
|
21
|
+
/// Default implementation of ``HybridObject.toString``
|
|
22
|
+
func toString() -> String {
|
|
23
|
+
return "[HybridObject OneKeyIcon]"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/// See ``HybridOneKeyIconSpec``
|
|
28
|
+
open class HybridOneKeyIconSpec_base {
|
|
29
|
+
private weak var cxxWrapper: HybridOneKeyIconSpec_cxx? = nil
|
|
30
|
+
public init() { }
|
|
31
|
+
public func getCxxWrapper() -> HybridOneKeyIconSpec_cxx {
|
|
32
|
+
#if DEBUG
|
|
33
|
+
guard self is any HybridOneKeyIconSpec else {
|
|
34
|
+
fatalError("`self` is not a `HybridOneKeyIconSpec`! Did you accidentally inherit from `HybridOneKeyIconSpec_base` instead of `HybridOneKeyIconSpec`?")
|
|
35
|
+
}
|
|
36
|
+
#endif
|
|
37
|
+
if let cxxWrapper = self.cxxWrapper {
|
|
38
|
+
return cxxWrapper
|
|
39
|
+
} else {
|
|
40
|
+
let cxxWrapper = HybridOneKeyIconSpec_cxx(self as! any HybridOneKeyIconSpec)
|
|
41
|
+
self.cxxWrapper = cxxWrapper
|
|
42
|
+
return cxxWrapper
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* A Swift base-protocol representing the OneKeyIcon HybridObject.
|
|
49
|
+
* Implement this protocol to create Swift-based instances of OneKeyIcon.
|
|
50
|
+
* ```swift
|
|
51
|
+
* class HybridOneKeyIcon : HybridOneKeyIconSpec {
|
|
52
|
+
* // ...
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
public typealias HybridOneKeyIconSpec = HybridOneKeyIconSpec_protocol & HybridOneKeyIconSpec_base
|