@matiks/rn-stroke-text 0.0.1

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 (62) hide show
  1. package/NitroRnStrokeText.podspec +31 -0
  2. package/README.md +38 -0
  3. package/android/CMakeLists.txt +29 -0
  4. package/android/build.gradle +138 -0
  5. package/android/fix-prefab.gradle +51 -0
  6. package/android/gradle.properties +5 -0
  7. package/android/src/main/AndroidManifest.xml +2 -0
  8. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  9. package/android/src/main/java/com/margelo/nitro/rnstroketext/FontUtil.kt +48 -0
  10. package/android/src/main/java/com/margelo/nitro/rnstroketext/HybridMatiksStrokeText.kt +80 -0
  11. package/android/src/main/java/com/margelo/nitro/rnstroketext/NitroRnStrokeTextPackage.kt +28 -0
  12. package/android/src/main/java/com/margelo/nitro/rnstroketext/StrokeTextView.kt +348 -0
  13. package/ios/Bridge.h +8 -0
  14. package/ios/HybridMatiksStrokeText.swift +97 -0
  15. package/ios/StrokeTextView.swift +174 -0
  16. package/ios/StrokedTextLabel.swift +62 -0
  17. package/lib/index.d.ts +10 -0
  18. package/lib/index.js +23 -0
  19. package/lib/specs/Stroke.nitro.d.ts +23 -0
  20. package/lib/specs/Stroke.nitro.js +1 -0
  21. package/nitro.json +24 -0
  22. package/nitrogen/generated/.gitattributes +1 -0
  23. package/nitrogen/generated/android/NitroRnStrokeText+autolinking.cmake +83 -0
  24. package/nitrogen/generated/android/NitroRnStrokeText+autolinking.gradle +27 -0
  25. package/nitrogen/generated/android/NitroRnStrokeTextOnLoad.cpp +46 -0
  26. package/nitrogen/generated/android/NitroRnStrokeTextOnLoad.hpp +25 -0
  27. package/nitrogen/generated/android/c++/JDimensions.hpp +61 -0
  28. package/nitrogen/generated/android/c++/JHybridMatiksStrokeTextSpec.cpp +156 -0
  29. package/nitrogen/generated/android/c++/JHybridMatiksStrokeTextSpec.hpp +85 -0
  30. package/nitrogen/generated/android/c++/JTextAlign.hpp +61 -0
  31. package/nitrogen/generated/android/c++/views/JHybridMatiksStrokeTextStateUpdater.cpp +92 -0
  32. package/nitrogen/generated/android/c++/views/JHybridMatiksStrokeTextStateUpdater.hpp +49 -0
  33. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnstroketext/Dimensions.kt +41 -0
  34. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnstroketext/HybridMatiksStrokeTextSpec.kt +115 -0
  35. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnstroketext/NitroRnStrokeTextOnLoad.kt +35 -0
  36. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnstroketext/TextAlign.kt +24 -0
  37. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnstroketext/views/HybridMatiksStrokeTextManager.kt +56 -0
  38. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnstroketext/views/HybridMatiksStrokeTextStateUpdater.kt +23 -0
  39. package/nitrogen/generated/ios/NitroRnStrokeText+autolinking.rb +60 -0
  40. package/nitrogen/generated/ios/NitroRnStrokeText-Swift-Cxx-Bridge.cpp +33 -0
  41. package/nitrogen/generated/ios/NitroRnStrokeText-Swift-Cxx-Bridge.hpp +119 -0
  42. package/nitrogen/generated/ios/NitroRnStrokeText-Swift-Cxx-Umbrella.hpp +51 -0
  43. package/nitrogen/generated/ios/NitroRnStrokeTextAutolinking.mm +33 -0
  44. package/nitrogen/generated/ios/NitroRnStrokeTextAutolinking.swift +25 -0
  45. package/nitrogen/generated/ios/c++/HybridMatiksStrokeTextSpecSwift.cpp +11 -0
  46. package/nitrogen/generated/ios/c++/HybridMatiksStrokeTextSpecSwift.hpp +157 -0
  47. package/nitrogen/generated/ios/c++/views/HybridMatiksStrokeTextComponent.mm +147 -0
  48. package/nitrogen/generated/ios/swift/Dimensions.swift +35 -0
  49. package/nitrogen/generated/ios/swift/HybridMatiksStrokeTextSpec.swift +65 -0
  50. package/nitrogen/generated/ios/swift/HybridMatiksStrokeTextSpec_cxx.swift +341 -0
  51. package/nitrogen/generated/ios/swift/TextAlign.swift +44 -0
  52. package/nitrogen/generated/shared/c++/Dimensions.hpp +87 -0
  53. package/nitrogen/generated/shared/c++/HybridMatiksStrokeTextSpec.cpp +41 -0
  54. package/nitrogen/generated/shared/c++/HybridMatiksStrokeTextSpec.hpp +87 -0
  55. package/nitrogen/generated/shared/c++/TextAlign.hpp +80 -0
  56. package/nitrogen/generated/shared/c++/views/HybridMatiksStrokeTextComponent.cpp +196 -0
  57. package/nitrogen/generated/shared/c++/views/HybridMatiksStrokeTextComponent.hpp +118 -0
  58. package/nitrogen/generated/shared/json/MatiksStrokeTextConfig.json +19 -0
  59. package/package.json +107 -0
  60. package/react-native.config.js +16 -0
  61. package/src/index.tsx +44 -0
  62. package/src/specs/Stroke.nitro.ts +34 -0
@@ -0,0 +1,341 @@
1
+ ///
2
+ /// HybridMatiksStrokeTextSpec_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 Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * A class implementation that bridges HybridMatiksStrokeTextSpec over to C++.
13
+ * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
14
+ *
15
+ * Also, some Swift types need to be bridged with special handling:
16
+ * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
17
+ * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
18
+ * - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
19
+ */
20
+ open class HybridMatiksStrokeTextSpec_cxx {
21
+ /**
22
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::rnstroketext::bridge::swift`)
23
+ * from `NitroRnStrokeText-Swift-Cxx-Bridge.hpp`.
24
+ * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
25
+ */
26
+ public typealias bridge = margelo.nitro.rnstroketext.bridge.swift
27
+
28
+ /**
29
+ * Holds an instance of the `HybridMatiksStrokeTextSpec` Swift protocol.
30
+ */
31
+ private var __implementation: any HybridMatiksStrokeTextSpec
32
+
33
+ /**
34
+ * Holds a weak pointer to the C++ class that wraps the Swift class.
35
+ */
36
+ private var __cxxPart: bridge.std__weak_ptr_HybridMatiksStrokeTextSpec_
37
+
38
+ /**
39
+ * Create a new `HybridMatiksStrokeTextSpec_cxx` that wraps the given `HybridMatiksStrokeTextSpec`.
40
+ * All properties and methods bridge to C++ types.
41
+ */
42
+ public init(_ implementation: any HybridMatiksStrokeTextSpec) {
43
+ self.__implementation = implementation
44
+ self.__cxxPart = .init()
45
+ /* no base class */
46
+ }
47
+
48
+ /**
49
+ * Get the actual `HybridMatiksStrokeTextSpec` instance this class wraps.
50
+ */
51
+ @inline(__always)
52
+ public func getHybridMatiksStrokeTextSpec() -> any HybridMatiksStrokeTextSpec {
53
+ return __implementation
54
+ }
55
+
56
+ /**
57
+ * Casts this instance to a retained unsafe raw pointer.
58
+ * This acquires one additional strong reference on the object!
59
+ */
60
+ public func toUnsafe() -> UnsafeMutableRawPointer {
61
+ return Unmanaged.passRetained(self).toOpaque()
62
+ }
63
+
64
+ /**
65
+ * Casts an unsafe pointer to a `HybridMatiksStrokeTextSpec_cxx`.
66
+ * The pointer has to be a retained opaque `Unmanaged<HybridMatiksStrokeTextSpec_cxx>`.
67
+ * This removes one strong reference from the object!
68
+ */
69
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridMatiksStrokeTextSpec_cxx {
70
+ return Unmanaged<HybridMatiksStrokeTextSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
71
+ }
72
+
73
+ /**
74
+ * Gets (or creates) the C++ part of this Hybrid Object.
75
+ * The C++ part is a `std::shared_ptr<HybridMatiksStrokeTextSpec>`.
76
+ */
77
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridMatiksStrokeTextSpec_ {
78
+ let cachedCxxPart = self.__cxxPart.lock()
79
+ if Bool(fromCxx: cachedCxxPart) {
80
+ return cachedCxxPart
81
+ } else {
82
+ let newCxxPart = bridge.create_std__shared_ptr_HybridMatiksStrokeTextSpec_(self.toUnsafe())
83
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridMatiksStrokeTextSpec_(newCxxPart)
84
+ return newCxxPart
85
+ }
86
+ }
87
+
88
+
89
+
90
+ /**
91
+ * Get the memory size of the Swift class (plus size of any other allocations)
92
+ * so the JS VM can properly track it and garbage-collect the JS object if needed.
93
+ */
94
+ @inline(__always)
95
+ public var memorySize: Int {
96
+ return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
97
+ }
98
+
99
+ /**
100
+ * Compares this object with the given [other] object for reference equality.
101
+ */
102
+ @inline(__always)
103
+ public func equals(other: HybridMatiksStrokeTextSpec_cxx) -> Bool {
104
+ return self.__implementation === other.__implementation
105
+ }
106
+
107
+ /**
108
+ * Call dispose() on the Swift class.
109
+ * This _may_ be called manually from JS.
110
+ */
111
+ @inline(__always)
112
+ public func dispose() {
113
+ self.__implementation.dispose()
114
+ }
115
+
116
+ /**
117
+ * Call toString() on the Swift class.
118
+ */
119
+ @inline(__always)
120
+ public func toString() -> String {
121
+ return self.__implementation.toString()
122
+ }
123
+
124
+ // Properties
125
+ public final var width: bridge.std__optional_double_ {
126
+ @inline(__always)
127
+ get {
128
+ return { () -> bridge.std__optional_double_ in
129
+ if let __unwrappedValue = self.__implementation.width {
130
+ return bridge.create_std__optional_double_(__unwrappedValue)
131
+ } else {
132
+ return .init()
133
+ }
134
+ }()
135
+ }
136
+ @inline(__always)
137
+ set {
138
+ self.__implementation.width = newValue.value
139
+ }
140
+ }
141
+
142
+ public final var text: std.string {
143
+ @inline(__always)
144
+ get {
145
+ return std.string(self.__implementation.text)
146
+ }
147
+ @inline(__always)
148
+ set {
149
+ self.__implementation.text = String(newValue)
150
+ }
151
+ }
152
+
153
+ public final var fontSize: bridge.std__optional_double_ {
154
+ @inline(__always)
155
+ get {
156
+ return { () -> bridge.std__optional_double_ in
157
+ if let __unwrappedValue = self.__implementation.fontSize {
158
+ return bridge.create_std__optional_double_(__unwrappedValue)
159
+ } else {
160
+ return .init()
161
+ }
162
+ }()
163
+ }
164
+ @inline(__always)
165
+ set {
166
+ self.__implementation.fontSize = newValue.value
167
+ }
168
+ }
169
+
170
+ public final var color: bridge.std__optional_std__string_ {
171
+ @inline(__always)
172
+ get {
173
+ return { () -> bridge.std__optional_std__string_ in
174
+ if let __unwrappedValue = self.__implementation.color {
175
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
176
+ } else {
177
+ return .init()
178
+ }
179
+ }()
180
+ }
181
+ @inline(__always)
182
+ set {
183
+ self.__implementation.color = { () -> String? in
184
+ if bridge.has_value_std__optional_std__string_(newValue) {
185
+ let __unwrapped = bridge.get_std__optional_std__string_(newValue)
186
+ return String(__unwrapped)
187
+ } else {
188
+ return nil
189
+ }
190
+ }()
191
+ }
192
+ }
193
+
194
+ public final var strokeColor: bridge.std__optional_std__string_ {
195
+ @inline(__always)
196
+ get {
197
+ return { () -> bridge.std__optional_std__string_ in
198
+ if let __unwrappedValue = self.__implementation.strokeColor {
199
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
200
+ } else {
201
+ return .init()
202
+ }
203
+ }()
204
+ }
205
+ @inline(__always)
206
+ set {
207
+ self.__implementation.strokeColor = { () -> String? in
208
+ if bridge.has_value_std__optional_std__string_(newValue) {
209
+ let __unwrapped = bridge.get_std__optional_std__string_(newValue)
210
+ return String(__unwrapped)
211
+ } else {
212
+ return nil
213
+ }
214
+ }()
215
+ }
216
+ }
217
+
218
+ public final var strokeWidth: bridge.std__optional_double_ {
219
+ @inline(__always)
220
+ get {
221
+ return { () -> bridge.std__optional_double_ in
222
+ if let __unwrappedValue = self.__implementation.strokeWidth {
223
+ return bridge.create_std__optional_double_(__unwrappedValue)
224
+ } else {
225
+ return .init()
226
+ }
227
+ }()
228
+ }
229
+ @inline(__always)
230
+ set {
231
+ self.__implementation.strokeWidth = newValue.value
232
+ }
233
+ }
234
+
235
+ public final var fontFamily: bridge.std__optional_std__string_ {
236
+ @inline(__always)
237
+ get {
238
+ return { () -> bridge.std__optional_std__string_ in
239
+ if let __unwrappedValue = self.__implementation.fontFamily {
240
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
241
+ } else {
242
+ return .init()
243
+ }
244
+ }()
245
+ }
246
+ @inline(__always)
247
+ set {
248
+ self.__implementation.fontFamily = { () -> String? in
249
+ if bridge.has_value_std__optional_std__string_(newValue) {
250
+ let __unwrapped = bridge.get_std__optional_std__string_(newValue)
251
+ return String(__unwrapped)
252
+ } else {
253
+ return nil
254
+ }
255
+ }()
256
+ }
257
+ }
258
+
259
+ public final var align: bridge.std__optional_TextAlign_ {
260
+ @inline(__always)
261
+ get {
262
+ return { () -> bridge.std__optional_TextAlign_ in
263
+ if let __unwrappedValue = self.__implementation.align {
264
+ return bridge.create_std__optional_TextAlign_(__unwrappedValue)
265
+ } else {
266
+ return .init()
267
+ }
268
+ }()
269
+ }
270
+ @inline(__always)
271
+ set {
272
+ self.__implementation.align = newValue.value
273
+ }
274
+ }
275
+
276
+ public final var numberOfLines: bridge.std__optional_double_ {
277
+ @inline(__always)
278
+ get {
279
+ return { () -> bridge.std__optional_double_ in
280
+ if let __unwrappedValue = self.__implementation.numberOfLines {
281
+ return bridge.create_std__optional_double_(__unwrappedValue)
282
+ } else {
283
+ return .init()
284
+ }
285
+ }()
286
+ }
287
+ @inline(__always)
288
+ set {
289
+ self.__implementation.numberOfLines = newValue.value
290
+ }
291
+ }
292
+
293
+ public final var ellipsis: bridge.std__optional_bool_ {
294
+ @inline(__always)
295
+ get {
296
+ return { () -> bridge.std__optional_bool_ in
297
+ if let __unwrappedValue = self.__implementation.ellipsis {
298
+ return bridge.create_std__optional_bool_(__unwrappedValue)
299
+ } else {
300
+ return .init()
301
+ }
302
+ }()
303
+ }
304
+ @inline(__always)
305
+ set {
306
+ self.__implementation.ellipsis = { () -> Bool? in
307
+ if bridge.has_value_std__optional_bool_(newValue) {
308
+ let __unwrapped = bridge.get_std__optional_bool_(newValue)
309
+ return __unwrapped
310
+ } else {
311
+ return nil
312
+ }
313
+ }()
314
+ }
315
+ }
316
+
317
+ // Methods
318
+ @inline(__always)
319
+ public final func measureDimensions() -> bridge.Result_Dimensions_ {
320
+ do {
321
+ let __result = try self.__implementation.measureDimensions()
322
+ let __resultCpp = __result
323
+ return bridge.create_Result_Dimensions_(__resultCpp)
324
+ } catch (let __error) {
325
+ let __exceptionPtr = __error.toCpp()
326
+ return bridge.create_Result_Dimensions_(__exceptionPtr)
327
+ }
328
+ }
329
+
330
+ public final func getView() -> UnsafeMutableRawPointer {
331
+ return Unmanaged.passRetained(__implementation.view).toOpaque()
332
+ }
333
+
334
+ public final func beforeUpdate() {
335
+ __implementation.beforeUpdate()
336
+ }
337
+
338
+ public final func afterUpdate() {
339
+ __implementation.afterUpdate()
340
+ }
341
+ }
@@ -0,0 +1,44 @@
1
+ ///
2
+ /// TextAlign.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ /**
9
+ * Represents the JS union `TextAlign`, backed by a C++ enum.
10
+ */
11
+ public typealias TextAlign = margelo.nitro.rnstroketext.TextAlign
12
+
13
+ public extension TextAlign {
14
+ /**
15
+ * Get a TextAlign for the given String value, or
16
+ * return `nil` if the given value was invalid/unknown.
17
+ */
18
+ init?(fromString string: String) {
19
+ switch string {
20
+ case "center":
21
+ self = .center
22
+ case "left":
23
+ self = .left
24
+ case "right":
25
+ self = .right
26
+ default:
27
+ return nil
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Get the String value this TextAlign represents.
33
+ */
34
+ var stringValue: String {
35
+ switch self {
36
+ case .center:
37
+ return "center"
38
+ case .left:
39
+ return "left"
40
+ case .right:
41
+ return "right"
42
+ }
43
+ }
44
+ }
@@ -0,0 +1,87 @@
1
+ ///
2
+ /// Dimensions.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/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+
32
+
33
+
34
+
35
+ namespace margelo::nitro::rnstroketext {
36
+
37
+ /**
38
+ * A struct which can be represented as a JavaScript object (Dimensions).
39
+ */
40
+ struct Dimensions final {
41
+ public:
42
+ double width SWIFT_PRIVATE;
43
+ double height SWIFT_PRIVATE;
44
+
45
+ public:
46
+ Dimensions() = default;
47
+ explicit Dimensions(double width, double height): width(width), height(height) {}
48
+
49
+ public:
50
+ friend bool operator==(const Dimensions& lhs, const Dimensions& rhs) = default;
51
+ };
52
+
53
+ } // namespace margelo::nitro::rnstroketext
54
+
55
+ namespace margelo::nitro {
56
+
57
+ // C++ Dimensions <> JS Dimensions (object)
58
+ template <>
59
+ struct JSIConverter<margelo::nitro::rnstroketext::Dimensions> final {
60
+ static inline margelo::nitro::rnstroketext::Dimensions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
61
+ jsi::Object obj = arg.asObject(runtime);
62
+ return margelo::nitro::rnstroketext::Dimensions(
63
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "width"))),
64
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "height")))
65
+ );
66
+ }
67
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::rnstroketext::Dimensions& arg) {
68
+ jsi::Object obj(runtime);
69
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "width"), JSIConverter<double>::toJSI(runtime, arg.width));
70
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "height"), JSIConverter<double>::toJSI(runtime, arg.height));
71
+ return obj;
72
+ }
73
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
74
+ if (!value.isObject()) {
75
+ return false;
76
+ }
77
+ jsi::Object obj = value.getObject(runtime);
78
+ if (!nitro::isPlainObject(runtime, obj)) {
79
+ return false;
80
+ }
81
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "width")))) return false;
82
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "height")))) return false;
83
+ return true;
84
+ }
85
+ };
86
+
87
+ } // namespace margelo::nitro
@@ -0,0 +1,41 @@
1
+ ///
2
+ /// HybridMatiksStrokeTextSpec.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 "HybridMatiksStrokeTextSpec.hpp"
9
+
10
+ namespace margelo::nitro::rnstroketext {
11
+
12
+ void HybridMatiksStrokeTextSpec::loadHybridMethods() {
13
+ // load base methods/properties
14
+ HybridObject::loadHybridMethods();
15
+ // load custom methods/properties
16
+ registerHybrids(this, [](Prototype& prototype) {
17
+ prototype.registerHybridGetter("width", &HybridMatiksStrokeTextSpec::getWidth);
18
+ prototype.registerHybridSetter("width", &HybridMatiksStrokeTextSpec::setWidth);
19
+ prototype.registerHybridGetter("text", &HybridMatiksStrokeTextSpec::getText);
20
+ prototype.registerHybridSetter("text", &HybridMatiksStrokeTextSpec::setText);
21
+ prototype.registerHybridGetter("fontSize", &HybridMatiksStrokeTextSpec::getFontSize);
22
+ prototype.registerHybridSetter("fontSize", &HybridMatiksStrokeTextSpec::setFontSize);
23
+ prototype.registerHybridGetter("color", &HybridMatiksStrokeTextSpec::getColor);
24
+ prototype.registerHybridSetter("color", &HybridMatiksStrokeTextSpec::setColor);
25
+ prototype.registerHybridGetter("strokeColor", &HybridMatiksStrokeTextSpec::getStrokeColor);
26
+ prototype.registerHybridSetter("strokeColor", &HybridMatiksStrokeTextSpec::setStrokeColor);
27
+ prototype.registerHybridGetter("strokeWidth", &HybridMatiksStrokeTextSpec::getStrokeWidth);
28
+ prototype.registerHybridSetter("strokeWidth", &HybridMatiksStrokeTextSpec::setStrokeWidth);
29
+ prototype.registerHybridGetter("fontFamily", &HybridMatiksStrokeTextSpec::getFontFamily);
30
+ prototype.registerHybridSetter("fontFamily", &HybridMatiksStrokeTextSpec::setFontFamily);
31
+ prototype.registerHybridGetter("align", &HybridMatiksStrokeTextSpec::getAlign);
32
+ prototype.registerHybridSetter("align", &HybridMatiksStrokeTextSpec::setAlign);
33
+ prototype.registerHybridGetter("numberOfLines", &HybridMatiksStrokeTextSpec::getNumberOfLines);
34
+ prototype.registerHybridSetter("numberOfLines", &HybridMatiksStrokeTextSpec::setNumberOfLines);
35
+ prototype.registerHybridGetter("ellipsis", &HybridMatiksStrokeTextSpec::getEllipsis);
36
+ prototype.registerHybridSetter("ellipsis", &HybridMatiksStrokeTextSpec::setEllipsis);
37
+ prototype.registerHybridMethod("measureDimensions", &HybridMatiksStrokeTextSpec::measureDimensions);
38
+ });
39
+ }
40
+
41
+ } // namespace margelo::nitro::rnstroketext
@@ -0,0 +1,87 @@
1
+ ///
2
+ /// HybridMatiksStrokeTextSpec.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/HybridObject.hpp>)
11
+ #include <NitroModules/HybridObject.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+
16
+ // Forward declaration of `TextAlign` to properly resolve imports.
17
+ namespace margelo::nitro::rnstroketext { enum class TextAlign; }
18
+ // Forward declaration of `Dimensions` to properly resolve imports.
19
+ namespace margelo::nitro::rnstroketext { struct Dimensions; }
20
+
21
+ #include <optional>
22
+ #include <string>
23
+ #include "TextAlign.hpp"
24
+ #include "Dimensions.hpp"
25
+
26
+ namespace margelo::nitro::rnstroketext {
27
+
28
+ using namespace margelo::nitro;
29
+
30
+ /**
31
+ * An abstract base class for `MatiksStrokeText`
32
+ * Inherit this class to create instances of `HybridMatiksStrokeTextSpec` in C++.
33
+ * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
34
+ * @example
35
+ * ```cpp
36
+ * class HybridMatiksStrokeText: public HybridMatiksStrokeTextSpec {
37
+ * public:
38
+ * HybridMatiksStrokeText(...): HybridObject(TAG) { ... }
39
+ * // ...
40
+ * };
41
+ * ```
42
+ */
43
+ class HybridMatiksStrokeTextSpec: public virtual HybridObject {
44
+ public:
45
+ // Constructor
46
+ explicit HybridMatiksStrokeTextSpec(): HybridObject(TAG) { }
47
+
48
+ // Destructor
49
+ ~HybridMatiksStrokeTextSpec() override = default;
50
+
51
+ public:
52
+ // Properties
53
+ virtual std::optional<double> getWidth() = 0;
54
+ virtual void setWidth(std::optional<double> width) = 0;
55
+ virtual std::string getText() = 0;
56
+ virtual void setText(const std::string& text) = 0;
57
+ virtual std::optional<double> getFontSize() = 0;
58
+ virtual void setFontSize(std::optional<double> fontSize) = 0;
59
+ virtual std::optional<std::string> getColor() = 0;
60
+ virtual void setColor(const std::optional<std::string>& color) = 0;
61
+ virtual std::optional<std::string> getStrokeColor() = 0;
62
+ virtual void setStrokeColor(const std::optional<std::string>& strokeColor) = 0;
63
+ virtual std::optional<double> getStrokeWidth() = 0;
64
+ virtual void setStrokeWidth(std::optional<double> strokeWidth) = 0;
65
+ virtual std::optional<std::string> getFontFamily() = 0;
66
+ virtual void setFontFamily(const std::optional<std::string>& fontFamily) = 0;
67
+ virtual std::optional<TextAlign> getAlign() = 0;
68
+ virtual void setAlign(std::optional<TextAlign> align) = 0;
69
+ virtual std::optional<double> getNumberOfLines() = 0;
70
+ virtual void setNumberOfLines(std::optional<double> numberOfLines) = 0;
71
+ virtual std::optional<bool> getEllipsis() = 0;
72
+ virtual void setEllipsis(std::optional<bool> ellipsis) = 0;
73
+
74
+ public:
75
+ // Methods
76
+ virtual Dimensions measureDimensions() = 0;
77
+
78
+ protected:
79
+ // Hybrid Setup
80
+ void loadHybridMethods() override;
81
+
82
+ protected:
83
+ // Tag for logging
84
+ static constexpr auto TAG = "MatiksStrokeText";
85
+ };
86
+
87
+ } // namespace margelo::nitro::rnstroketext
@@ -0,0 +1,80 @@
1
+ ///
2
+ /// TextAlign.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/NitroHash.hpp>)
11
+ #include <NitroModules/NitroHash.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
16
+ #include <NitroModules/JSIConverter.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
21
+ #include <NitroModules/NitroDefines.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+ namespace margelo::nitro::rnstroketext {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (TextAlign).
30
+ */
31
+ enum class TextAlign {
32
+ CENTER SWIFT_NAME(center) = 0,
33
+ LEFT SWIFT_NAME(left) = 1,
34
+ RIGHT SWIFT_NAME(right) = 2,
35
+ } CLOSED_ENUM;
36
+
37
+ } // namespace margelo::nitro::rnstroketext
38
+
39
+ namespace margelo::nitro {
40
+
41
+ // C++ TextAlign <> JS TextAlign (union)
42
+ template <>
43
+ struct JSIConverter<margelo::nitro::rnstroketext::TextAlign> final {
44
+ static inline margelo::nitro::rnstroketext::TextAlign fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
45
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
46
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
47
+ case hashString("center"): return margelo::nitro::rnstroketext::TextAlign::CENTER;
48
+ case hashString("left"): return margelo::nitro::rnstroketext::TextAlign::LEFT;
49
+ case hashString("right"): return margelo::nitro::rnstroketext::TextAlign::RIGHT;
50
+ default: [[unlikely]]
51
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum TextAlign - invalid value!");
52
+ }
53
+ }
54
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::rnstroketext::TextAlign arg) {
55
+ switch (arg) {
56
+ case margelo::nitro::rnstroketext::TextAlign::CENTER: return JSIConverter<std::string>::toJSI(runtime, "center");
57
+ case margelo::nitro::rnstroketext::TextAlign::LEFT: return JSIConverter<std::string>::toJSI(runtime, "left");
58
+ case margelo::nitro::rnstroketext::TextAlign::RIGHT: return JSIConverter<std::string>::toJSI(runtime, "right");
59
+ default: [[unlikely]]
60
+ throw std::invalid_argument("Cannot convert TextAlign to JS - invalid value: "
61
+ + std::to_string(static_cast<int>(arg)) + "!");
62
+ }
63
+ }
64
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
65
+ if (!value.isString()) {
66
+ return false;
67
+ }
68
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
69
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
70
+ case hashString("center"):
71
+ case hashString("left"):
72
+ case hashString("right"):
73
+ return true;
74
+ default:
75
+ return false;
76
+ }
77
+ }
78
+ };
79
+
80
+ } // namespace margelo::nitro