@onekeyfe/react-native-image 6.7.0-alpha.409 → 6.7.0-alpha.412

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 (83) hide show
  1. package/README.md +12 -0
  2. package/android/build.gradle +3 -1
  3. package/android/src/main/java/com/margelo/nitro/onekeyimage/OneKeyIcon.kt +93 -0
  4. package/android/src/main/java/com/margelo/nitro/onekeyimage/OneKeyImageGlideRegistry.kt +1 -1
  5. package/android/src/main/java/com/margelo/nitro/onekeyimage/OneKeyImagePackage.kt +2 -1
  6. package/android/src/main/java/com/margelo/nitro/onekeyimage/OneKeyNamedSVG.kt +217 -0
  7. package/android/src/main/java/com/margelo/nitro/onekeyimage/OneKeySVG.kt +31 -0
  8. package/ios/OneKeyIcon.swift +90 -0
  9. package/ios/OneKeyImageCoderBridge.h +4 -0
  10. package/ios/OneKeyImageCoderBridge.m +9 -0
  11. package/ios/OneKeyNamedSVG.swift +282 -0
  12. package/ios/tests/OneKeyIconTests.swift +484 -0
  13. package/lib/module/OneKeyIcon.nitro.js +4 -0
  14. package/lib/module/icon/assetUrls.js +7 -0
  15. package/lib/module/icon/dom.js +21 -0
  16. package/lib/module/icon/index.js +29 -0
  17. package/lib/module/icon/index.web.js +32 -0
  18. package/lib/module/icon/props.js +22 -0
  19. package/lib/module/package.json +6 -1
  20. package/lib/nitrogen/generated/android/c++/JHybridOneKeyIconSpec.cpp +67 -0
  21. package/lib/nitrogen/generated/android/c++/JHybridOneKeyIconSpec.hpp +66 -0
  22. package/lib/nitrogen/generated/android/c++/views/JHybridOneKeyIconStateUpdater.cpp +79 -0
  23. package/lib/nitrogen/generated/android/c++/views/JHybridOneKeyIconStateUpdater.hpp +54 -0
  24. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/onekeyimage/HybridOneKeyIconSpec.kt +65 -0
  25. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/onekeyimage/views/HybridOneKeyIconManager.kt +96 -0
  26. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/onekeyimage/views/HybridOneKeyIconStateUpdater.kt +23 -0
  27. package/lib/nitrogen/generated/android/onekeyimage+autolinking.cmake +4 -0
  28. package/lib/nitrogen/generated/android/onekeyimageOnLoad.cpp +18 -0
  29. package/lib/nitrogen/generated/ios/OneKeyImage-Swift-Cxx-Bridge.cpp +17 -0
  30. package/lib/nitrogen/generated/ios/OneKeyImage-Swift-Cxx-Bridge.hpp +32 -15
  31. package/lib/nitrogen/generated/ios/OneKeyImage-Swift-Cxx-Umbrella.hpp +5 -0
  32. package/lib/nitrogen/generated/ios/OneKeyImageAutolinking.mm +8 -0
  33. package/lib/nitrogen/generated/ios/OneKeyImageAutolinking.swift +12 -0
  34. package/lib/nitrogen/generated/ios/c++/HybridOneKeyIconSpecSwift.cpp +11 -0
  35. package/lib/nitrogen/generated/ios/c++/HybridOneKeyIconSpecSwift.hpp +89 -0
  36. package/lib/nitrogen/generated/ios/c++/views/HybridOneKeyIconComponent.mm +150 -0
  37. package/lib/nitrogen/generated/ios/swift/HybridOneKeyIconSpec.swift +56 -0
  38. package/lib/nitrogen/generated/ios/swift/HybridOneKeyIconSpec_cxx.swift +193 -0
  39. package/lib/nitrogen/generated/shared/c++/HybridOneKeyIconSpec.cpp +24 -0
  40. package/lib/nitrogen/generated/shared/c++/HybridOneKeyIconSpec.hpp +66 -0
  41. package/lib/nitrogen/generated/shared/c++/views/HybridOneKeyIconComponent.cpp +36 -0
  42. package/lib/nitrogen/generated/shared/c++/views/HybridOneKeyIconComponent.hpp +88 -0
  43. package/lib/nitrogen/generated/shared/json/OneKeyIconConfig.json +11 -0
  44. package/lib/typescript/src/OneKeyIcon.nitro.d.ts +7 -0
  45. package/lib/typescript/src/icon/assetUrls.d.ts +2 -0
  46. package/lib/typescript/src/icon/dom.d.ts +3 -0
  47. package/lib/typescript/src/icon/index.d.ts +140 -0
  48. package/lib/typescript/src/icon/index.web.d.ts +134 -0
  49. package/lib/typescript/src/icon/props.d.ts +8 -0
  50. package/nitro.json +10 -0
  51. package/nitrogen/generated/android/c++/JHybridOneKeyIconSpec.cpp +67 -0
  52. package/nitrogen/generated/android/c++/JHybridOneKeyIconSpec.hpp +66 -0
  53. package/nitrogen/generated/android/c++/views/JHybridOneKeyIconStateUpdater.cpp +79 -0
  54. package/nitrogen/generated/android/c++/views/JHybridOneKeyIconStateUpdater.hpp +54 -0
  55. package/nitrogen/generated/android/kotlin/com/margelo/nitro/onekeyimage/HybridOneKeyIconSpec.kt +65 -0
  56. package/nitrogen/generated/android/kotlin/com/margelo/nitro/onekeyimage/views/HybridOneKeyIconManager.kt +96 -0
  57. package/nitrogen/generated/android/kotlin/com/margelo/nitro/onekeyimage/views/HybridOneKeyIconStateUpdater.kt +23 -0
  58. package/nitrogen/generated/android/onekeyimage+autolinking.cmake +4 -0
  59. package/nitrogen/generated/android/onekeyimageOnLoad.cpp +18 -0
  60. package/nitrogen/generated/ios/OneKeyImage-Swift-Cxx-Bridge.cpp +17 -0
  61. package/nitrogen/generated/ios/OneKeyImage-Swift-Cxx-Bridge.hpp +32 -15
  62. package/nitrogen/generated/ios/OneKeyImage-Swift-Cxx-Umbrella.hpp +5 -0
  63. package/nitrogen/generated/ios/OneKeyImageAutolinking.mm +8 -0
  64. package/nitrogen/generated/ios/OneKeyImageAutolinking.swift +12 -0
  65. package/nitrogen/generated/ios/c++/HybridOneKeyIconSpecSwift.cpp +11 -0
  66. package/nitrogen/generated/ios/c++/HybridOneKeyIconSpecSwift.hpp +89 -0
  67. package/nitrogen/generated/ios/c++/views/HybridOneKeyIconComponent.mm +150 -0
  68. package/nitrogen/generated/ios/swift/HybridOneKeyIconSpec.swift +56 -0
  69. package/nitrogen/generated/ios/swift/HybridOneKeyIconSpec_cxx.swift +193 -0
  70. package/nitrogen/generated/shared/c++/HybridOneKeyIconSpec.cpp +24 -0
  71. package/nitrogen/generated/shared/c++/HybridOneKeyIconSpec.hpp +66 -0
  72. package/nitrogen/generated/shared/c++/views/HybridOneKeyIconComponent.cpp +36 -0
  73. package/nitrogen/generated/shared/c++/views/HybridOneKeyIconComponent.hpp +88 -0
  74. package/nitrogen/generated/shared/json/OneKeyIconConfig.json +11 -0
  75. package/package.json +40 -7
  76. package/scripts/configure-icon-imports.mjs +7 -0
  77. package/scripts/icon-fixtures.test.mjs +398 -0
  78. package/src/OneKeyIcon.nitro.ts +8 -0
  79. package/src/icon/assetUrls.ts +4 -0
  80. package/src/icon/dom.ts +21 -0
  81. package/src/icon/index.tsx +38 -0
  82. package/src/icon/index.web.tsx +36 -0
  83. package/src/icon/props.ts +38 -0
@@ -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
@@ -0,0 +1,193 @@
1
+ ///
2
+ /// HybridOneKeyIconSpec_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 HybridOneKeyIconSpec 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 HybridOneKeyIconSpec_cxx {
20
+ /**
21
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::onekeyimage::bridge::swift`)
22
+ * from `OneKeyImage-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.onekeyimage.bridge.swift
26
+
27
+ /**
28
+ * Holds an instance of the `HybridOneKeyIconSpec` Swift protocol.
29
+ */
30
+ private var __implementation: any HybridOneKeyIconSpec
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_HybridOneKeyIconSpec_
36
+
37
+ /**
38
+ * Create a new `HybridOneKeyIconSpec_cxx` that wraps the given `HybridOneKeyIconSpec`.
39
+ * All properties and methods bridge to C++ types.
40
+ */
41
+ public init(_ implementation: any HybridOneKeyIconSpec) {
42
+ self.__implementation = implementation
43
+ self.__cxxPart = .init()
44
+ /* no base class */
45
+ }
46
+
47
+ /**
48
+ * Get the actual `HybridOneKeyIconSpec` instance this class wraps.
49
+ */
50
+ @inline(__always)
51
+ public func getHybridOneKeyIconSpec() -> any HybridOneKeyIconSpec {
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 `HybridOneKeyIconSpec_cxx`.
65
+ * The pointer has to be a retained opaque `Unmanaged<HybridOneKeyIconSpec_cxx>`.
66
+ * This removes one strong reference from the object!
67
+ */
68
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridOneKeyIconSpec_cxx {
69
+ return Unmanaged<HybridOneKeyIconSpec_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<HybridOneKeyIconSpec>`.
75
+ */
76
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridOneKeyIconSpec_ {
77
+ let cachedCxxPart = self.__cxxPart.lock()
78
+ if Bool(fromCxx: cachedCxxPart) {
79
+ return cachedCxxPart
80
+ } else {
81
+ let newCxxPart = bridge.create_std__shared_ptr_HybridOneKeyIconSpec_(self.toUnsafe())
82
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridOneKeyIconSpec_(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: HybridOneKeyIconSpec_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 iconName: bridge.std__optional_std__string_ {
125
+ @inline(__always)
126
+ get {
127
+ return { () -> bridge.std__optional_std__string_ in
128
+ if let __unwrappedValue = self.__implementation.iconName {
129
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
130
+ } else {
131
+ return .init()
132
+ }
133
+ }()
134
+ }
135
+ @inline(__always)
136
+ set {
137
+ self.__implementation.iconName = { () -> String? in
138
+ if bridge.has_value_std__optional_std__string_(newValue) {
139
+ let __unwrapped = bridge.get_std__optional_std__string_(newValue)
140
+ return String(__unwrapped)
141
+ } else {
142
+ return nil
143
+ }
144
+ }()
145
+ }
146
+ }
147
+
148
+ public final var resolvedColor: bridge.std__optional_std__string_ {
149
+ @inline(__always)
150
+ get {
151
+ return { () -> bridge.std__optional_std__string_ in
152
+ if let __unwrappedValue = self.__implementation.resolvedColor {
153
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
154
+ } else {
155
+ return .init()
156
+ }
157
+ }()
158
+ }
159
+ @inline(__always)
160
+ set {
161
+ self.__implementation.resolvedColor = { () -> String? in
162
+ if bridge.has_value_std__optional_std__string_(newValue) {
163
+ let __unwrapped = bridge.get_std__optional_std__string_(newValue)
164
+ return String(__unwrapped)
165
+ } else {
166
+ return nil
167
+ }
168
+ }()
169
+ }
170
+ }
171
+
172
+ // Methods
173
+ public final func getView() -> UnsafeMutableRawPointer {
174
+ return Unmanaged.passRetained(__implementation.view).toOpaque()
175
+ }
176
+
177
+ public final func beforeUpdate() {
178
+ __implementation.beforeUpdate()
179
+ }
180
+
181
+ public final func afterUpdate() {
182
+ __implementation.afterUpdate()
183
+ }
184
+
185
+ public final func maybePrepareForRecycle() {
186
+ guard let recyclable = __implementation as? any RecyclableView else { return }
187
+ recyclable.prepareForRecycle()
188
+ }
189
+
190
+ public final func onDropView() {
191
+ __implementation.onDropView()
192
+ }
193
+ }
@@ -0,0 +1,24 @@
1
+ ///
2
+ /// HybridOneKeyIconSpec.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 "HybridOneKeyIconSpec.hpp"
9
+
10
+ namespace margelo::nitro::onekeyimage {
11
+
12
+ void HybridOneKeyIconSpec::loadHybridMethods() {
13
+ // load base methods/properties
14
+ HybridObject::loadHybridMethods();
15
+ // load custom methods/properties
16
+ registerHybrids(this, [](Prototype& prototype) {
17
+ prototype.registerHybridGetter("iconName", &HybridOneKeyIconSpec::getIconName);
18
+ prototype.registerHybridSetter("iconName", &HybridOneKeyIconSpec::setIconName);
19
+ prototype.registerHybridGetter("resolvedColor", &HybridOneKeyIconSpec::getResolvedColor);
20
+ prototype.registerHybridSetter("resolvedColor", &HybridOneKeyIconSpec::setResolvedColor);
21
+ });
22
+ }
23
+
24
+ } // namespace margelo::nitro::onekeyimage
@@ -0,0 +1,66 @@
1
+ ///
2
+ /// HybridOneKeyIconSpec.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::onekeyimage {
22
+
23
+ using namespace margelo::nitro;
24
+
25
+ /**
26
+ * An abstract base class for `OneKeyIcon`
27
+ * Inherit this class to create instances of `HybridOneKeyIconSpec` in C++.
28
+ * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
29
+ * @example
30
+ * ```cpp
31
+ * class HybridOneKeyIcon: public HybridOneKeyIconSpec {
32
+ * public:
33
+ * HybridOneKeyIcon(...): HybridObject(TAG) { ... }
34
+ * // ...
35
+ * };
36
+ * ```
37
+ */
38
+ class HybridOneKeyIconSpec: public virtual HybridObject {
39
+ public:
40
+ // Constructor
41
+ explicit HybridOneKeyIconSpec(): HybridObject(TAG) { }
42
+
43
+ // Destructor
44
+ ~HybridOneKeyIconSpec() override = default;
45
+
46
+ public:
47
+ // Properties
48
+ virtual std::optional<std::string> getIconName() = 0;
49
+ virtual void setIconName(const std::optional<std::string>& iconName) = 0;
50
+ virtual std::optional<std::string> getResolvedColor() = 0;
51
+ virtual void setResolvedColor(const std::optional<std::string>& resolvedColor) = 0;
52
+
53
+ public:
54
+ // Methods
55
+
56
+
57
+ protected:
58
+ // Hybrid Setup
59
+ void loadHybridMethods() override;
60
+
61
+ protected:
62
+ // Tag for logging
63
+ static constexpr auto TAG = "OneKeyIcon";
64
+ };
65
+
66
+ } // namespace margelo::nitro::onekeyimage
@@ -0,0 +1,36 @@
1
+ ///
2
+ /// HybridOneKeyIconComponent.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 "HybridOneKeyIconComponent.hpp"
9
+
10
+ #include <NitroModules/NitroHash.hpp>
11
+ #include <NitroModules/ReactProp.hpp>
12
+
13
+ namespace margelo::nitro::onekeyimage::views {
14
+
15
+ using namespace facebook;
16
+
17
+ extern const char HybridOneKeyIconComponentName[] = "OneKeyIcon";
18
+
19
+ HybridOneKeyIconProps::HybridOneKeyIconProps(const react::PropsParserContext& context,
20
+ const HybridOneKeyIconProps& sourceProps,
21
+ const react::RawProps& rawProps):
22
+ react::ViewProps(context, sourceProps, rawProps, filterObjectKeys),
23
+ iconName(nitro::ReactProp<std::optional<std::string>>::fromRawValue("OneKeyIcon", "iconName", rawProps, sourceProps.iconName)),
24
+ resolvedColor(nitro::ReactProp<std::optional<std::string>>::fromRawValue("OneKeyIcon", "resolvedColor", rawProps, sourceProps.resolvedColor)),
25
+ hybridRef(nitro::ReactProp<std::optional<std::function<void(const std::shared_ptr<HybridOneKeyIconSpec>& /* ref */)>>>::fromRawValue("OneKeyIcon", "hybridRef", rawProps, sourceProps.hybridRef)) { }
26
+
27
+ bool HybridOneKeyIconProps::filterObjectKeys(const std::string& propName) {
28
+ switch (hashString(propName)) {
29
+ case hashString("iconName"): return true;
30
+ case hashString("resolvedColor"): return true;
31
+ case hashString("hybridRef"): return true;
32
+ default: return false;
33
+ }
34
+ }
35
+
36
+ } // namespace margelo::nitro::onekeyimage::views