@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
package/lib/index.js ADDED
@@ -0,0 +1,23 @@
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 = ({ styles, ...props }) => {
7
+ const ref = useRef(null);
8
+ const [size, setSize] = useState({ width: 0, height: 0 });
9
+ useEffect(() => {
10
+ if (!ref.current)
11
+ return;
12
+ const result = ref.current.measureDimensions();
13
+ setSize(result);
14
+ }, [
15
+ props.fontFamily,
16
+ props.fontSize,
17
+ props.text,
18
+ ]);
19
+ return (React.createElement(StrokeTextViewComponent, { ...props, style: [{ width: size.width, height: size.height }, styles], hybridRef: callback((_ref) => {
20
+ ref.current = _ref;
21
+ }) }));
22
+ };
23
+ export default React.memo(StrokeTextView);
@@ -0,0 +1,23 @@
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
+ }
15
+ export interface Dimensions {
16
+ width: number;
17
+ height: number;
18
+ }
19
+ export interface MatiksStrokeTextMethods extends HybridViewMethods {
20
+ measureDimensions(): Dimensions;
21
+ }
22
+ export type MatiksStrokeText = HybridView<MatiksStrokeTextProps, MatiksStrokeTextMethods>;
23
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/nitro.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "$schema": "https://nitro.margelo.com/nitro.schema.json",
3
+ "cxxNamespace": [
4
+ "rnstroketext"
5
+ ],
6
+ "ios": {
7
+ "iosModuleName": "NitroRnStrokeText"
8
+ },
9
+ "android": {
10
+ "androidNamespace": [
11
+ "rnstroketext"
12
+ ],
13
+ "androidCxxLibName": "NitroRnStrokeText"
14
+ },
15
+ "autolinking": {
16
+ "MatiksStrokeText": {
17
+ "swift": "HybridMatiksStrokeText",
18
+ "kotlin": "HybridMatiksStrokeText"
19
+ }
20
+ },
21
+ "ignorePaths": [
22
+ "**/node_modules"
23
+ ]
24
+ }
@@ -0,0 +1 @@
1
+ ** linguist-generated=true
@@ -0,0 +1,83 @@
1
+ #
2
+ # NitroRnStrokeText+autolinking.cmake
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 CMake file that adds all files generated by Nitrogen
9
+ # to the current CMake project.
10
+ #
11
+ # To use it, add this to your CMakeLists.txt:
12
+ # ```cmake
13
+ # include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/NitroRnStrokeText+autolinking.cmake)
14
+ # ```
15
+
16
+ # Define a flag to check if we are building properly
17
+ add_definitions(-DBUILDING_NITRORNSTROKETEXT_WITH_GENERATED_CMAKE_PROJECT)
18
+
19
+ # Enable Raw Props parsing in react-native (for Nitro Views)
20
+ add_definitions(-DRN_SERIALIZABLE_STATE)
21
+
22
+ # Add all headers that were generated by Nitrogen
23
+ include_directories(
24
+ "../nitrogen/generated/shared/c++"
25
+ "../nitrogen/generated/android/c++"
26
+ "../nitrogen/generated/android/"
27
+ )
28
+
29
+ # Add all .cpp sources that were generated by Nitrogen
30
+ target_sources(
31
+ # CMake project name (Android C++ library name)
32
+ NitroRnStrokeText PRIVATE
33
+ # Autolinking Setup
34
+ ../nitrogen/generated/android/NitroRnStrokeTextOnLoad.cpp
35
+ # Shared Nitrogen C++ sources
36
+ ../nitrogen/generated/shared/c++/HybridMatiksStrokeTextSpec.cpp
37
+ ../nitrogen/generated/shared/c++/views/HybridMatiksStrokeTextComponent.cpp
38
+ # Android-specific Nitrogen C++ sources
39
+ ../nitrogen/generated/android/c++/JHybridMatiksStrokeTextSpec.cpp
40
+ ../nitrogen/generated/android/c++/views/JHybridMatiksStrokeTextStateUpdater.cpp
41
+ )
42
+
43
+ # From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
44
+ # Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
45
+ target_compile_definitions(
46
+ NitroRnStrokeText PRIVATE
47
+ -DFOLLY_NO_CONFIG=1
48
+ -DFOLLY_HAVE_CLOCK_GETTIME=1
49
+ -DFOLLY_USE_LIBCPP=1
50
+ -DFOLLY_CFG_NO_COROUTINES=1
51
+ -DFOLLY_MOBILE=1
52
+ -DFOLLY_HAVE_RECVMMSG=1
53
+ -DFOLLY_HAVE_PTHREAD=1
54
+ # Once we target android-23 above, we can comment
55
+ # the following line. NDK uses GNU style stderror_r() after API 23.
56
+ -DFOLLY_HAVE_XSI_STRERROR_R=1
57
+ )
58
+
59
+ # Add all libraries required by the generated specs
60
+ find_package(fbjni REQUIRED) # <-- Used for communication between Java <-> C++
61
+ find_package(ReactAndroid REQUIRED) # <-- Used to set up React Native bindings (e.g. CallInvoker/TurboModule)
62
+ find_package(react-native-nitro-modules REQUIRED) # <-- Used to create all HybridObjects and use the Nitro core library
63
+
64
+ # Link all libraries together
65
+ target_link_libraries(
66
+ NitroRnStrokeText
67
+ fbjni::fbjni # <-- Facebook C++ JNI helpers
68
+ ReactAndroid::jsi # <-- RN: JSI
69
+ react-native-nitro-modules::NitroModules # <-- NitroModules Core :)
70
+ )
71
+
72
+ # Link react-native (different prefab between RN 0.75 and RN 0.76)
73
+ if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
74
+ target_link_libraries(
75
+ NitroRnStrokeText
76
+ ReactAndroid::reactnative # <-- RN: Native Modules umbrella prefab
77
+ )
78
+ else()
79
+ target_link_libraries(
80
+ NitroRnStrokeText
81
+ ReactAndroid::react_nativemodule_core # <-- RN: TurboModules Core
82
+ )
83
+ endif()
@@ -0,0 +1,27 @@
1
+ ///
2
+ /// NitroRnStrokeText+autolinking.gradle
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 Gradle file that adds all files generated by Nitrogen
9
+ /// to the current Gradle project.
10
+ ///
11
+ /// To use it, add this to your build.gradle:
12
+ /// ```gradle
13
+ /// apply from: '../nitrogen/generated/android/NitroRnStrokeText+autolinking.gradle'
14
+ /// ```
15
+
16
+ logger.warn("[NitroModules] 🔥 NitroRnStrokeText is boosted by nitro!")
17
+
18
+ android {
19
+ sourceSets {
20
+ main {
21
+ java.srcDirs += [
22
+ // Nitrogen files
23
+ "${project.projectDir}/../nitrogen/generated/android/kotlin"
24
+ ]
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,46 @@
1
+ ///
2
+ /// NitroRnStrokeTextOnLoad.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
+ #ifndef BUILDING_NITRORNSTROKETEXT_WITH_GENERATED_CMAKE_PROJECT
9
+ #error NitroRnStrokeTextOnLoad.cpp is not being built with the autogenerated CMakeLists.txt project. Is a different CMakeLists.txt building this?
10
+ #endif
11
+
12
+ #include "NitroRnStrokeTextOnLoad.hpp"
13
+
14
+ #include <jni.h>
15
+ #include <fbjni/fbjni.h>
16
+ #include <NitroModules/HybridObjectRegistry.hpp>
17
+
18
+ #include "JHybridMatiksStrokeTextSpec.hpp"
19
+ #include "views/JHybridMatiksStrokeTextStateUpdater.hpp"
20
+ #include <NitroModules/DefaultConstructableObject.hpp>
21
+
22
+ namespace margelo::nitro::rnstroketext {
23
+
24
+ int initialize(JavaVM* vm) {
25
+ using namespace margelo::nitro;
26
+ using namespace margelo::nitro::rnstroketext;
27
+ using namespace facebook;
28
+
29
+ return facebook::jni::initialize(vm, [] {
30
+ // Register native JNI methods
31
+ margelo::nitro::rnstroketext::JHybridMatiksStrokeTextSpec::registerNatives();
32
+ margelo::nitro::rnstroketext::views::JHybridMatiksStrokeTextStateUpdater::registerNatives();
33
+
34
+ // Register Nitro Hybrid Objects
35
+ HybridObjectRegistry::registerHybridObjectConstructor(
36
+ "MatiksStrokeText",
37
+ []() -> std::shared_ptr<HybridObject> {
38
+ static DefaultConstructableObject<JHybridMatiksStrokeTextSpec::javaobject> object("com/margelo/nitro/rnstroketext/HybridMatiksStrokeText");
39
+ auto instance = object.create();
40
+ return instance->cthis()->shared();
41
+ }
42
+ );
43
+ });
44
+ }
45
+
46
+ } // namespace margelo::nitro::rnstroketext
@@ -0,0 +1,25 @@
1
+ ///
2
+ /// NitroRnStrokeTextOnLoad.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
+ #include <jni.h>
9
+ #include <NitroModules/NitroDefines.hpp>
10
+
11
+ namespace margelo::nitro::rnstroketext {
12
+
13
+ /**
14
+ * Initializes the native (C++) part of NitroRnStrokeText, and autolinks all Hybrid Objects.
15
+ * Call this in your `JNI_OnLoad` function (probably inside `cpp-adapter.cpp`).
16
+ * Example:
17
+ * ```cpp (cpp-adapter.cpp)
18
+ * JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
19
+ * return margelo::nitro::rnstroketext::initialize(vm);
20
+ * }
21
+ * ```
22
+ */
23
+ int initialize(JavaVM* vm);
24
+
25
+ } // namespace margelo::nitro::rnstroketext
@@ -0,0 +1,61 @@
1
+ ///
2
+ /// JDimensions.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <fbjni/fbjni.h>
11
+ #include "Dimensions.hpp"
12
+
13
+
14
+
15
+ namespace margelo::nitro::rnstroketext {
16
+
17
+ using namespace facebook;
18
+
19
+ /**
20
+ * The C++ JNI bridge between the C++ struct "Dimensions" and the the Kotlin data class "Dimensions".
21
+ */
22
+ struct JDimensions final: public jni::JavaClass<JDimensions> {
23
+ public:
24
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/rnstroketext/Dimensions;";
25
+
26
+ public:
27
+ /**
28
+ * Convert this Java/Kotlin-based struct to the C++ struct Dimensions by copying all values to C++.
29
+ */
30
+ [[maybe_unused]]
31
+ [[nodiscard]]
32
+ Dimensions toCpp() const {
33
+ static const auto clazz = javaClassStatic();
34
+ static const auto fieldWidth = clazz->getField<double>("width");
35
+ double width = this->getFieldValue(fieldWidth);
36
+ static const auto fieldHeight = clazz->getField<double>("height");
37
+ double height = this->getFieldValue(fieldHeight);
38
+ return Dimensions(
39
+ width,
40
+ height
41
+ );
42
+ }
43
+
44
+ public:
45
+ /**
46
+ * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
47
+ */
48
+ [[maybe_unused]]
49
+ static jni::local_ref<JDimensions::javaobject> fromCpp(const Dimensions& value) {
50
+ using JSignature = JDimensions(double, double);
51
+ static const auto clazz = javaClassStatic();
52
+ static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
53
+ return create(
54
+ clazz,
55
+ value.width,
56
+ value.height
57
+ );
58
+ }
59
+ };
60
+
61
+ } // namespace margelo::nitro::rnstroketext
@@ -0,0 +1,156 @@
1
+ ///
2
+ /// JHybridMatiksStrokeTextSpec.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 "JHybridMatiksStrokeTextSpec.hpp"
9
+
10
+ // Forward declaration of `TextAlign` to properly resolve imports.
11
+ namespace margelo::nitro::rnstroketext { enum class TextAlign; }
12
+ // Forward declaration of `Dimensions` to properly resolve imports.
13
+ namespace margelo::nitro::rnstroketext { struct Dimensions; }
14
+
15
+ #include <optional>
16
+ #include <string>
17
+ #include "TextAlign.hpp"
18
+ #include "JTextAlign.hpp"
19
+ #include "Dimensions.hpp"
20
+ #include "JDimensions.hpp"
21
+
22
+ namespace margelo::nitro::rnstroketext {
23
+
24
+ jni::local_ref<JHybridMatiksStrokeTextSpec::jhybriddata> JHybridMatiksStrokeTextSpec::initHybrid(jni::alias_ref<jhybridobject> jThis) {
25
+ return makeCxxInstance(jThis);
26
+ }
27
+
28
+ void JHybridMatiksStrokeTextSpec::registerNatives() {
29
+ registerHybrid({
30
+ makeNativeMethod("initHybrid", JHybridMatiksStrokeTextSpec::initHybrid),
31
+ });
32
+ }
33
+
34
+ size_t JHybridMatiksStrokeTextSpec::getExternalMemorySize() noexcept {
35
+ static const auto method = javaClassStatic()->getMethod<jlong()>("getMemorySize");
36
+ return method(_javaPart);
37
+ }
38
+
39
+ bool JHybridMatiksStrokeTextSpec::equals(const std::shared_ptr<HybridObject>& other) {
40
+ if (auto otherCast = std::dynamic_pointer_cast<JHybridMatiksStrokeTextSpec>(other)) {
41
+ return _javaPart == otherCast->_javaPart;
42
+ }
43
+ return false;
44
+ }
45
+
46
+ void JHybridMatiksStrokeTextSpec::dispose() noexcept {
47
+ static const auto method = javaClassStatic()->getMethod<void()>("dispose");
48
+ method(_javaPart);
49
+ }
50
+
51
+ std::string JHybridMatiksStrokeTextSpec::toString() {
52
+ static const auto method = javaClassStatic()->getMethod<jni::JString()>("toString");
53
+ auto javaString = method(_javaPart);
54
+ return javaString->toStdString();
55
+ }
56
+
57
+ // Properties
58
+ std::optional<double> JHybridMatiksStrokeTextSpec::getWidth() {
59
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JDouble>()>("getWidth");
60
+ auto __result = method(_javaPart);
61
+ return __result != nullptr ? std::make_optional(__result->value()) : std::nullopt;
62
+ }
63
+ void JHybridMatiksStrokeTextSpec::setWidth(std::optional<double> width) {
64
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JDouble> /* width */)>("setWidth");
65
+ method(_javaPart, width.has_value() ? jni::JDouble::valueOf(width.value()) : nullptr);
66
+ }
67
+ std::string JHybridMatiksStrokeTextSpec::getText() {
68
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getText");
69
+ auto __result = method(_javaPart);
70
+ return __result->toStdString();
71
+ }
72
+ void JHybridMatiksStrokeTextSpec::setText(const std::string& text) {
73
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* text */)>("setText");
74
+ method(_javaPart, jni::make_jstring(text));
75
+ }
76
+ std::optional<double> JHybridMatiksStrokeTextSpec::getFontSize() {
77
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JDouble>()>("getFontSize");
78
+ auto __result = method(_javaPart);
79
+ return __result != nullptr ? std::make_optional(__result->value()) : std::nullopt;
80
+ }
81
+ void JHybridMatiksStrokeTextSpec::setFontSize(std::optional<double> fontSize) {
82
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JDouble> /* fontSize */)>("setFontSize");
83
+ method(_javaPart, fontSize.has_value() ? jni::JDouble::valueOf(fontSize.value()) : nullptr);
84
+ }
85
+ std::optional<std::string> JHybridMatiksStrokeTextSpec::getColor() {
86
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getColor");
87
+ auto __result = method(_javaPart);
88
+ return __result != nullptr ? std::make_optional(__result->toStdString()) : std::nullopt;
89
+ }
90
+ void JHybridMatiksStrokeTextSpec::setColor(const std::optional<std::string>& color) {
91
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* color */)>("setColor");
92
+ method(_javaPart, color.has_value() ? jni::make_jstring(color.value()) : nullptr);
93
+ }
94
+ std::optional<std::string> JHybridMatiksStrokeTextSpec::getStrokeColor() {
95
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getStrokeColor");
96
+ auto __result = method(_javaPart);
97
+ return __result != nullptr ? std::make_optional(__result->toStdString()) : std::nullopt;
98
+ }
99
+ void JHybridMatiksStrokeTextSpec::setStrokeColor(const std::optional<std::string>& strokeColor) {
100
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* strokeColor */)>("setStrokeColor");
101
+ method(_javaPart, strokeColor.has_value() ? jni::make_jstring(strokeColor.value()) : nullptr);
102
+ }
103
+ std::optional<double> JHybridMatiksStrokeTextSpec::getStrokeWidth() {
104
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JDouble>()>("getStrokeWidth");
105
+ auto __result = method(_javaPart);
106
+ return __result != nullptr ? std::make_optional(__result->value()) : std::nullopt;
107
+ }
108
+ void JHybridMatiksStrokeTextSpec::setStrokeWidth(std::optional<double> strokeWidth) {
109
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JDouble> /* strokeWidth */)>("setStrokeWidth");
110
+ method(_javaPart, strokeWidth.has_value() ? jni::JDouble::valueOf(strokeWidth.value()) : nullptr);
111
+ }
112
+ std::optional<std::string> JHybridMatiksStrokeTextSpec::getFontFamily() {
113
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getFontFamily");
114
+ auto __result = method(_javaPart);
115
+ return __result != nullptr ? std::make_optional(__result->toStdString()) : std::nullopt;
116
+ }
117
+ void JHybridMatiksStrokeTextSpec::setFontFamily(const std::optional<std::string>& fontFamily) {
118
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* fontFamily */)>("setFontFamily");
119
+ method(_javaPart, fontFamily.has_value() ? jni::make_jstring(fontFamily.value()) : nullptr);
120
+ }
121
+ std::optional<TextAlign> JHybridMatiksStrokeTextSpec::getAlign() {
122
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<JTextAlign>()>("getAlign");
123
+ auto __result = method(_javaPart);
124
+ return __result != nullptr ? std::make_optional(__result->toCpp()) : std::nullopt;
125
+ }
126
+ void JHybridMatiksStrokeTextSpec::setAlign(std::optional<TextAlign> align) {
127
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JTextAlign> /* align */)>("setAlign");
128
+ method(_javaPart, align.has_value() ? JTextAlign::fromCpp(align.value()) : nullptr);
129
+ }
130
+ std::optional<double> JHybridMatiksStrokeTextSpec::getNumberOfLines() {
131
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JDouble>()>("getNumberOfLines");
132
+ auto __result = method(_javaPart);
133
+ return __result != nullptr ? std::make_optional(__result->value()) : std::nullopt;
134
+ }
135
+ void JHybridMatiksStrokeTextSpec::setNumberOfLines(std::optional<double> numberOfLines) {
136
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JDouble> /* numberOfLines */)>("setNumberOfLines");
137
+ method(_javaPart, numberOfLines.has_value() ? jni::JDouble::valueOf(numberOfLines.value()) : nullptr);
138
+ }
139
+ std::optional<bool> JHybridMatiksStrokeTextSpec::getEllipsis() {
140
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JBoolean>()>("getEllipsis");
141
+ auto __result = method(_javaPart);
142
+ return __result != nullptr ? std::make_optional(static_cast<bool>(__result->value())) : std::nullopt;
143
+ }
144
+ void JHybridMatiksStrokeTextSpec::setEllipsis(std::optional<bool> ellipsis) {
145
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JBoolean> /* ellipsis */)>("setEllipsis");
146
+ method(_javaPart, ellipsis.has_value() ? jni::JBoolean::valueOf(ellipsis.value()) : nullptr);
147
+ }
148
+
149
+ // Methods
150
+ Dimensions JHybridMatiksStrokeTextSpec::measureDimensions() {
151
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<JDimensions>()>("measureDimensions");
152
+ auto __result = method(_javaPart);
153
+ return __result->toCpp();
154
+ }
155
+
156
+ } // namespace margelo::nitro::rnstroketext
@@ -0,0 +1,85 @@
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
+ #include <NitroModules/JHybridObject.hpp>
11
+ #include <fbjni/fbjni.h>
12
+ #include "HybridMatiksStrokeTextSpec.hpp"
13
+
14
+
15
+
16
+
17
+ namespace margelo::nitro::rnstroketext {
18
+
19
+ using namespace facebook;
20
+
21
+ class JHybridMatiksStrokeTextSpec: public jni::HybridClass<JHybridMatiksStrokeTextSpec, JHybridObject>,
22
+ public virtual HybridMatiksStrokeTextSpec {
23
+ public:
24
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/rnstroketext/HybridMatiksStrokeTextSpec;";
25
+ static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
26
+ static void registerNatives();
27
+
28
+ protected:
29
+ // C++ constructor (called from Java via `initHybrid()`)
30
+ explicit JHybridMatiksStrokeTextSpec(jni::alias_ref<jhybridobject> jThis) :
31
+ HybridObject(HybridMatiksStrokeTextSpec::TAG),
32
+ HybridBase(jThis),
33
+ _javaPart(jni::make_global(jThis)) {}
34
+
35
+ public:
36
+ ~JHybridMatiksStrokeTextSpec() override {
37
+ // Hermes GC can destroy JS objects on a non-JNI Thread.
38
+ jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
39
+ }
40
+
41
+ public:
42
+ size_t getExternalMemorySize() noexcept override;
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 {
49
+ return _javaPart;
50
+ }
51
+
52
+ public:
53
+ // Properties
54
+ std::optional<double> getWidth() override;
55
+ void setWidth(std::optional<double> width) override;
56
+ std::string getText() override;
57
+ void setText(const std::string& text) override;
58
+ std::optional<double> getFontSize() override;
59
+ void setFontSize(std::optional<double> fontSize) override;
60
+ std::optional<std::string> getColor() override;
61
+ void setColor(const std::optional<std::string>& color) override;
62
+ std::optional<std::string> getStrokeColor() override;
63
+ void setStrokeColor(const std::optional<std::string>& strokeColor) override;
64
+ std::optional<double> getStrokeWidth() override;
65
+ void setStrokeWidth(std::optional<double> strokeWidth) override;
66
+ std::optional<std::string> getFontFamily() override;
67
+ void setFontFamily(const std::optional<std::string>& fontFamily) override;
68
+ std::optional<TextAlign> getAlign() override;
69
+ void setAlign(std::optional<TextAlign> align) override;
70
+ std::optional<double> getNumberOfLines() override;
71
+ void setNumberOfLines(std::optional<double> numberOfLines) override;
72
+ std::optional<bool> getEllipsis() override;
73
+ void setEllipsis(std::optional<bool> ellipsis) override;
74
+
75
+ public:
76
+ // Methods
77
+ Dimensions measureDimensions() override;
78
+
79
+ private:
80
+ friend HybridBase;
81
+ using HybridBase::HybridBase;
82
+ jni::global_ref<JHybridMatiksStrokeTextSpec::javaobject> _javaPart;
83
+ };
84
+
85
+ } // namespace margelo::nitro::rnstroketext
@@ -0,0 +1,61 @@
1
+ ///
2
+ /// JTextAlign.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <fbjni/fbjni.h>
11
+ #include "TextAlign.hpp"
12
+
13
+ namespace margelo::nitro::rnstroketext {
14
+
15
+ using namespace facebook;
16
+
17
+ /**
18
+ * The C++ JNI bridge between the C++ enum "TextAlign" and the the Kotlin enum "TextAlign".
19
+ */
20
+ struct JTextAlign final: public jni::JavaClass<JTextAlign> {
21
+ public:
22
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/rnstroketext/TextAlign;";
23
+
24
+ public:
25
+ /**
26
+ * Convert this Java/Kotlin-based enum to the C++ enum TextAlign.
27
+ */
28
+ [[maybe_unused]]
29
+ [[nodiscard]]
30
+ TextAlign toCpp() const {
31
+ static const auto clazz = javaClassStatic();
32
+ static const auto fieldOrdinal = clazz->getField<int>("value");
33
+ int ordinal = this->getFieldValue(fieldOrdinal);
34
+ return static_cast<TextAlign>(ordinal);
35
+ }
36
+
37
+ public:
38
+ /**
39
+ * Create a Java/Kotlin-based enum with the given C++ enum's value.
40
+ */
41
+ [[maybe_unused]]
42
+ static jni::alias_ref<JTextAlign> fromCpp(TextAlign value) {
43
+ static const auto clazz = javaClassStatic();
44
+ switch (value) {
45
+ case TextAlign::CENTER:
46
+ static const auto fieldCENTER = clazz->getStaticField<JTextAlign>("CENTER");
47
+ return clazz->getStaticFieldValue(fieldCENTER);
48
+ case TextAlign::LEFT:
49
+ static const auto fieldLEFT = clazz->getStaticField<JTextAlign>("LEFT");
50
+ return clazz->getStaticFieldValue(fieldLEFT);
51
+ case TextAlign::RIGHT:
52
+ static const auto fieldRIGHT = clazz->getStaticField<JTextAlign>("RIGHT");
53
+ return clazz->getStaticFieldValue(fieldRIGHT);
54
+ default:
55
+ std::string stringValue = std::to_string(static_cast<int>(value));
56
+ throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
57
+ }
58
+ }
59
+ };
60
+
61
+ } // namespace margelo::nitro::rnstroketext