@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.
- package/NitroRnStrokeText.podspec +31 -0
- package/README.md +38 -0
- package/android/CMakeLists.txt +29 -0
- package/android/build.gradle +138 -0
- package/android/fix-prefab.gradle +51 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/rnstroketext/FontUtil.kt +48 -0
- package/android/src/main/java/com/margelo/nitro/rnstroketext/HybridMatiksStrokeText.kt +80 -0
- package/android/src/main/java/com/margelo/nitro/rnstroketext/NitroRnStrokeTextPackage.kt +28 -0
- package/android/src/main/java/com/margelo/nitro/rnstroketext/StrokeTextView.kt +348 -0
- package/ios/Bridge.h +8 -0
- package/ios/HybridMatiksStrokeText.swift +97 -0
- package/ios/StrokeTextView.swift +174 -0
- package/ios/StrokedTextLabel.swift +62 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.js +23 -0
- package/lib/specs/Stroke.nitro.d.ts +23 -0
- package/lib/specs/Stroke.nitro.js +1 -0
- package/nitro.json +24 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/NitroRnStrokeText+autolinking.cmake +83 -0
- package/nitrogen/generated/android/NitroRnStrokeText+autolinking.gradle +27 -0
- package/nitrogen/generated/android/NitroRnStrokeTextOnLoad.cpp +46 -0
- package/nitrogen/generated/android/NitroRnStrokeTextOnLoad.hpp +25 -0
- package/nitrogen/generated/android/c++/JDimensions.hpp +61 -0
- package/nitrogen/generated/android/c++/JHybridMatiksStrokeTextSpec.cpp +156 -0
- package/nitrogen/generated/android/c++/JHybridMatiksStrokeTextSpec.hpp +85 -0
- package/nitrogen/generated/android/c++/JTextAlign.hpp +61 -0
- package/nitrogen/generated/android/c++/views/JHybridMatiksStrokeTextStateUpdater.cpp +92 -0
- package/nitrogen/generated/android/c++/views/JHybridMatiksStrokeTextStateUpdater.hpp +49 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnstroketext/Dimensions.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnstroketext/HybridMatiksStrokeTextSpec.kt +115 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnstroketext/NitroRnStrokeTextOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnstroketext/TextAlign.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnstroketext/views/HybridMatiksStrokeTextManager.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnstroketext/views/HybridMatiksStrokeTextStateUpdater.kt +23 -0
- package/nitrogen/generated/ios/NitroRnStrokeText+autolinking.rb +60 -0
- package/nitrogen/generated/ios/NitroRnStrokeText-Swift-Cxx-Bridge.cpp +33 -0
- package/nitrogen/generated/ios/NitroRnStrokeText-Swift-Cxx-Bridge.hpp +119 -0
- package/nitrogen/generated/ios/NitroRnStrokeText-Swift-Cxx-Umbrella.hpp +51 -0
- package/nitrogen/generated/ios/NitroRnStrokeTextAutolinking.mm +33 -0
- package/nitrogen/generated/ios/NitroRnStrokeTextAutolinking.swift +25 -0
- package/nitrogen/generated/ios/c++/HybridMatiksStrokeTextSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridMatiksStrokeTextSpecSwift.hpp +157 -0
- package/nitrogen/generated/ios/c++/views/HybridMatiksStrokeTextComponent.mm +147 -0
- package/nitrogen/generated/ios/swift/Dimensions.swift +35 -0
- package/nitrogen/generated/ios/swift/HybridMatiksStrokeTextSpec.swift +65 -0
- package/nitrogen/generated/ios/swift/HybridMatiksStrokeTextSpec_cxx.swift +341 -0
- package/nitrogen/generated/ios/swift/TextAlign.swift +44 -0
- package/nitrogen/generated/shared/c++/Dimensions.hpp +87 -0
- package/nitrogen/generated/shared/c++/HybridMatiksStrokeTextSpec.cpp +41 -0
- package/nitrogen/generated/shared/c++/HybridMatiksStrokeTextSpec.hpp +87 -0
- package/nitrogen/generated/shared/c++/TextAlign.hpp +80 -0
- package/nitrogen/generated/shared/c++/views/HybridMatiksStrokeTextComponent.cpp +196 -0
- package/nitrogen/generated/shared/c++/views/HybridMatiksStrokeTextComponent.hpp +118 -0
- package/nitrogen/generated/shared/json/MatiksStrokeTextConfig.json +19 -0
- package/package.json +107 -0
- package/react-native.config.js +16 -0
- package/src/index.tsx +44 -0
- package/src/specs/Stroke.nitro.ts +34 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHybridMatiksStrokeTextStateUpdater.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 "JHybridMatiksStrokeTextStateUpdater.hpp"
|
|
9
|
+
#include "views/HybridMatiksStrokeTextComponent.hpp"
|
|
10
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
11
|
+
|
|
12
|
+
namespace margelo::nitro::rnstroketext::views {
|
|
13
|
+
|
|
14
|
+
using namespace facebook;
|
|
15
|
+
using ConcreteStateData = react::ConcreteState<HybridMatiksStrokeTextState>;
|
|
16
|
+
|
|
17
|
+
void JHybridMatiksStrokeTextStateUpdater::updateViewProps(jni::alias_ref<jni::JClass> /* class */,
|
|
18
|
+
jni::alias_ref<JHybridMatiksStrokeTextSpec::javaobject> javaView,
|
|
19
|
+
jni::alias_ref<JStateWrapper::javaobject> stateWrapperInterface) {
|
|
20
|
+
JHybridMatiksStrokeTextSpec* view = javaView->cthis();
|
|
21
|
+
|
|
22
|
+
// Get concrete StateWrapperImpl from passed StateWrapper interface object
|
|
23
|
+
jobject rawStateWrapper = stateWrapperInterface.get();
|
|
24
|
+
if (!stateWrapperInterface->isInstanceOf(react::StateWrapperImpl::javaClassStatic())) {
|
|
25
|
+
throw std::runtime_error("StateWrapper is not a StateWrapperImpl");
|
|
26
|
+
}
|
|
27
|
+
auto stateWrapper = jni::alias_ref<react::StateWrapperImpl::javaobject>{
|
|
28
|
+
static_cast<react::StateWrapperImpl::javaobject>(rawStateWrapper)};
|
|
29
|
+
|
|
30
|
+
std::shared_ptr<const react::State> state = stateWrapper->cthis()->getState();
|
|
31
|
+
auto concreteState = std::dynamic_pointer_cast<const ConcreteStateData>(state);
|
|
32
|
+
const HybridMatiksStrokeTextState& data = concreteState->getData();
|
|
33
|
+
const std::optional<HybridMatiksStrokeTextProps>& maybeProps = data.getProps();
|
|
34
|
+
if (!maybeProps.has_value()) {
|
|
35
|
+
// Props aren't set yet!
|
|
36
|
+
throw std::runtime_error("HybridMatiksStrokeTextState's data doesn't contain any props!");
|
|
37
|
+
}
|
|
38
|
+
const HybridMatiksStrokeTextProps& props = maybeProps.value();
|
|
39
|
+
if (props.width.isDirty) {
|
|
40
|
+
view->setWidth(props.width.value);
|
|
41
|
+
// TODO: Set isDirty = false
|
|
42
|
+
}
|
|
43
|
+
if (props.text.isDirty) {
|
|
44
|
+
view->setText(props.text.value);
|
|
45
|
+
// TODO: Set isDirty = false
|
|
46
|
+
}
|
|
47
|
+
if (props.fontSize.isDirty) {
|
|
48
|
+
view->setFontSize(props.fontSize.value);
|
|
49
|
+
// TODO: Set isDirty = false
|
|
50
|
+
}
|
|
51
|
+
if (props.color.isDirty) {
|
|
52
|
+
view->setColor(props.color.value);
|
|
53
|
+
// TODO: Set isDirty = false
|
|
54
|
+
}
|
|
55
|
+
if (props.strokeColor.isDirty) {
|
|
56
|
+
view->setStrokeColor(props.strokeColor.value);
|
|
57
|
+
// TODO: Set isDirty = false
|
|
58
|
+
}
|
|
59
|
+
if (props.strokeWidth.isDirty) {
|
|
60
|
+
view->setStrokeWidth(props.strokeWidth.value);
|
|
61
|
+
// TODO: Set isDirty = false
|
|
62
|
+
}
|
|
63
|
+
if (props.fontFamily.isDirty) {
|
|
64
|
+
view->setFontFamily(props.fontFamily.value);
|
|
65
|
+
// TODO: Set isDirty = false
|
|
66
|
+
}
|
|
67
|
+
if (props.align.isDirty) {
|
|
68
|
+
view->setAlign(props.align.value);
|
|
69
|
+
// TODO: Set isDirty = false
|
|
70
|
+
}
|
|
71
|
+
if (props.numberOfLines.isDirty) {
|
|
72
|
+
view->setNumberOfLines(props.numberOfLines.value);
|
|
73
|
+
// TODO: Set isDirty = false
|
|
74
|
+
}
|
|
75
|
+
if (props.ellipsis.isDirty) {
|
|
76
|
+
view->setEllipsis(props.ellipsis.value);
|
|
77
|
+
// TODO: Set isDirty = false
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Update hybridRef if it changed
|
|
81
|
+
if (props.hybridRef.isDirty) {
|
|
82
|
+
// hybridRef changed - call it with new this
|
|
83
|
+
const auto& maybeFunc = props.hybridRef.value;
|
|
84
|
+
if (maybeFunc.has_value()) {
|
|
85
|
+
std::shared_ptr<JHybridMatiksStrokeTextSpec> shared = javaView->cthis()->shared_cast<JHybridMatiksStrokeTextSpec>();
|
|
86
|
+
maybeFunc.value()(shared);
|
|
87
|
+
}
|
|
88
|
+
// TODO: Set isDirty = false
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
} // namespace margelo::nitro::rnstroketext::views
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHybridMatiksStrokeTextStateUpdater.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
|
+
#ifndef RN_SERIALIZABLE_STATE
|
|
11
|
+
#error NitroRnStrokeText was compiled without the 'RN_SERIALIZABLE_STATE' flag. This flag is required for Nitro Views - set it in your CMakeLists!
|
|
12
|
+
#endif
|
|
13
|
+
|
|
14
|
+
#include <fbjni/fbjni.h>
|
|
15
|
+
#include <react/fabric/StateWrapperImpl.h>
|
|
16
|
+
#include <react/fabric/CoreComponentsRegistry.h>
|
|
17
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
18
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
19
|
+
#include <NitroModules/JStateWrapper.hpp>
|
|
20
|
+
#include "JHybridMatiksStrokeTextSpec.hpp"
|
|
21
|
+
#include "views/HybridMatiksStrokeTextComponent.hpp"
|
|
22
|
+
|
|
23
|
+
namespace margelo::nitro::rnstroketext::views {
|
|
24
|
+
|
|
25
|
+
using namespace facebook;
|
|
26
|
+
|
|
27
|
+
class JHybridMatiksStrokeTextStateUpdater: public jni::JavaClass<JHybridMatiksStrokeTextStateUpdater> {
|
|
28
|
+
public:
|
|
29
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/rnstroketext/views/HybridMatiksStrokeTextStateUpdater;";
|
|
30
|
+
|
|
31
|
+
public:
|
|
32
|
+
static void updateViewProps(jni::alias_ref<jni::JClass> /* class */,
|
|
33
|
+
jni::alias_ref<JHybridMatiksStrokeTextSpec::javaobject> view,
|
|
34
|
+
jni::alias_ref<JStateWrapper::javaobject> stateWrapperInterface);
|
|
35
|
+
|
|
36
|
+
public:
|
|
37
|
+
static void registerNatives() {
|
|
38
|
+
// Register JNI calls
|
|
39
|
+
javaClassStatic()->registerNatives({
|
|
40
|
+
makeNativeMethod("updateViewProps", JHybridMatiksStrokeTextStateUpdater::updateViewProps),
|
|
41
|
+
});
|
|
42
|
+
// Register React Native view component descriptor
|
|
43
|
+
auto provider = react::concreteComponentDescriptorProvider<HybridMatiksStrokeTextComponentDescriptor>();
|
|
44
|
+
auto providerRegistry = react::CoreComponentsRegistry::sharedProviderRegistry();
|
|
45
|
+
providerRegistry->add(provider);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
} // namespace margelo::nitro::rnstroketext::views
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Dimensions.kt
|
|
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
|
+
package com.margelo.nitro.rnstroketext
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Represents the JavaScript object/struct "Dimensions".
|
|
16
|
+
*/
|
|
17
|
+
@DoNotStrip
|
|
18
|
+
@Keep
|
|
19
|
+
data class Dimensions(
|
|
20
|
+
@DoNotStrip
|
|
21
|
+
@Keep
|
|
22
|
+
val width: Double,
|
|
23
|
+
@DoNotStrip
|
|
24
|
+
@Keep
|
|
25
|
+
val height: Double
|
|
26
|
+
) {
|
|
27
|
+
/* primary constructor */
|
|
28
|
+
|
|
29
|
+
companion object {
|
|
30
|
+
/**
|
|
31
|
+
* Constructor called from C++
|
|
32
|
+
*/
|
|
33
|
+
@DoNotStrip
|
|
34
|
+
@Keep
|
|
35
|
+
@Suppress("unused")
|
|
36
|
+
@JvmStatic
|
|
37
|
+
private fun fromCpp(width: Double, height: Double): Dimensions {
|
|
38
|
+
return Dimensions(width, height)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridMatiksStrokeTextSpec.kt
|
|
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
|
+
package com.margelo.nitro.rnstroketext
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
import com.margelo.nitro.views.HybridView
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A Kotlin class representing the MatiksStrokeText HybridObject.
|
|
17
|
+
* Implement this abstract class to create Kotlin-based instances of MatiksStrokeText.
|
|
18
|
+
*/
|
|
19
|
+
@DoNotStrip
|
|
20
|
+
@Keep
|
|
21
|
+
@Suppress(
|
|
22
|
+
"KotlinJniMissingFunction", "unused",
|
|
23
|
+
"RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
|
|
24
|
+
"LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
|
|
25
|
+
)
|
|
26
|
+
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
|
+
// Properties
|
|
45
|
+
@get:DoNotStrip
|
|
46
|
+
@get:Keep
|
|
47
|
+
@set:DoNotStrip
|
|
48
|
+
@set:Keep
|
|
49
|
+
abstract var width: Double?
|
|
50
|
+
|
|
51
|
+
@get:DoNotStrip
|
|
52
|
+
@get:Keep
|
|
53
|
+
@set:DoNotStrip
|
|
54
|
+
@set:Keep
|
|
55
|
+
abstract var text: String
|
|
56
|
+
|
|
57
|
+
@get:DoNotStrip
|
|
58
|
+
@get:Keep
|
|
59
|
+
@set:DoNotStrip
|
|
60
|
+
@set:Keep
|
|
61
|
+
abstract var fontSize: Double?
|
|
62
|
+
|
|
63
|
+
@get:DoNotStrip
|
|
64
|
+
@get:Keep
|
|
65
|
+
@set:DoNotStrip
|
|
66
|
+
@set:Keep
|
|
67
|
+
abstract var color: String?
|
|
68
|
+
|
|
69
|
+
@get:DoNotStrip
|
|
70
|
+
@get:Keep
|
|
71
|
+
@set:DoNotStrip
|
|
72
|
+
@set:Keep
|
|
73
|
+
abstract var strokeColor: String?
|
|
74
|
+
|
|
75
|
+
@get:DoNotStrip
|
|
76
|
+
@get:Keep
|
|
77
|
+
@set:DoNotStrip
|
|
78
|
+
@set:Keep
|
|
79
|
+
abstract var strokeWidth: Double?
|
|
80
|
+
|
|
81
|
+
@get:DoNotStrip
|
|
82
|
+
@get:Keep
|
|
83
|
+
@set:DoNotStrip
|
|
84
|
+
@set:Keep
|
|
85
|
+
abstract var fontFamily: String?
|
|
86
|
+
|
|
87
|
+
@get:DoNotStrip
|
|
88
|
+
@get:Keep
|
|
89
|
+
@set:DoNotStrip
|
|
90
|
+
@set:Keep
|
|
91
|
+
abstract var align: TextAlign?
|
|
92
|
+
|
|
93
|
+
@get:DoNotStrip
|
|
94
|
+
@get:Keep
|
|
95
|
+
@set:DoNotStrip
|
|
96
|
+
@set:Keep
|
|
97
|
+
abstract var numberOfLines: Double?
|
|
98
|
+
|
|
99
|
+
@get:DoNotStrip
|
|
100
|
+
@get:Keep
|
|
101
|
+
@set:DoNotStrip
|
|
102
|
+
@set:Keep
|
|
103
|
+
abstract var ellipsis: Boolean?
|
|
104
|
+
|
|
105
|
+
// Methods
|
|
106
|
+
@DoNotStrip
|
|
107
|
+
@Keep
|
|
108
|
+
abstract fun measureDimensions(): Dimensions
|
|
109
|
+
|
|
110
|
+
private external fun initHybrid(): HybridData
|
|
111
|
+
|
|
112
|
+
companion object {
|
|
113
|
+
protected const val TAG = "HybridMatiksStrokeTextSpec"
|
|
114
|
+
}
|
|
115
|
+
}
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnstroketext/NitroRnStrokeTextOnLoad.kt
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroRnStrokeTextOnLoad.kt
|
|
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
|
+
package com.margelo.nitro.rnstroketext
|
|
9
|
+
|
|
10
|
+
import android.util.Log
|
|
11
|
+
|
|
12
|
+
internal class NitroRnStrokeTextOnLoad {
|
|
13
|
+
companion object {
|
|
14
|
+
private const val TAG = "NitroRnStrokeTextOnLoad"
|
|
15
|
+
private var didLoad = false
|
|
16
|
+
/**
|
|
17
|
+
* Initializes the native part of "NitroRnStrokeText".
|
|
18
|
+
* This method is idempotent and can be called more than once.
|
|
19
|
+
*/
|
|
20
|
+
@JvmStatic
|
|
21
|
+
fun initializeNative() {
|
|
22
|
+
if (didLoad) return
|
|
23
|
+
try {
|
|
24
|
+
Log.i(TAG, "Loading NitroRnStrokeText C++ library...")
|
|
25
|
+
System.loadLibrary("NitroRnStrokeText")
|
|
26
|
+
Log.i(TAG, "Successfully loaded NitroRnStrokeText C++ library!")
|
|
27
|
+
didLoad = true
|
|
28
|
+
} catch (e: Error) {
|
|
29
|
+
Log.e(TAG, "Failed to load NitroRnStrokeText C++ library! Is it properly installed and linked? " +
|
|
30
|
+
"Is the name correct? (see `CMakeLists.txt`, at `add_library(...)`)", e)
|
|
31
|
+
throw e
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// TextAlign.kt
|
|
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
|
+
package com.margelo.nitro.rnstroketext
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Represents the JavaScript enum/union "TextAlign".
|
|
15
|
+
*/
|
|
16
|
+
@DoNotStrip
|
|
17
|
+
@Keep
|
|
18
|
+
enum class TextAlign(@DoNotStrip @Keep val value: Int) {
|
|
19
|
+
CENTER(0),
|
|
20
|
+
LEFT(1),
|
|
21
|
+
RIGHT(2);
|
|
22
|
+
|
|
23
|
+
companion object
|
|
24
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridMatiksStrokeTextManager.kt
|
|
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
|
+
package com.margelo.nitro.rnstroketext.views
|
|
9
|
+
|
|
10
|
+
import android.view.View
|
|
11
|
+
import com.facebook.react.uimanager.ReactStylesDiffMap
|
|
12
|
+
import com.facebook.react.uimanager.SimpleViewManager
|
|
13
|
+
import com.facebook.react.uimanager.StateWrapper
|
|
14
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
15
|
+
import com.margelo.nitro.rnstroketext.*
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Represents the React Native `ViewManager` for the "MatiksStrokeText" Nitro HybridView.
|
|
19
|
+
*/
|
|
20
|
+
open class HybridMatiksStrokeTextManager: SimpleViewManager<View>() {
|
|
21
|
+
private val views = hashMapOf<View, HybridMatiksStrokeText>()
|
|
22
|
+
|
|
23
|
+
override fun getName(): String {
|
|
24
|
+
return "MatiksStrokeText"
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
override fun createViewInstance(reactContext: ThemedReactContext): View {
|
|
28
|
+
val hybridView = HybridMatiksStrokeText(reactContext)
|
|
29
|
+
val view = hybridView.view
|
|
30
|
+
views[view] = hybridView
|
|
31
|
+
return view
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
override fun onDropViewInstance(view: View) {
|
|
35
|
+
super.onDropViewInstance(view)
|
|
36
|
+
views.remove(view)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
override fun updateState(view: View, props: ReactStylesDiffMap, stateWrapper: StateWrapper): Any? {
|
|
40
|
+
val hybridView = views[view] ?: throw Error("Couldn't find view $view in local views table!")
|
|
41
|
+
|
|
42
|
+
// 1. Update each prop individually
|
|
43
|
+
hybridView.beforeUpdate()
|
|
44
|
+
HybridMatiksStrokeTextStateUpdater.updateViewProps(hybridView, stateWrapper)
|
|
45
|
+
hybridView.afterUpdate()
|
|
46
|
+
|
|
47
|
+
// 2. Continue in base View props
|
|
48
|
+
return super.updateState(view, props, stateWrapper)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
protected override fun setupViewRecycling() {
|
|
52
|
+
// TODO: Recycling should be controllable by the user. WIP, but disabled for now.
|
|
53
|
+
// By not calling `super.setupViewRecycling()`, we effectively
|
|
54
|
+
// disable view recycling for now.
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridMatiksStrokeTextStateUpdater.kt
|
|
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
|
+
package com.margelo.nitro.rnstroketext.views
|
|
9
|
+
|
|
10
|
+
import com.facebook.react.uimanager.StateWrapper
|
|
11
|
+
import com.margelo.nitro.rnstroketext.*
|
|
12
|
+
|
|
13
|
+
internal class HybridMatiksStrokeTextStateUpdater {
|
|
14
|
+
companion object {
|
|
15
|
+
/**
|
|
16
|
+
* Updates the props for [view] through C++.
|
|
17
|
+
* The [state] prop is expected to contain [view]'s props as wrapped Fabric state.
|
|
18
|
+
*/
|
|
19
|
+
@Suppress("KotlinJniMissingFunction")
|
|
20
|
+
@JvmStatic
|
|
21
|
+
external fun updateViewProps(view: HybridMatiksStrokeTextSpec, state: StateWrapper)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#
|
|
2
|
+
# NitroRnStrokeText+autolinking.rb
|
|
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
|
+
# This is a Ruby script that adds all files generated by Nitrogen
|
|
9
|
+
# to the given podspec.
|
|
10
|
+
#
|
|
11
|
+
# To use it, add this to your .podspec:
|
|
12
|
+
# ```ruby
|
|
13
|
+
# Pod::Spec.new do |spec|
|
|
14
|
+
# # ...
|
|
15
|
+
#
|
|
16
|
+
# # Add all files generated by Nitrogen
|
|
17
|
+
# load 'nitrogen/generated/ios/NitroRnStrokeText+autolinking.rb'
|
|
18
|
+
# add_nitrogen_files(spec)
|
|
19
|
+
# end
|
|
20
|
+
# ```
|
|
21
|
+
|
|
22
|
+
def add_nitrogen_files(spec)
|
|
23
|
+
Pod::UI.puts "[NitroModules] 🔥 NitroRnStrokeText is boosted by nitro!"
|
|
24
|
+
|
|
25
|
+
spec.dependency "NitroModules"
|
|
26
|
+
|
|
27
|
+
current_source_files = Array(spec.attributes_hash['source_files'])
|
|
28
|
+
spec.source_files = current_source_files + [
|
|
29
|
+
# Generated cross-platform specs
|
|
30
|
+
"nitrogen/generated/shared/**/*.{h,hpp,c,cpp,swift}",
|
|
31
|
+
# Generated bridges for the cross-platform specs
|
|
32
|
+
"nitrogen/generated/ios/**/*.{h,hpp,c,cpp,mm,swift}",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
current_public_header_files = Array(spec.attributes_hash['public_header_files'])
|
|
36
|
+
spec.public_header_files = current_public_header_files + [
|
|
37
|
+
# Generated specs
|
|
38
|
+
"nitrogen/generated/shared/**/*.{h,hpp}",
|
|
39
|
+
# Swift to C++ bridging helpers
|
|
40
|
+
"nitrogen/generated/ios/NitroRnStrokeText-Swift-Cxx-Bridge.hpp"
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
current_private_header_files = Array(spec.attributes_hash['private_header_files'])
|
|
44
|
+
spec.private_header_files = current_private_header_files + [
|
|
45
|
+
# iOS specific specs
|
|
46
|
+
"nitrogen/generated/ios/c++/**/*.{h,hpp}",
|
|
47
|
+
# Views are framework-specific and should be private
|
|
48
|
+
"nitrogen/generated/shared/**/views/**/*"
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
current_pod_target_xcconfig = spec.attributes_hash['pod_target_xcconfig'] || {}
|
|
52
|
+
spec.pod_target_xcconfig = current_pod_target_xcconfig.merge({
|
|
53
|
+
# Use C++ 20
|
|
54
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
|
|
55
|
+
# Enables C++ <-> Swift interop (by default it's only ObjC)
|
|
56
|
+
"SWIFT_OBJC_INTEROP_MODE" => "objcxx",
|
|
57
|
+
# Enables stricter modular headers
|
|
58
|
+
"DEFINES_MODULE" => "YES",
|
|
59
|
+
})
|
|
60
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroRnStrokeText-Swift-Cxx-Bridge.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 "NitroRnStrokeText-Swift-Cxx-Bridge.hpp"
|
|
9
|
+
|
|
10
|
+
// Include C++ implementation defined types
|
|
11
|
+
#include "HybridMatiksStrokeTextSpecSwift.hpp"
|
|
12
|
+
#include "NitroRnStrokeText-Swift-Cxx-Umbrella.hpp"
|
|
13
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro::rnstroketext::bridge::swift {
|
|
16
|
+
|
|
17
|
+
// pragma MARK: std::shared_ptr<HybridMatiksStrokeTextSpec>
|
|
18
|
+
std::shared_ptr<HybridMatiksStrokeTextSpec> create_std__shared_ptr_HybridMatiksStrokeTextSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
|
|
19
|
+
NitroRnStrokeText::HybridMatiksStrokeTextSpec_cxx swiftPart = NitroRnStrokeText::HybridMatiksStrokeTextSpec_cxx::fromUnsafe(swiftUnsafePointer);
|
|
20
|
+
return std::make_shared<margelo::nitro::rnstroketext::HybridMatiksStrokeTextSpecSwift>(swiftPart);
|
|
21
|
+
}
|
|
22
|
+
void* NON_NULL get_std__shared_ptr_HybridMatiksStrokeTextSpec_(std__shared_ptr_HybridMatiksStrokeTextSpec_ cppType) {
|
|
23
|
+
std::shared_ptr<margelo::nitro::rnstroketext::HybridMatiksStrokeTextSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::rnstroketext::HybridMatiksStrokeTextSpecSwift>(cppType);
|
|
24
|
+
#ifdef NITRO_DEBUG
|
|
25
|
+
if (swiftWrapper == nullptr) [[unlikely]] {
|
|
26
|
+
throw std::runtime_error("Class \"HybridMatiksStrokeTextSpec\" is not implemented in Swift!");
|
|
27
|
+
}
|
|
28
|
+
#endif
|
|
29
|
+
NitroRnStrokeText::HybridMatiksStrokeTextSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
|
|
30
|
+
return swiftPart.toUnsafe();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
} // namespace margelo::nitro::rnstroketext::bridge::swift
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroRnStrokeText-Swift-Cxx-Bridge.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
// Forward declarations of C++ defined types
|
|
11
|
+
// Forward declaration of `Dimensions` to properly resolve imports.
|
|
12
|
+
namespace margelo::nitro::rnstroketext { struct Dimensions; }
|
|
13
|
+
// Forward declaration of `HybridMatiksStrokeTextSpec` to properly resolve imports.
|
|
14
|
+
namespace margelo::nitro::rnstroketext { class HybridMatiksStrokeTextSpec; }
|
|
15
|
+
// Forward declaration of `TextAlign` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::rnstroketext { enum class TextAlign; }
|
|
17
|
+
|
|
18
|
+
// Forward declarations of Swift defined types
|
|
19
|
+
// Forward declaration of `HybridMatiksStrokeTextSpec_cxx` to properly resolve imports.
|
|
20
|
+
namespace NitroRnStrokeText { class HybridMatiksStrokeTextSpec_cxx; }
|
|
21
|
+
|
|
22
|
+
// Include C++ defined types
|
|
23
|
+
#include "Dimensions.hpp"
|
|
24
|
+
#include "HybridMatiksStrokeTextSpec.hpp"
|
|
25
|
+
#include "TextAlign.hpp"
|
|
26
|
+
#include <NitroModules/Result.hpp>
|
|
27
|
+
#include <exception>
|
|
28
|
+
#include <memory>
|
|
29
|
+
#include <optional>
|
|
30
|
+
#include <string>
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Contains specialized versions of C++ templated types so they can be accessed from Swift,
|
|
34
|
+
* as well as helper functions to interact with those C++ types from Swift.
|
|
35
|
+
*/
|
|
36
|
+
namespace margelo::nitro::rnstroketext::bridge::swift {
|
|
37
|
+
|
|
38
|
+
// pragma MARK: std::optional<double>
|
|
39
|
+
/**
|
|
40
|
+
* Specialized version of `std::optional<double>`.
|
|
41
|
+
*/
|
|
42
|
+
using std__optional_double_ = std::optional<double>;
|
|
43
|
+
inline std::optional<double> create_std__optional_double_(const double& value) noexcept {
|
|
44
|
+
return std::optional<double>(value);
|
|
45
|
+
}
|
|
46
|
+
inline bool has_value_std__optional_double_(const std::optional<double>& optional) noexcept {
|
|
47
|
+
return optional.has_value();
|
|
48
|
+
}
|
|
49
|
+
inline double get_std__optional_double_(const std::optional<double>& optional) noexcept {
|
|
50
|
+
return *optional;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// pragma MARK: std::optional<std::string>
|
|
54
|
+
/**
|
|
55
|
+
* Specialized version of `std::optional<std::string>`.
|
|
56
|
+
*/
|
|
57
|
+
using std__optional_std__string_ = std::optional<std::string>;
|
|
58
|
+
inline std::optional<std::string> create_std__optional_std__string_(const std::string& value) noexcept {
|
|
59
|
+
return std::optional<std::string>(value);
|
|
60
|
+
}
|
|
61
|
+
inline bool has_value_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
|
|
62
|
+
return optional.has_value();
|
|
63
|
+
}
|
|
64
|
+
inline std::string get_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
|
|
65
|
+
return *optional;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// pragma MARK: std::optional<TextAlign>
|
|
69
|
+
/**
|
|
70
|
+
* Specialized version of `std::optional<TextAlign>`.
|
|
71
|
+
*/
|
|
72
|
+
using std__optional_TextAlign_ = std::optional<TextAlign>;
|
|
73
|
+
inline std::optional<TextAlign> create_std__optional_TextAlign_(const TextAlign& value) noexcept {
|
|
74
|
+
return std::optional<TextAlign>(value);
|
|
75
|
+
}
|
|
76
|
+
inline bool has_value_std__optional_TextAlign_(const std::optional<TextAlign>& optional) noexcept {
|
|
77
|
+
return optional.has_value();
|
|
78
|
+
}
|
|
79
|
+
inline TextAlign get_std__optional_TextAlign_(const std::optional<TextAlign>& optional) noexcept {
|
|
80
|
+
return *optional;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// pragma MARK: std::optional<bool>
|
|
84
|
+
/**
|
|
85
|
+
* Specialized version of `std::optional<bool>`.
|
|
86
|
+
*/
|
|
87
|
+
using std__optional_bool_ = std::optional<bool>;
|
|
88
|
+
inline std::optional<bool> create_std__optional_bool_(const bool& value) noexcept {
|
|
89
|
+
return std::optional<bool>(value);
|
|
90
|
+
}
|
|
91
|
+
inline bool has_value_std__optional_bool_(const std::optional<bool>& optional) noexcept {
|
|
92
|
+
return optional.has_value();
|
|
93
|
+
}
|
|
94
|
+
inline bool get_std__optional_bool_(const std::optional<bool>& optional) noexcept {
|
|
95
|
+
return *optional;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// pragma MARK: std::shared_ptr<HybridMatiksStrokeTextSpec>
|
|
99
|
+
/**
|
|
100
|
+
* Specialized version of `std::shared_ptr<HybridMatiksStrokeTextSpec>`.
|
|
101
|
+
*/
|
|
102
|
+
using std__shared_ptr_HybridMatiksStrokeTextSpec_ = std::shared_ptr<HybridMatiksStrokeTextSpec>;
|
|
103
|
+
std::shared_ptr<HybridMatiksStrokeTextSpec> create_std__shared_ptr_HybridMatiksStrokeTextSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
|
|
104
|
+
void* NON_NULL get_std__shared_ptr_HybridMatiksStrokeTextSpec_(std__shared_ptr_HybridMatiksStrokeTextSpec_ cppType);
|
|
105
|
+
|
|
106
|
+
// pragma MARK: std::weak_ptr<HybridMatiksStrokeTextSpec>
|
|
107
|
+
using std__weak_ptr_HybridMatiksStrokeTextSpec_ = std::weak_ptr<HybridMatiksStrokeTextSpec>;
|
|
108
|
+
inline std__weak_ptr_HybridMatiksStrokeTextSpec_ weakify_std__shared_ptr_HybridMatiksStrokeTextSpec_(const std::shared_ptr<HybridMatiksStrokeTextSpec>& strong) noexcept { return strong; }
|
|
109
|
+
|
|
110
|
+
// pragma MARK: Result<Dimensions>
|
|
111
|
+
using Result_Dimensions_ = Result<Dimensions>;
|
|
112
|
+
inline Result_Dimensions_ create_Result_Dimensions_(const Dimensions& value) noexcept {
|
|
113
|
+
return Result<Dimensions>::withValue(value);
|
|
114
|
+
}
|
|
115
|
+
inline Result_Dimensions_ create_Result_Dimensions_(const std::exception_ptr& error) noexcept {
|
|
116
|
+
return Result<Dimensions>::withError(error);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
} // namespace margelo::nitro::rnstroketext::bridge::swift
|