@matiks/rn-stroke-text 0.1.9 → 0.2.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/nitrogen/generated/android/NitroRnStrokeTextOnLoad.cpp +27 -17
- package/nitrogen/generated/android/NitroRnStrokeTextOnLoad.hpp +13 -4
- package/nitrogen/generated/android/c++/JHybridMatiksStrokeTextSpec.cpp +39 -45
- package/nitrogen/generated/android/c++/JHybridMatiksStrokeTextSpec.hpp +19 -22
- package/nitrogen/generated/android/c++/views/JHybridMatiksStrokeTextStateUpdater.cpp +43 -43
- package/nitrogen/generated/android/c++/views/JHybridMatiksStrokeTextStateUpdater.hpp +3 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnstroketext/HybridMatiksStrokeTextSpec.kt +16 -18
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnstroketext/views/HybridMatiksStrokeTextManager.kt +27 -13
- package/nitrogen/generated/ios/NitroRnStrokeText-Swift-Cxx-Bridge.hpp +4 -4
- package/nitrogen/generated/ios/NitroRnStrokeTextAutolinking.swift +8 -7
- package/nitrogen/generated/ios/c++/views/HybridMatiksStrokeTextComponent.mm +10 -5
- package/nitrogen/generated/ios/swift/Dimensions.swift +0 -1
- package/nitrogen/generated/ios/swift/HybridMatiksStrokeTextSpec.swift +2 -3
- package/nitrogen/generated/ios/swift/HybridMatiksStrokeTextSpec_cxx.swift +37 -5
- package/nitrogen/generated/shared/c++/views/HybridMatiksStrokeTextComponent.cpp +4 -18
- package/nitrogen/generated/shared/c++/views/HybridMatiksStrokeTextComponent.hpp +8 -5
- package/package.json +3 -3
- package/lib/index.d.ts +0 -10
- package/lib/index.js +0 -28
- package/lib/specs/Stroke.nitro.d.ts +0 -24
- package/lib/specs/Stroke.nitro.js +0 -1
|
@@ -22,25 +22,35 @@
|
|
|
22
22
|
namespace margelo::nitro::rnstroketext {
|
|
23
23
|
|
|
24
24
|
int initialize(JavaVM* vm) {
|
|
25
|
+
return facebook::jni::initialize(vm, []() {
|
|
26
|
+
::margelo::nitro::rnstroketext::registerAllNatives();
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
struct JHybridMatiksStrokeTextSpecImpl: public jni::JavaClass<JHybridMatiksStrokeTextSpecImpl, JHybridMatiksStrokeTextSpec::JavaPart> {
|
|
31
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/rnstroketext/HybridMatiksStrokeText;";
|
|
32
|
+
static std::shared_ptr<JHybridMatiksStrokeTextSpec> create() {
|
|
33
|
+
static auto constructorFn = javaClassStatic()->getConstructor<JHybridMatiksStrokeTextSpecImpl::javaobject()>();
|
|
34
|
+
jni::local_ref<JHybridMatiksStrokeTextSpec::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn);
|
|
35
|
+
return javaPart->getJHybridMatiksStrokeTextSpec();
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
void registerAllNatives() {
|
|
25
40
|
using namespace margelo::nitro;
|
|
26
41
|
using namespace margelo::nitro::rnstroketext;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
auto instance = object.create();
|
|
40
|
-
return instance->cthis()->shared();
|
|
41
|
-
}
|
|
42
|
-
);
|
|
43
|
-
});
|
|
42
|
+
|
|
43
|
+
// Register native JNI methods
|
|
44
|
+
margelo::nitro::rnstroketext::JHybridMatiksStrokeTextSpec::CxxPart::registerNatives();
|
|
45
|
+
margelo::nitro::rnstroketext::views::JHybridMatiksStrokeTextStateUpdater::registerNatives();
|
|
46
|
+
|
|
47
|
+
// Register Nitro Hybrid Objects
|
|
48
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
49
|
+
"MatiksStrokeText",
|
|
50
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
51
|
+
return JHybridMatiksStrokeTextSpecImpl::create();
|
|
52
|
+
}
|
|
53
|
+
);
|
|
44
54
|
}
|
|
45
55
|
|
|
46
56
|
} // namespace margelo::nitro::rnstroketext
|
|
@@ -6,20 +6,29 @@
|
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#include <jni.h>
|
|
9
|
+
#include <functional>
|
|
9
10
|
#include <NitroModules/NitroDefines.hpp>
|
|
10
11
|
|
|
11
12
|
namespace margelo::nitro::rnstroketext {
|
|
12
13
|
|
|
14
|
+
[[deprecated("Use registerNatives() instead.")]]
|
|
15
|
+
int initialize(JavaVM* vm);
|
|
16
|
+
|
|
13
17
|
/**
|
|
14
|
-
*
|
|
15
|
-
* Call this in your `JNI_OnLoad` function (probably inside `cpp-adapter.cpp`)
|
|
18
|
+
* Register the native (C++) part of NitroRnStrokeText, and autolinks all Hybrid Objects.
|
|
19
|
+
* Call this in your `JNI_OnLoad` function (probably inside `cpp-adapter.cpp`),
|
|
20
|
+
* inside a `facebook::jni::initialize(vm, ...)` call.
|
|
16
21
|
* Example:
|
|
17
22
|
* ```cpp (cpp-adapter.cpp)
|
|
18
23
|
* JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
|
|
19
|
-
* return
|
|
24
|
+
* return facebook::jni::initialize(vm, []() {
|
|
25
|
+
* // register all NitroRnStrokeText HybridObjects
|
|
26
|
+
* margelo::nitro::rnstroketext::registerNatives();
|
|
27
|
+
* // any other custom registrations go here.
|
|
28
|
+
* });
|
|
20
29
|
* }
|
|
21
30
|
* ```
|
|
22
31
|
*/
|
|
23
|
-
|
|
32
|
+
void registerAllNatives();
|
|
24
33
|
|
|
25
34
|
} // namespace margelo::nitro::rnstroketext
|
|
@@ -21,134 +21,128 @@ namespace margelo::nitro::rnstroketext { struct Dimensions; }
|
|
|
21
21
|
|
|
22
22
|
namespace margelo::nitro::rnstroketext {
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
});
|
|
24
|
+
std::shared_ptr<JHybridMatiksStrokeTextSpec> JHybridMatiksStrokeTextSpec::JavaPart::getJHybridMatiksStrokeTextSpec() {
|
|
25
|
+
auto hybridObject = JHybridObject::JavaPart::getJHybridObject();
|
|
26
|
+
auto castHybridObject = std::dynamic_pointer_cast<JHybridMatiksStrokeTextSpec>(hybridObject);
|
|
27
|
+
if (castHybridObject == nullptr) [[unlikely]] {
|
|
28
|
+
throw std::runtime_error("Failed to downcast JHybridObject to JHybridMatiksStrokeTextSpec!");
|
|
29
|
+
}
|
|
30
|
+
return castHybridObject;
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return method(_javaPart);
|
|
33
|
+
jni::local_ref<JHybridMatiksStrokeTextSpec::CxxPart::jhybriddata> JHybridMatiksStrokeTextSpec::CxxPart::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
34
|
+
return makeCxxInstance(jThis);
|
|
37
35
|
}
|
|
38
36
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
std::shared_ptr<JHybridObject> JHybridMatiksStrokeTextSpec::CxxPart::createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) {
|
|
38
|
+
auto castJavaPart = jni::dynamic_ref_cast<JHybridMatiksStrokeTextSpec::JavaPart>(javaPart);
|
|
39
|
+
if (castJavaPart == nullptr) [[unlikely]] {
|
|
40
|
+
throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridMatiksStrokeTextSpec::JavaPart!");
|
|
42
41
|
}
|
|
43
|
-
return
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
void JHybridMatiksStrokeTextSpec::dispose() noexcept {
|
|
47
|
-
static const auto method = javaClassStatic()->getMethod<void()>("dispose");
|
|
48
|
-
method(_javaPart);
|
|
42
|
+
return std::make_shared<JHybridMatiksStrokeTextSpec>(castJavaPart);
|
|
49
43
|
}
|
|
50
44
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
void JHybridMatiksStrokeTextSpec::CxxPart::registerNatives() {
|
|
46
|
+
registerHybrid({
|
|
47
|
+
makeNativeMethod("initHybrid", JHybridMatiksStrokeTextSpec::CxxPart::initHybrid),
|
|
48
|
+
});
|
|
55
49
|
}
|
|
56
50
|
|
|
57
51
|
// Properties
|
|
58
52
|
std::optional<double> JHybridMatiksStrokeTextSpec::getWidth() {
|
|
59
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JDouble>()>("getWidth");
|
|
53
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JDouble>()>("getWidth");
|
|
60
54
|
auto __result = method(_javaPart);
|
|
61
55
|
return __result != nullptr ? std::make_optional(__result->value()) : std::nullopt;
|
|
62
56
|
}
|
|
63
57
|
void JHybridMatiksStrokeTextSpec::setWidth(std::optional<double> width) {
|
|
64
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JDouble> /* width */)>("setWidth");
|
|
58
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JDouble> /* width */)>("setWidth");
|
|
65
59
|
method(_javaPart, width.has_value() ? jni::JDouble::valueOf(width.value()) : nullptr);
|
|
66
60
|
}
|
|
67
61
|
std::string JHybridMatiksStrokeTextSpec::getText() {
|
|
68
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getText");
|
|
62
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getText");
|
|
69
63
|
auto __result = method(_javaPart);
|
|
70
64
|
return __result->toStdString();
|
|
71
65
|
}
|
|
72
66
|
void JHybridMatiksStrokeTextSpec::setText(const std::string& text) {
|
|
73
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* text */)>("setText");
|
|
67
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* text */)>("setText");
|
|
74
68
|
method(_javaPart, jni::make_jstring(text));
|
|
75
69
|
}
|
|
76
70
|
std::optional<double> JHybridMatiksStrokeTextSpec::getFontSize() {
|
|
77
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JDouble>()>("getFontSize");
|
|
71
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JDouble>()>("getFontSize");
|
|
78
72
|
auto __result = method(_javaPart);
|
|
79
73
|
return __result != nullptr ? std::make_optional(__result->value()) : std::nullopt;
|
|
80
74
|
}
|
|
81
75
|
void JHybridMatiksStrokeTextSpec::setFontSize(std::optional<double> fontSize) {
|
|
82
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JDouble> /* fontSize */)>("setFontSize");
|
|
76
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JDouble> /* fontSize */)>("setFontSize");
|
|
83
77
|
method(_javaPart, fontSize.has_value() ? jni::JDouble::valueOf(fontSize.value()) : nullptr);
|
|
84
78
|
}
|
|
85
79
|
std::optional<std::string> JHybridMatiksStrokeTextSpec::getColor() {
|
|
86
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getColor");
|
|
80
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getColor");
|
|
87
81
|
auto __result = method(_javaPart);
|
|
88
82
|
return __result != nullptr ? std::make_optional(__result->toStdString()) : std::nullopt;
|
|
89
83
|
}
|
|
90
84
|
void JHybridMatiksStrokeTextSpec::setColor(const std::optional<std::string>& color) {
|
|
91
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* color */)>("setColor");
|
|
85
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* color */)>("setColor");
|
|
92
86
|
method(_javaPart, color.has_value() ? jni::make_jstring(color.value()) : nullptr);
|
|
93
87
|
}
|
|
94
88
|
std::optional<std::string> JHybridMatiksStrokeTextSpec::getStrokeColor() {
|
|
95
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getStrokeColor");
|
|
89
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getStrokeColor");
|
|
96
90
|
auto __result = method(_javaPart);
|
|
97
91
|
return __result != nullptr ? std::make_optional(__result->toStdString()) : std::nullopt;
|
|
98
92
|
}
|
|
99
93
|
void JHybridMatiksStrokeTextSpec::setStrokeColor(const std::optional<std::string>& strokeColor) {
|
|
100
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* strokeColor */)>("setStrokeColor");
|
|
94
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* strokeColor */)>("setStrokeColor");
|
|
101
95
|
method(_javaPart, strokeColor.has_value() ? jni::make_jstring(strokeColor.value()) : nullptr);
|
|
102
96
|
}
|
|
103
97
|
std::optional<double> JHybridMatiksStrokeTextSpec::getStrokeWidth() {
|
|
104
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JDouble>()>("getStrokeWidth");
|
|
98
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JDouble>()>("getStrokeWidth");
|
|
105
99
|
auto __result = method(_javaPart);
|
|
106
100
|
return __result != nullptr ? std::make_optional(__result->value()) : std::nullopt;
|
|
107
101
|
}
|
|
108
102
|
void JHybridMatiksStrokeTextSpec::setStrokeWidth(std::optional<double> strokeWidth) {
|
|
109
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JDouble> /* strokeWidth */)>("setStrokeWidth");
|
|
103
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JDouble> /* strokeWidth */)>("setStrokeWidth");
|
|
110
104
|
method(_javaPart, strokeWidth.has_value() ? jni::JDouble::valueOf(strokeWidth.value()) : nullptr);
|
|
111
105
|
}
|
|
112
106
|
std::optional<std::string> JHybridMatiksStrokeTextSpec::getFontFamily() {
|
|
113
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getFontFamily");
|
|
107
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getFontFamily");
|
|
114
108
|
auto __result = method(_javaPart);
|
|
115
109
|
return __result != nullptr ? std::make_optional(__result->toStdString()) : std::nullopt;
|
|
116
110
|
}
|
|
117
111
|
void JHybridMatiksStrokeTextSpec::setFontFamily(const std::optional<std::string>& fontFamily) {
|
|
118
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* fontFamily */)>("setFontFamily");
|
|
112
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* fontFamily */)>("setFontFamily");
|
|
119
113
|
method(_javaPart, fontFamily.has_value() ? jni::make_jstring(fontFamily.value()) : nullptr);
|
|
120
114
|
}
|
|
121
115
|
std::optional<TextAlign> JHybridMatiksStrokeTextSpec::getAlign() {
|
|
122
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JTextAlign>()>("getAlign");
|
|
116
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JTextAlign>()>("getAlign");
|
|
123
117
|
auto __result = method(_javaPart);
|
|
124
118
|
return __result != nullptr ? std::make_optional(__result->toCpp()) : std::nullopt;
|
|
125
119
|
}
|
|
126
120
|
void JHybridMatiksStrokeTextSpec::setAlign(std::optional<TextAlign> align) {
|
|
127
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JTextAlign> /* align */)>("setAlign");
|
|
121
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JTextAlign> /* align */)>("setAlign");
|
|
128
122
|
method(_javaPart, align.has_value() ? JTextAlign::fromCpp(align.value()) : nullptr);
|
|
129
123
|
}
|
|
130
124
|
std::optional<double> JHybridMatiksStrokeTextSpec::getNumberOfLines() {
|
|
131
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JDouble>()>("getNumberOfLines");
|
|
125
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JDouble>()>("getNumberOfLines");
|
|
132
126
|
auto __result = method(_javaPart);
|
|
133
127
|
return __result != nullptr ? std::make_optional(__result->value()) : std::nullopt;
|
|
134
128
|
}
|
|
135
129
|
void JHybridMatiksStrokeTextSpec::setNumberOfLines(std::optional<double> numberOfLines) {
|
|
136
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JDouble> /* numberOfLines */)>("setNumberOfLines");
|
|
130
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JDouble> /* numberOfLines */)>("setNumberOfLines");
|
|
137
131
|
method(_javaPart, numberOfLines.has_value() ? jni::JDouble::valueOf(numberOfLines.value()) : nullptr);
|
|
138
132
|
}
|
|
139
133
|
std::optional<bool> JHybridMatiksStrokeTextSpec::getEllipsis() {
|
|
140
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JBoolean>()>("getEllipsis");
|
|
134
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JBoolean>()>("getEllipsis");
|
|
141
135
|
auto __result = method(_javaPart);
|
|
142
136
|
return __result != nullptr ? std::make_optional(static_cast<bool>(__result->value())) : std::nullopt;
|
|
143
137
|
}
|
|
144
138
|
void JHybridMatiksStrokeTextSpec::setEllipsis(std::optional<bool> ellipsis) {
|
|
145
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JBoolean> /* ellipsis */)>("setEllipsis");
|
|
139
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JBoolean> /* ellipsis */)>("setEllipsis");
|
|
146
140
|
method(_javaPart, ellipsis.has_value() ? jni::JBoolean::valueOf(ellipsis.value()) : nullptr);
|
|
147
141
|
}
|
|
148
142
|
|
|
149
143
|
// Methods
|
|
150
144
|
Dimensions JHybridMatiksStrokeTextSpec::measureDimensions() {
|
|
151
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JDimensions>()>("measureDimensions");
|
|
145
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JDimensions>()>("measureDimensions");
|
|
152
146
|
auto __result = method(_javaPart);
|
|
153
147
|
return __result->toCpp();
|
|
154
148
|
}
|
|
@@ -18,34 +18,33 @@ namespace margelo::nitro::rnstroketext {
|
|
|
18
18
|
|
|
19
19
|
using namespace facebook;
|
|
20
20
|
|
|
21
|
-
class JHybridMatiksStrokeTextSpec: public
|
|
22
|
-
public virtual HybridMatiksStrokeTextSpec {
|
|
21
|
+
class JHybridMatiksStrokeTextSpec: public virtual HybridMatiksStrokeTextSpec, public virtual JHybridObject {
|
|
23
22
|
public:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
HybridBase
|
|
33
|
-
|
|
23
|
+
struct JavaPart: public jni::JavaClass<JavaPart, JHybridObject::JavaPart> {
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/rnstroketext/HybridMatiksStrokeTextSpec;";
|
|
25
|
+
std::shared_ptr<JHybridMatiksStrokeTextSpec> getJHybridMatiksStrokeTextSpec();
|
|
26
|
+
};
|
|
27
|
+
struct CxxPart: public jni::HybridClass<CxxPart, JHybridObject::CxxPart> {
|
|
28
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/rnstroketext/HybridMatiksStrokeTextSpec$CxxPart;";
|
|
29
|
+
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
|
|
30
|
+
static void registerNatives();
|
|
31
|
+
using HybridBase::HybridBase;
|
|
32
|
+
protected:
|
|
33
|
+
std::shared_ptr<JHybridObject> createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) override;
|
|
34
|
+
};
|
|
34
35
|
|
|
35
36
|
public:
|
|
37
|
+
explicit JHybridMatiksStrokeTextSpec(const jni::local_ref<JHybridMatiksStrokeTextSpec::JavaPart>& javaPart):
|
|
38
|
+
HybridObject(HybridMatiksStrokeTextSpec::TAG),
|
|
39
|
+
JHybridObject(javaPart),
|
|
40
|
+
_javaPart(jni::make_global(javaPart)) {}
|
|
36
41
|
~JHybridMatiksStrokeTextSpec() override {
|
|
37
42
|
// Hermes GC can destroy JS objects on a non-JNI Thread.
|
|
38
43
|
jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
|
|
39
44
|
}
|
|
40
45
|
|
|
41
46
|
public:
|
|
42
|
-
|
|
43
|
-
bool equals(const std::shared_ptr<HybridObject>& other) override;
|
|
44
|
-
void dispose() noexcept override;
|
|
45
|
-
std::string toString() override;
|
|
46
|
-
|
|
47
|
-
public:
|
|
48
|
-
inline const jni::global_ref<JHybridMatiksStrokeTextSpec::javaobject>& getJavaPart() const noexcept {
|
|
47
|
+
inline const jni::global_ref<JHybridMatiksStrokeTextSpec::JavaPart>& getJavaPart() const noexcept {
|
|
49
48
|
return _javaPart;
|
|
50
49
|
}
|
|
51
50
|
|
|
@@ -77,9 +76,7 @@ namespace margelo::nitro::rnstroketext {
|
|
|
77
76
|
Dimensions measureDimensions() override;
|
|
78
77
|
|
|
79
78
|
private:
|
|
80
|
-
|
|
81
|
-
using HybridBase::HybridBase;
|
|
82
|
-
jni::global_ref<JHybridMatiksStrokeTextSpec::javaobject> _javaPart;
|
|
79
|
+
jni::global_ref<JHybridMatiksStrokeTextSpec::JavaPart> _javaPart;
|
|
83
80
|
};
|
|
84
81
|
|
|
85
82
|
} // namespace margelo::nitro::rnstroketext
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
#include "JHybridMatiksStrokeTextStateUpdater.hpp"
|
|
9
9
|
#include "views/HybridMatiksStrokeTextComponent.hpp"
|
|
10
10
|
#include <NitroModules/NitroDefines.hpp>
|
|
11
|
+
#include <react/fabric/StateWrapperImpl.h>
|
|
11
12
|
|
|
12
13
|
namespace margelo::nitro::rnstroketext::views {
|
|
13
14
|
|
|
@@ -15,77 +16,76 @@ using namespace facebook;
|
|
|
15
16
|
using ConcreteStateData = react::ConcreteState<HybridMatiksStrokeTextState>;
|
|
16
17
|
|
|
17
18
|
void JHybridMatiksStrokeTextStateUpdater::updateViewProps(jni::alias_ref<jni::JClass> /* class */,
|
|
18
|
-
jni::alias_ref<JHybridMatiksStrokeTextSpec::
|
|
19
|
+
jni::alias_ref<JHybridMatiksStrokeTextSpec::JavaPart> javaView,
|
|
19
20
|
jni::alias_ref<JStateWrapper::javaobject> stateWrapperInterface) {
|
|
20
|
-
JHybridMatiksStrokeTextSpec
|
|
21
|
+
std::shared_ptr<JHybridMatiksStrokeTextSpec> hybridView = javaView->getJHybridMatiksStrokeTextSpec();
|
|
21
22
|
|
|
22
23
|
// Get concrete StateWrapperImpl from passed StateWrapper interface object
|
|
23
24
|
jobject rawStateWrapper = stateWrapperInterface.get();
|
|
24
|
-
if (!stateWrapperInterface->isInstanceOf(react::StateWrapperImpl::javaClassStatic())) {
|
|
25
|
+
if (!stateWrapperInterface->isInstanceOf(react::StateWrapperImpl::javaClassStatic())) [[unlikely]] {
|
|
25
26
|
throw std::runtime_error("StateWrapper is not a StateWrapperImpl");
|
|
26
27
|
}
|
|
27
28
|
auto stateWrapper = jni::alias_ref<react::StateWrapperImpl::javaobject>{
|
|
28
29
|
static_cast<react::StateWrapperImpl::javaobject>(rawStateWrapper)};
|
|
29
|
-
|
|
30
30
|
std::shared_ptr<const react::State> state = stateWrapper->cthis()->getState();
|
|
31
|
-
auto concreteState = std::
|
|
31
|
+
auto concreteState = std::static_pointer_cast<const ConcreteStateData>(state);
|
|
32
32
|
const HybridMatiksStrokeTextState& data = concreteState->getData();
|
|
33
|
-
const std::
|
|
34
|
-
if (
|
|
33
|
+
const std::shared_ptr<HybridMatiksStrokeTextProps>& props = data.getProps();
|
|
34
|
+
if (props == nullptr) [[unlikely]] {
|
|
35
35
|
// Props aren't set yet!
|
|
36
36
|
throw std::runtime_error("HybridMatiksStrokeTextState's data doesn't contain any props!");
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
|
|
39
|
+
// Update all props if they are dirty
|
|
40
|
+
if (props->width.isDirty) {
|
|
41
|
+
hybridView->setWidth(props->width.value);
|
|
42
|
+
props->width.isDirty = false;
|
|
42
43
|
}
|
|
43
|
-
if (props
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
if (props->text.isDirty) {
|
|
45
|
+
hybridView->setText(props->text.value);
|
|
46
|
+
props->text.isDirty = false;
|
|
46
47
|
}
|
|
47
|
-
if (props
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
if (props->fontSize.isDirty) {
|
|
49
|
+
hybridView->setFontSize(props->fontSize.value);
|
|
50
|
+
props->fontSize.isDirty = false;
|
|
50
51
|
}
|
|
51
|
-
if (props
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
if (props->color.isDirty) {
|
|
53
|
+
hybridView->setColor(props->color.value);
|
|
54
|
+
props->color.isDirty = false;
|
|
54
55
|
}
|
|
55
|
-
if (props
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
if (props->strokeColor.isDirty) {
|
|
57
|
+
hybridView->setStrokeColor(props->strokeColor.value);
|
|
58
|
+
props->strokeColor.isDirty = false;
|
|
58
59
|
}
|
|
59
|
-
if (props
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
if (props->strokeWidth.isDirty) {
|
|
61
|
+
hybridView->setStrokeWidth(props->strokeWidth.value);
|
|
62
|
+
props->strokeWidth.isDirty = false;
|
|
62
63
|
}
|
|
63
|
-
if (props
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
if (props->fontFamily.isDirty) {
|
|
65
|
+
hybridView->setFontFamily(props->fontFamily.value);
|
|
66
|
+
props->fontFamily.isDirty = false;
|
|
66
67
|
}
|
|
67
|
-
if (props
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
if (props->align.isDirty) {
|
|
69
|
+
hybridView->setAlign(props->align.value);
|
|
70
|
+
props->align.isDirty = false;
|
|
70
71
|
}
|
|
71
|
-
if (props
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
if (props->numberOfLines.isDirty) {
|
|
73
|
+
hybridView->setNumberOfLines(props->numberOfLines.value);
|
|
74
|
+
props->numberOfLines.isDirty = false;
|
|
74
75
|
}
|
|
75
|
-
if (props
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
if (props->ellipsis.isDirty) {
|
|
77
|
+
hybridView->setEllipsis(props->ellipsis.value);
|
|
78
|
+
props->ellipsis.isDirty = false;
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
// Update hybridRef if it changed
|
|
81
|
-
if (props
|
|
82
|
+
if (props->hybridRef.isDirty) {
|
|
82
83
|
// hybridRef changed - call it with new this
|
|
83
|
-
const auto& maybeFunc = props
|
|
84
|
+
const auto& maybeFunc = props->hybridRef.value;
|
|
84
85
|
if (maybeFunc.has_value()) {
|
|
85
|
-
|
|
86
|
-
maybeFunc.value()(shared);
|
|
86
|
+
maybeFunc.value()(hybridView);
|
|
87
87
|
}
|
|
88
|
-
|
|
88
|
+
props->hybridRef.isDirty = false;
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
#endif
|
|
13
13
|
|
|
14
14
|
#include <fbjni/fbjni.h>
|
|
15
|
-
#include <react/fabric/StateWrapperImpl.h>
|
|
16
15
|
#include <react/fabric/CoreComponentsRegistry.h>
|
|
16
|
+
#include <react/fabric/StateWrapperImpl.h>
|
|
17
17
|
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
18
18
|
#include <NitroModules/NitroDefines.hpp>
|
|
19
19
|
#include <NitroModules/JStateWrapper.hpp>
|
|
@@ -24,13 +24,13 @@ namespace margelo::nitro::rnstroketext::views {
|
|
|
24
24
|
|
|
25
25
|
using namespace facebook;
|
|
26
26
|
|
|
27
|
-
class JHybridMatiksStrokeTextStateUpdater: public jni::JavaClass<JHybridMatiksStrokeTextStateUpdater> {
|
|
27
|
+
class JHybridMatiksStrokeTextStateUpdater final: public jni::JavaClass<JHybridMatiksStrokeTextStateUpdater> {
|
|
28
28
|
public:
|
|
29
29
|
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/rnstroketext/views/HybridMatiksStrokeTextStateUpdater;";
|
|
30
30
|
|
|
31
31
|
public:
|
|
32
32
|
static void updateViewProps(jni::alias_ref<jni::JClass> /* class */,
|
|
33
|
-
jni::alias_ref<JHybridMatiksStrokeTextSpec::
|
|
33
|
+
jni::alias_ref<JHybridMatiksStrokeTextSpec::JavaPart> view,
|
|
34
34
|
jni::alias_ref<JStateWrapper::javaobject> stateWrapperInterface);
|
|
35
35
|
|
|
36
36
|
public:
|
|
@@ -10,6 +10,7 @@ package com.margelo.nitro.rnstroketext
|
|
|
10
10
|
import androidx.annotation.Keep
|
|
11
11
|
import com.facebook.jni.HybridData
|
|
12
12
|
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
import com.margelo.nitro.core.HybridObject
|
|
13
14
|
import com.margelo.nitro.views.HybridView
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -24,23 +25,6 @@ import com.margelo.nitro.views.HybridView
|
|
|
24
25
|
"LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
|
|
25
26
|
)
|
|
26
27
|
abstract class HybridMatiksStrokeTextSpec: HybridView() {
|
|
27
|
-
@DoNotStrip
|
|
28
|
-
private var mHybridData: HybridData = initHybrid()
|
|
29
|
-
|
|
30
|
-
init {
|
|
31
|
-
super.updateNative(mHybridData)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
override fun updateNative(hybridData: HybridData) {
|
|
35
|
-
mHybridData = hybridData
|
|
36
|
-
super.updateNative(hybridData)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Default implementation of `HybridObject.toString()`
|
|
40
|
-
override fun toString(): String {
|
|
41
|
-
return "[HybridObject MatiksStrokeText]"
|
|
42
|
-
}
|
|
43
|
-
|
|
44
28
|
// Properties
|
|
45
29
|
@get:DoNotStrip
|
|
46
30
|
@get:Keep
|
|
@@ -107,7 +91,21 @@ abstract class HybridMatiksStrokeTextSpec: HybridView() {
|
|
|
107
91
|
@Keep
|
|
108
92
|
abstract fun measureDimensions(): Dimensions
|
|
109
93
|
|
|
110
|
-
|
|
94
|
+
// Default implementation of `HybridObject.toString()`
|
|
95
|
+
override fun toString(): String {
|
|
96
|
+
return "[HybridObject MatiksStrokeText]"
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// C++ backing class
|
|
100
|
+
@DoNotStrip
|
|
101
|
+
@Keep
|
|
102
|
+
protected open class CxxPart(javaPart: HybridMatiksStrokeTextSpec): HybridObject.CxxPart(javaPart) {
|
|
103
|
+
// C++ JHybridMatiksStrokeTextSpec::CxxPart::initHybrid(...)
|
|
104
|
+
external override fun initHybrid(): HybridData
|
|
105
|
+
}
|
|
106
|
+
override fun createCxxPart(): CxxPart {
|
|
107
|
+
return CxxPart(this)
|
|
108
|
+
}
|
|
111
109
|
|
|
112
110
|
companion object {
|
|
113
111
|
protected const val TAG = "HybridMatiksStrokeTextSpec"
|
|
@@ -12,13 +12,20 @@ import com.facebook.react.uimanager.ReactStylesDiffMap
|
|
|
12
12
|
import com.facebook.react.uimanager.SimpleViewManager
|
|
13
13
|
import com.facebook.react.uimanager.StateWrapper
|
|
14
14
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
15
|
+
import com.margelo.nitro.R.id.associated_hybrid_view_tag
|
|
16
|
+
import com.margelo.nitro.views.RecyclableView
|
|
15
17
|
import com.margelo.nitro.rnstroketext.*
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
20
|
* Represents the React Native `ViewManager` for the "MatiksStrokeText" Nitro HybridView.
|
|
19
21
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
public class HybridMatiksStrokeTextManager: SimpleViewManager<View>() {
|
|
23
|
+
init {
|
|
24
|
+
if (RecyclableView::class.java.isAssignableFrom(HybridMatiksStrokeText::class.java)) {
|
|
25
|
+
// Enable view recycling
|
|
26
|
+
super.setupViewRecycling()
|
|
27
|
+
}
|
|
28
|
+
}
|
|
22
29
|
|
|
23
30
|
override fun getName(): String {
|
|
24
31
|
return "MatiksStrokeText"
|
|
@@ -27,17 +34,13 @@ open class HybridMatiksStrokeTextManager: SimpleViewManager<View>() {
|
|
|
27
34
|
override fun createViewInstance(reactContext: ThemedReactContext): View {
|
|
28
35
|
val hybridView = HybridMatiksStrokeText(reactContext)
|
|
29
36
|
val view = hybridView.view
|
|
30
|
-
|
|
37
|
+
view.setTag(associated_hybrid_view_tag, hybridView)
|
|
31
38
|
return view
|
|
32
39
|
}
|
|
33
40
|
|
|
34
|
-
override fun onDropViewInstance(view: View) {
|
|
35
|
-
super.onDropViewInstance(view)
|
|
36
|
-
views.remove(view)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
41
|
override fun updateState(view: View, props: ReactStylesDiffMap, stateWrapper: StateWrapper): Any? {
|
|
40
|
-
val hybridView =
|
|
42
|
+
val hybridView = view.getTag(associated_hybrid_view_tag) as? HybridMatiksStrokeText
|
|
43
|
+
?: throw Error("Couldn't find view $view in local views table!")
|
|
41
44
|
|
|
42
45
|
// 1. Update each prop individually
|
|
43
46
|
hybridView.beforeUpdate()
|
|
@@ -48,9 +51,20 @@ open class HybridMatiksStrokeTextManager: SimpleViewManager<View>() {
|
|
|
48
51
|
return super.updateState(view, props, stateWrapper)
|
|
49
52
|
}
|
|
50
53
|
|
|
51
|
-
protected override fun
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
protected override fun prepareToRecycleView(reactContext: ThemedReactContext, view: View): View? {
|
|
55
|
+
super.prepareToRecycleView(reactContext, view)
|
|
56
|
+
val hybridView = view.getTag(associated_hybrid_view_tag) as? HybridMatiksStrokeText
|
|
57
|
+
?: return null
|
|
58
|
+
|
|
59
|
+
@Suppress("USELESS_IS_CHECK")
|
|
60
|
+
if (hybridView is RecyclableView) {
|
|
61
|
+
// Recycle in it's implementation
|
|
62
|
+
hybridView.prepareForRecycle()
|
|
63
|
+
|
|
64
|
+
// Maybe update the view if it changed
|
|
65
|
+
return hybridView.view
|
|
66
|
+
} else {
|
|
67
|
+
return null
|
|
68
|
+
}
|
|
55
69
|
}
|
|
56
70
|
}
|
|
@@ -47,7 +47,7 @@ namespace margelo::nitro::rnstroketext::bridge::swift {
|
|
|
47
47
|
return optional.has_value();
|
|
48
48
|
}
|
|
49
49
|
inline double get_std__optional_double_(const std::optional<double>& optional) noexcept {
|
|
50
|
-
return
|
|
50
|
+
return optional.value();
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
// pragma MARK: std::optional<std::string>
|
|
@@ -62,7 +62,7 @@ namespace margelo::nitro::rnstroketext::bridge::swift {
|
|
|
62
62
|
return optional.has_value();
|
|
63
63
|
}
|
|
64
64
|
inline std::string get_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
|
|
65
|
-
return
|
|
65
|
+
return optional.value();
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
// pragma MARK: std::optional<TextAlign>
|
|
@@ -77,7 +77,7 @@ namespace margelo::nitro::rnstroketext::bridge::swift {
|
|
|
77
77
|
return optional.has_value();
|
|
78
78
|
}
|
|
79
79
|
inline TextAlign get_std__optional_TextAlign_(const std::optional<TextAlign>& optional) noexcept {
|
|
80
|
-
return
|
|
80
|
+
return optional.value();
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
// pragma MARK: std::optional<bool>
|
|
@@ -92,7 +92,7 @@ namespace margelo::nitro::rnstroketext::bridge::swift {
|
|
|
92
92
|
return optional.has_value();
|
|
93
93
|
}
|
|
94
94
|
inline bool get_std__optional_bool_(const std::optional<bool>& optional) noexcept {
|
|
95
|
-
return
|
|
95
|
+
return optional.value();
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
// pragma MARK: std::shared_ptr<HybridMatiksStrokeTextSpec>
|
|
@@ -5,16 +5,13 @@
|
|
|
5
5
|
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
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
|
|
8
12
|
public final class NitroRnStrokeTextAutolinking {
|
|
9
13
|
public typealias bridge = margelo.nitro.rnstroketext.bridge.swift
|
|
10
14
|
|
|
11
|
-
/**
|
|
12
|
-
* Creates an instance of a Swift class that implements `HybridMatiksStrokeTextSpec`,
|
|
13
|
-
* and wraps it in a Swift class that can directly interop with C++ (`HybridMatiksStrokeTextSpec_cxx`)
|
|
14
|
-
*
|
|
15
|
-
* This is generated by Nitrogen and will initialize the class specified
|
|
16
|
-
* in the `"autolinking"` property of `nitro.json` (in this case, `HybridMatiksStrokeText`).
|
|
17
|
-
*/
|
|
18
15
|
public static func createMatiksStrokeText() -> bridge.std__shared_ptr_HybridMatiksStrokeTextSpec_ {
|
|
19
16
|
let hybridObject = HybridMatiksStrokeText()
|
|
20
17
|
return { () -> bridge.std__shared_ptr_HybridMatiksStrokeTextSpec_ in
|
|
@@ -22,4 +19,8 @@ public final class NitroRnStrokeTextAutolinking {
|
|
|
22
19
|
return __cxxWrapped.getCxxPart()
|
|
23
20
|
}()
|
|
24
21
|
}
|
|
22
|
+
|
|
23
|
+
public static func isMatiksStrokeTextRecyclable() -> Bool {
|
|
24
|
+
return HybridMatiksStrokeText.self is any RecyclableView.Type
|
|
25
|
+
}
|
|
25
26
|
}
|
|
@@ -41,11 +41,6 @@ using namespace margelo::nitro::rnstroketext::views;
|
|
|
41
41
|
return react::concreteComponentDescriptorProvider<HybridMatiksStrokeTextComponentDescriptor>();
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
+ (BOOL)shouldBeRecycled {
|
|
45
|
-
// TODO: Recycling should be controllable by the user. WIP, but disabled for now.
|
|
46
|
-
return NO;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
44
|
- (instancetype) init {
|
|
50
45
|
if (self = [super init]) {
|
|
51
46
|
std::shared_ptr<HybridMatiksStrokeTextSpec> hybridView = NitroRnStrokeText::NitroRnStrokeTextAutolinking::createMatiksStrokeText();
|
|
@@ -144,4 +139,14 @@ using namespace margelo::nitro::rnstroketext::views;
|
|
|
144
139
|
[super updateProps:props oldProps:oldProps];
|
|
145
140
|
}
|
|
146
141
|
|
|
142
|
+
+ (BOOL)shouldBeRecycled {
|
|
143
|
+
return NitroRnStrokeText::NitroRnStrokeTextAutolinking::isMatiksStrokeTextRecyclable();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
- (void)prepareForRecycle {
|
|
147
|
+
[super prepareForRecycle];
|
|
148
|
+
NitroRnStrokeText::HybridMatiksStrokeTextSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
149
|
+
swiftPart.maybePrepareForRecycle();
|
|
150
|
+
}
|
|
151
|
+
|
|
147
152
|
@end
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
|
-
import Foundation
|
|
9
8
|
import NitroModules
|
|
10
9
|
|
|
11
10
|
/// See ``HybridMatiksStrokeTextSpec``
|
|
@@ -39,14 +38,14 @@ open class HybridMatiksStrokeTextSpec_base {
|
|
|
39
38
|
public init() { }
|
|
40
39
|
public func getCxxWrapper() -> HybridMatiksStrokeTextSpec_cxx {
|
|
41
40
|
#if DEBUG
|
|
42
|
-
guard self is HybridMatiksStrokeTextSpec else {
|
|
41
|
+
guard self is any HybridMatiksStrokeTextSpec else {
|
|
43
42
|
fatalError("`self` is not a `HybridMatiksStrokeTextSpec`! Did you accidentally inherit from `HybridMatiksStrokeTextSpec_base` instead of `HybridMatiksStrokeTextSpec`?")
|
|
44
43
|
}
|
|
45
44
|
#endif
|
|
46
45
|
if let cxxWrapper = self.cxxWrapper {
|
|
47
46
|
return cxxWrapper
|
|
48
47
|
} else {
|
|
49
|
-
let cxxWrapper = HybridMatiksStrokeTextSpec_cxx(self as! HybridMatiksStrokeTextSpec)
|
|
48
|
+
let cxxWrapper = HybridMatiksStrokeTextSpec_cxx(self as! any HybridMatiksStrokeTextSpec)
|
|
50
49
|
self.cxxWrapper = cxxWrapper
|
|
51
50
|
return cxxWrapper
|
|
52
51
|
}
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
|
-
import Foundation
|
|
9
8
|
import NitroModules
|
|
10
9
|
|
|
11
10
|
/**
|
|
@@ -135,7 +134,14 @@ open class HybridMatiksStrokeTextSpec_cxx {
|
|
|
135
134
|
}
|
|
136
135
|
@inline(__always)
|
|
137
136
|
set {
|
|
138
|
-
self.__implementation.width =
|
|
137
|
+
self.__implementation.width = { () -> Double? in
|
|
138
|
+
if bridge.has_value_std__optional_double_(newValue) {
|
|
139
|
+
let __unwrapped = bridge.get_std__optional_double_(newValue)
|
|
140
|
+
return __unwrapped
|
|
141
|
+
} else {
|
|
142
|
+
return nil
|
|
143
|
+
}
|
|
144
|
+
}()
|
|
139
145
|
}
|
|
140
146
|
}
|
|
141
147
|
|
|
@@ -163,7 +169,14 @@ open class HybridMatiksStrokeTextSpec_cxx {
|
|
|
163
169
|
}
|
|
164
170
|
@inline(__always)
|
|
165
171
|
set {
|
|
166
|
-
self.__implementation.fontSize =
|
|
172
|
+
self.__implementation.fontSize = { () -> Double? in
|
|
173
|
+
if bridge.has_value_std__optional_double_(newValue) {
|
|
174
|
+
let __unwrapped = bridge.get_std__optional_double_(newValue)
|
|
175
|
+
return __unwrapped
|
|
176
|
+
} else {
|
|
177
|
+
return nil
|
|
178
|
+
}
|
|
179
|
+
}()
|
|
167
180
|
}
|
|
168
181
|
}
|
|
169
182
|
|
|
@@ -228,7 +241,14 @@ open class HybridMatiksStrokeTextSpec_cxx {
|
|
|
228
241
|
}
|
|
229
242
|
@inline(__always)
|
|
230
243
|
set {
|
|
231
|
-
self.__implementation.strokeWidth =
|
|
244
|
+
self.__implementation.strokeWidth = { () -> Double? in
|
|
245
|
+
if bridge.has_value_std__optional_double_(newValue) {
|
|
246
|
+
let __unwrapped = bridge.get_std__optional_double_(newValue)
|
|
247
|
+
return __unwrapped
|
|
248
|
+
} else {
|
|
249
|
+
return nil
|
|
250
|
+
}
|
|
251
|
+
}()
|
|
232
252
|
}
|
|
233
253
|
}
|
|
234
254
|
|
|
@@ -286,7 +306,14 @@ open class HybridMatiksStrokeTextSpec_cxx {
|
|
|
286
306
|
}
|
|
287
307
|
@inline(__always)
|
|
288
308
|
set {
|
|
289
|
-
self.__implementation.numberOfLines =
|
|
309
|
+
self.__implementation.numberOfLines = { () -> Double? in
|
|
310
|
+
if bridge.has_value_std__optional_double_(newValue) {
|
|
311
|
+
let __unwrapped = bridge.get_std__optional_double_(newValue)
|
|
312
|
+
return __unwrapped
|
|
313
|
+
} else {
|
|
314
|
+
return nil
|
|
315
|
+
}
|
|
316
|
+
}()
|
|
290
317
|
}
|
|
291
318
|
}
|
|
292
319
|
|
|
@@ -338,4 +365,9 @@ open class HybridMatiksStrokeTextSpec_cxx {
|
|
|
338
365
|
public final func afterUpdate() {
|
|
339
366
|
__implementation.afterUpdate()
|
|
340
367
|
}
|
|
368
|
+
|
|
369
|
+
public final func maybePrepareForRecycle() {
|
|
370
|
+
guard let recyclable = __implementation as? any RecyclableView else { return }
|
|
371
|
+
recyclable.prepareForRecycle()
|
|
372
|
+
}
|
|
341
373
|
}
|
|
@@ -137,20 +137,6 @@ namespace margelo::nitro::rnstroketext::views {
|
|
|
137
137
|
}
|
|
138
138
|
}()) { }
|
|
139
139
|
|
|
140
|
-
HybridMatiksStrokeTextProps::HybridMatiksStrokeTextProps(const HybridMatiksStrokeTextProps& other):
|
|
141
|
-
react::ViewProps(),
|
|
142
|
-
width(other.width),
|
|
143
|
-
text(other.text),
|
|
144
|
-
fontSize(other.fontSize),
|
|
145
|
-
color(other.color),
|
|
146
|
-
strokeColor(other.strokeColor),
|
|
147
|
-
strokeWidth(other.strokeWidth),
|
|
148
|
-
fontFamily(other.fontFamily),
|
|
149
|
-
align(other.align),
|
|
150
|
-
numberOfLines(other.numberOfLines),
|
|
151
|
-
ellipsis(other.ellipsis),
|
|
152
|
-
hybridRef(other.hybridRef) { }
|
|
153
|
-
|
|
154
140
|
bool HybridMatiksStrokeTextProps::filterObjectKeys(const std::string& propName) {
|
|
155
141
|
switch (hashString(propName)) {
|
|
156
142
|
case hashString("width"): return true;
|
|
@@ -185,10 +171,10 @@ namespace margelo::nitro::rnstroketext::views {
|
|
|
185
171
|
void HybridMatiksStrokeTextComponentDescriptor::adopt(react::ShadowNode& shadowNode) const {
|
|
186
172
|
// This is called immediately after `ShadowNode` is created, cloned or in progress.
|
|
187
173
|
// On Android, we need to wrap props in our state, which gets routed through Java and later unwrapped in JNI/C++.
|
|
188
|
-
auto& concreteShadowNode =
|
|
189
|
-
const HybridMatiksStrokeTextProps
|
|
190
|
-
|
|
191
|
-
state
|
|
174
|
+
auto& concreteShadowNode = static_cast<HybridMatiksStrokeTextShadowNode&>(shadowNode);
|
|
175
|
+
const std::shared_ptr<const HybridMatiksStrokeTextProps>& constProps = concreteShadowNode.getConcreteSharedProps();
|
|
176
|
+
const std::shared_ptr<HybridMatiksStrokeTextProps>& props = std::const_pointer_cast<HybridMatiksStrokeTextProps>(constProps);
|
|
177
|
+
HybridMatiksStrokeTextState state{props};
|
|
192
178
|
concreteShadowNode.setStateData(std::move(state));
|
|
193
179
|
}
|
|
194
180
|
#endif
|
|
@@ -38,7 +38,6 @@ namespace margelo::nitro::rnstroketext::views {
|
|
|
38
38
|
class HybridMatiksStrokeTextProps final: public react::ViewProps {
|
|
39
39
|
public:
|
|
40
40
|
HybridMatiksStrokeTextProps() = default;
|
|
41
|
-
HybridMatiksStrokeTextProps(const HybridMatiksStrokeTextProps&);
|
|
42
41
|
HybridMatiksStrokeTextProps(const react::PropsParserContext& context,
|
|
43
42
|
const HybridMatiksStrokeTextProps& sourceProps,
|
|
44
43
|
const react::RawProps& rawProps);
|
|
@@ -66,10 +65,14 @@ namespace margelo::nitro::rnstroketext::views {
|
|
|
66
65
|
class HybridMatiksStrokeTextState final {
|
|
67
66
|
public:
|
|
68
67
|
HybridMatiksStrokeTextState() = default;
|
|
68
|
+
explicit HybridMatiksStrokeTextState(const std::shared_ptr<HybridMatiksStrokeTextProps>& props):
|
|
69
|
+
_props(props) {}
|
|
69
70
|
|
|
70
71
|
public:
|
|
71
|
-
|
|
72
|
-
const std::
|
|
72
|
+
[[nodiscard]]
|
|
73
|
+
const std::shared_ptr<HybridMatiksStrokeTextProps>& getProps() const {
|
|
74
|
+
return _props;
|
|
75
|
+
}
|
|
73
76
|
|
|
74
77
|
public:
|
|
75
78
|
#ifdef ANDROID
|
|
@@ -83,7 +86,7 @@ namespace margelo::nitro::rnstroketext::views {
|
|
|
83
86
|
#endif
|
|
84
87
|
|
|
85
88
|
private:
|
|
86
|
-
std::
|
|
89
|
+
std::shared_ptr<HybridMatiksStrokeTextProps> _props;
|
|
87
90
|
};
|
|
88
91
|
|
|
89
92
|
/**
|
|
@@ -99,7 +102,7 @@ namespace margelo::nitro::rnstroketext::views {
|
|
|
99
102
|
*/
|
|
100
103
|
class HybridMatiksStrokeTextComponentDescriptor final: public react::ConcreteComponentDescriptor<HybridMatiksStrokeTextShadowNode> {
|
|
101
104
|
public:
|
|
102
|
-
HybridMatiksStrokeTextComponentDescriptor(const react::ComponentDescriptorParameters& parameters);
|
|
105
|
+
explicit HybridMatiksStrokeTextComponentDescriptor(const react::ComponentDescriptorParameters& parameters);
|
|
103
106
|
|
|
104
107
|
public:
|
|
105
108
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matiks/rn-stroke-text",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "rn-stroke-text",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"module": "lib/index",
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
"eslint": "^8.57.0",
|
|
59
59
|
"eslint-config-prettier": "^9.1.0",
|
|
60
60
|
"eslint-plugin-prettier": "^5.2.1",
|
|
61
|
-
"nitrogen": "
|
|
61
|
+
"nitrogen": "0.35.0",
|
|
62
62
|
"prettier": "^3.3.3",
|
|
63
63
|
"react": "19.1.1",
|
|
64
64
|
"react-native": "0.82.0",
|
|
65
|
-
"react-native-nitro-modules": "
|
|
65
|
+
"react-native-nitro-modules": "0.35.0",
|
|
66
66
|
"typescript": "^5.8.3"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
package/lib/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { type MatiksStrokeTextProps } from "./specs/Stroke.nitro";
|
|
3
|
-
interface StrokeTextViewProps extends MatiksStrokeTextProps {
|
|
4
|
-
styles?: {
|
|
5
|
-
width?: number;
|
|
6
|
-
height?: number;
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
declare const _default: React.MemoExoticComponent<({ text, styles, ...props }: StrokeTextViewProps) => React.JSX.Element>;
|
|
10
|
-
export default _default;
|
package/lib/index.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from "react";
|
|
2
|
-
import { callback, getHostComponent } from "react-native-nitro-modules";
|
|
3
|
-
import MatiksKeyboardViewConfig from "../nitrogen/generated/shared/json/MatiksStrokeTextConfig.json";
|
|
4
|
-
import {} from "./specs/Stroke.nitro";
|
|
5
|
-
const StrokeTextViewComponent = getHostComponent('MatiksStrokeText', () => MatiksKeyboardViewConfig);
|
|
6
|
-
const StrokeTextView = ({ text, styles, ...props }) => {
|
|
7
|
-
const ref = useRef(null);
|
|
8
|
-
const [size, setSize] = useState({ width: 0, height: 0 });
|
|
9
|
-
const [isReady, setIsReady] = useState(false);
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
if (!ref.current)
|
|
12
|
-
return;
|
|
13
|
-
const result = ref.current.measureDimensions();
|
|
14
|
-
setSize(result);
|
|
15
|
-
}, [
|
|
16
|
-
props.fontFamily,
|
|
17
|
-
props.fontSize,
|
|
18
|
-
text,
|
|
19
|
-
isReady
|
|
20
|
-
]);
|
|
21
|
-
return (React.createElement(StrokeTextViewComponent, { ...props, text: String(text), style: [{ width: size.width, height: size.height }, styles], hybridRef: callback((_ref) => {
|
|
22
|
-
if (ref.current)
|
|
23
|
-
return;
|
|
24
|
-
ref.current = _ref;
|
|
25
|
-
setIsReady(true);
|
|
26
|
-
}) }));
|
|
27
|
-
};
|
|
28
|
-
export default React.memo(StrokeTextView);
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
type TextAlign = 'center' | 'left' | 'right';
|
|
2
|
-
import type { HybridView, HybridViewMethods, HybridViewProps } from 'react-native-nitro-modules';
|
|
3
|
-
export interface MatiksStrokeTextProps extends HybridViewProps {
|
|
4
|
-
width?: number;
|
|
5
|
-
text: string;
|
|
6
|
-
fontSize?: number;
|
|
7
|
-
color?: string;
|
|
8
|
-
strokeColor?: string;
|
|
9
|
-
strokeWidth?: number;
|
|
10
|
-
fontFamily?: string;
|
|
11
|
-
align?: TextAlign;
|
|
12
|
-
numberOfLines?: number;
|
|
13
|
-
ellipsis?: boolean;
|
|
14
|
-
onDimensionsChange?: (dimensions: Dimensions) => void;
|
|
15
|
-
}
|
|
16
|
-
export interface Dimensions {
|
|
17
|
-
width: number;
|
|
18
|
-
height: number;
|
|
19
|
-
}
|
|
20
|
-
export interface MatiksStrokeTextMethods extends HybridViewMethods {
|
|
21
|
-
measureDimensions(): Dimensions;
|
|
22
|
-
}
|
|
23
|
-
export type MatiksStrokeText = HybridView<MatiksStrokeTextProps, MatiksStrokeTextMethods>;
|
|
24
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|