@whetware/react-native-stroke-text 0.0.2
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/CHANGELOG.md +7 -0
- package/LICENSE.md +21 -0
- package/NitroStrokeText.podspec +31 -0
- package/README.md +45 -0
- package/android/CMakeLists.txt +29 -0
- package/android/build.gradle +142 -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/stroketext/HybridStrokeTextView.kt +107 -0
- package/android/src/main/java/com/margelo/nitro/stroketext/NitroStrokeTextPackage.kt +39 -0
- package/android/src/main/java/com/margelo/nitro/stroketext/StrokeTextView.kt +429 -0
- package/ios/Bridge.h +8 -0
- package/ios/HybridStrokeTextView.swift +114 -0
- package/ios/StrokeTextColor.swift +120 -0
- package/ios/StrokeTextView.swift +326 -0
- package/ios/StrokedTextLabel.swift +72 -0
- package/lib/StrokeText.d.ts +3 -0
- package/lib/StrokeText.js +109 -0
- package/lib/StrokeText.web.d.ts +3 -0
- package/lib/StrokeText.web.js +106 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +1 -0
- package/lib/index.web.d.ts +2 -0
- package/lib/index.web.js +1 -0
- package/lib/specs/StrokeTextView.nitro.d.ts +37 -0
- package/lib/specs/StrokeTextView.nitro.js +1 -0
- package/lib/types.d.ts +17 -0
- package/lib/types.js +1 -0
- package/nitro.json +24 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/NitroStrokeText+autolinking.cmake +83 -0
- package/nitrogen/generated/android/NitroStrokeText+autolinking.gradle +27 -0
- package/nitrogen/generated/android/NitroStrokeTextOnLoad.cpp +46 -0
- package/nitrogen/generated/android/NitroStrokeTextOnLoad.hpp +25 -0
- package/nitrogen/generated/android/c++/JHybridStrokeTextViewSpec.cpp +308 -0
- package/nitrogen/generated/android/c++/JHybridStrokeTextViewSpec.hpp +117 -0
- package/nitrogen/generated/android/c++/JStrokeTextAlign.hpp +67 -0
- package/nitrogen/generated/android/c++/JStrokeTextDecorationLine.hpp +64 -0
- package/nitrogen/generated/android/c++/JStrokeTextEllipsizeMode.hpp +64 -0
- package/nitrogen/generated/android/c++/JStrokeTextFontStyle.hpp +58 -0
- package/nitrogen/generated/android/c++/JStrokeTextTransform.hpp +64 -0
- package/nitrogen/generated/android/c++/views/JHybridStrokeTextViewStateUpdater.cpp +156 -0
- package/nitrogen/generated/android/c++/views/JHybridStrokeTextViewStateUpdater.hpp +49 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/stroketext/HybridStrokeTextViewSpec.kt +209 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/stroketext/NitroStrokeTextOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/stroketext/StrokeTextAlign.kt +26 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/stroketext/StrokeTextDecorationLine.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/stroketext/StrokeTextEllipsizeMode.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/stroketext/StrokeTextFontStyle.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/stroketext/StrokeTextTransform.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/stroketext/views/HybridStrokeTextViewManager.kt +70 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/stroketext/views/HybridStrokeTextViewStateUpdater.kt +23 -0
- package/nitrogen/generated/ios/NitroStrokeText+autolinking.rb +60 -0
- package/nitrogen/generated/ios/NitroStrokeText-Swift-Cxx-Bridge.cpp +33 -0
- package/nitrogen/generated/ios/NitroStrokeText-Swift-Cxx-Bridge.hpp +177 -0
- package/nitrogen/generated/ios/NitroStrokeText-Swift-Cxx-Umbrella.hpp +58 -0
- package/nitrogen/generated/ios/NitroStrokeTextAutolinking.mm +33 -0
- package/nitrogen/generated/ios/NitroStrokeTextAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridStrokeTextViewSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridStrokeTextViewSpecSwift.hpp +271 -0
- package/nitrogen/generated/ios/c++/views/HybridStrokeTextViewComponent.mm +232 -0
- package/nitrogen/generated/ios/swift/HybridStrokeTextViewSpec.swift +81 -0
- package/nitrogen/generated/ios/swift/HybridStrokeTextViewSpec_cxx.swift +620 -0
- package/nitrogen/generated/ios/swift/StrokeTextAlign.swift +52 -0
- package/nitrogen/generated/ios/swift/StrokeTextDecorationLine.swift +48 -0
- package/nitrogen/generated/ios/swift/StrokeTextEllipsizeMode.swift +48 -0
- package/nitrogen/generated/ios/swift/StrokeTextFontStyle.swift +40 -0
- package/nitrogen/generated/ios/swift/StrokeTextTransform.swift +48 -0
- package/nitrogen/generated/shared/c++/HybridStrokeTextViewSpec.cpp +72 -0
- package/nitrogen/generated/shared/c++/HybridStrokeTextViewSpec.hpp +128 -0
- package/nitrogen/generated/shared/c++/StrokeTextAlign.hpp +88 -0
- package/nitrogen/generated/shared/c++/StrokeTextDecorationLine.hpp +84 -0
- package/nitrogen/generated/shared/c++/StrokeTextEllipsizeMode.hpp +84 -0
- package/nitrogen/generated/shared/c++/StrokeTextFontStyle.hpp +76 -0
- package/nitrogen/generated/shared/c++/StrokeTextTransform.hpp +84 -0
- package/nitrogen/generated/shared/c++/views/HybridStrokeTextViewComponent.cpp +388 -0
- package/nitrogen/generated/shared/c++/views/HybridStrokeTextViewComponent.hpp +138 -0
- package/nitrogen/generated/shared/json/StrokeTextViewConfig.json +35 -0
- package/package.json +124 -0
- package/react-native.config.js +16 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// StrokeTextEllipsizeMode.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Represents the JS union `StrokeTextEllipsizeMode`, backed by a C++ enum.
|
|
10
|
+
*/
|
|
11
|
+
public typealias StrokeTextEllipsizeMode = margelo.nitro.stroketext.StrokeTextEllipsizeMode
|
|
12
|
+
|
|
13
|
+
public extension StrokeTextEllipsizeMode {
|
|
14
|
+
/**
|
|
15
|
+
* Get a StrokeTextEllipsizeMode for the given String value, or
|
|
16
|
+
* return `nil` if the given value was invalid/unknown.
|
|
17
|
+
*/
|
|
18
|
+
init?(fromString string: String) {
|
|
19
|
+
switch string {
|
|
20
|
+
case "head":
|
|
21
|
+
self = .head
|
|
22
|
+
case "middle":
|
|
23
|
+
self = .middle
|
|
24
|
+
case "tail":
|
|
25
|
+
self = .tail
|
|
26
|
+
case "clip":
|
|
27
|
+
self = .clip
|
|
28
|
+
default:
|
|
29
|
+
return nil
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Get the String value this StrokeTextEllipsizeMode represents.
|
|
35
|
+
*/
|
|
36
|
+
var stringValue: String {
|
|
37
|
+
switch self {
|
|
38
|
+
case .head:
|
|
39
|
+
return "head"
|
|
40
|
+
case .middle:
|
|
41
|
+
return "middle"
|
|
42
|
+
case .tail:
|
|
43
|
+
return "tail"
|
|
44
|
+
case .clip:
|
|
45
|
+
return "clip"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// StrokeTextFontStyle.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Represents the JS union `StrokeTextFontStyle`, backed by a C++ enum.
|
|
10
|
+
*/
|
|
11
|
+
public typealias StrokeTextFontStyle = margelo.nitro.stroketext.StrokeTextFontStyle
|
|
12
|
+
|
|
13
|
+
public extension StrokeTextFontStyle {
|
|
14
|
+
/**
|
|
15
|
+
* Get a StrokeTextFontStyle for the given String value, or
|
|
16
|
+
* return `nil` if the given value was invalid/unknown.
|
|
17
|
+
*/
|
|
18
|
+
init?(fromString string: String) {
|
|
19
|
+
switch string {
|
|
20
|
+
case "normal":
|
|
21
|
+
self = .normal
|
|
22
|
+
case "italic":
|
|
23
|
+
self = .italic
|
|
24
|
+
default:
|
|
25
|
+
return nil
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Get the String value this StrokeTextFontStyle represents.
|
|
31
|
+
*/
|
|
32
|
+
var stringValue: String {
|
|
33
|
+
switch self {
|
|
34
|
+
case .normal:
|
|
35
|
+
return "normal"
|
|
36
|
+
case .italic:
|
|
37
|
+
return "italic"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// StrokeTextTransform.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Represents the JS union `StrokeTextTransform`, backed by a C++ enum.
|
|
10
|
+
*/
|
|
11
|
+
public typealias StrokeTextTransform = margelo.nitro.stroketext.StrokeTextTransform
|
|
12
|
+
|
|
13
|
+
public extension StrokeTextTransform {
|
|
14
|
+
/**
|
|
15
|
+
* Get a StrokeTextTransform for the given String value, or
|
|
16
|
+
* return `nil` if the given value was invalid/unknown.
|
|
17
|
+
*/
|
|
18
|
+
init?(fromString string: String) {
|
|
19
|
+
switch string {
|
|
20
|
+
case "none":
|
|
21
|
+
self = .none
|
|
22
|
+
case "uppercase":
|
|
23
|
+
self = .uppercase
|
|
24
|
+
case "lowercase":
|
|
25
|
+
self = .lowercase
|
|
26
|
+
case "capitalize":
|
|
27
|
+
self = .capitalize
|
|
28
|
+
default:
|
|
29
|
+
return nil
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Get the String value this StrokeTextTransform represents.
|
|
35
|
+
*/
|
|
36
|
+
var stringValue: String {
|
|
37
|
+
switch self {
|
|
38
|
+
case .none:
|
|
39
|
+
return "none"
|
|
40
|
+
case .uppercase:
|
|
41
|
+
return "uppercase"
|
|
42
|
+
case .lowercase:
|
|
43
|
+
return "lowercase"
|
|
44
|
+
case .capitalize:
|
|
45
|
+
return "capitalize"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridStrokeTextViewSpec.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 "HybridStrokeTextViewSpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::stroketext {
|
|
11
|
+
|
|
12
|
+
void HybridStrokeTextViewSpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridGetter("text", &HybridStrokeTextViewSpec::getText);
|
|
18
|
+
prototype.registerHybridSetter("text", &HybridStrokeTextViewSpec::setText);
|
|
19
|
+
prototype.registerHybridGetter("color", &HybridStrokeTextViewSpec::getColor);
|
|
20
|
+
prototype.registerHybridSetter("color", &HybridStrokeTextViewSpec::setColor);
|
|
21
|
+
prototype.registerHybridGetter("strokeColor", &HybridStrokeTextViewSpec::getStrokeColor);
|
|
22
|
+
prototype.registerHybridSetter("strokeColor", &HybridStrokeTextViewSpec::setStrokeColor);
|
|
23
|
+
prototype.registerHybridGetter("strokeWidth", &HybridStrokeTextViewSpec::getStrokeWidth);
|
|
24
|
+
prototype.registerHybridSetter("strokeWidth", &HybridStrokeTextViewSpec::setStrokeWidth);
|
|
25
|
+
prototype.registerHybridGetter("fontSize", &HybridStrokeTextViewSpec::getFontSize);
|
|
26
|
+
prototype.registerHybridSetter("fontSize", &HybridStrokeTextViewSpec::setFontSize);
|
|
27
|
+
prototype.registerHybridGetter("fontWeight", &HybridStrokeTextViewSpec::getFontWeight);
|
|
28
|
+
prototype.registerHybridSetter("fontWeight", &HybridStrokeTextViewSpec::setFontWeight);
|
|
29
|
+
prototype.registerHybridGetter("fontFamily", &HybridStrokeTextViewSpec::getFontFamily);
|
|
30
|
+
prototype.registerHybridSetter("fontFamily", &HybridStrokeTextViewSpec::setFontFamily);
|
|
31
|
+
prototype.registerHybridGetter("fontStyle", &HybridStrokeTextViewSpec::getFontStyle);
|
|
32
|
+
prototype.registerHybridSetter("fontStyle", &HybridStrokeTextViewSpec::setFontStyle);
|
|
33
|
+
prototype.registerHybridGetter("lineHeight", &HybridStrokeTextViewSpec::getLineHeight);
|
|
34
|
+
prototype.registerHybridSetter("lineHeight", &HybridStrokeTextViewSpec::setLineHeight);
|
|
35
|
+
prototype.registerHybridGetter("letterSpacing", &HybridStrokeTextViewSpec::getLetterSpacing);
|
|
36
|
+
prototype.registerHybridSetter("letterSpacing", &HybridStrokeTextViewSpec::setLetterSpacing);
|
|
37
|
+
prototype.registerHybridGetter("textAlign", &HybridStrokeTextViewSpec::getTextAlign);
|
|
38
|
+
prototype.registerHybridSetter("textAlign", &HybridStrokeTextViewSpec::setTextAlign);
|
|
39
|
+
prototype.registerHybridGetter("textDecorationLine", &HybridStrokeTextViewSpec::getTextDecorationLine);
|
|
40
|
+
prototype.registerHybridSetter("textDecorationLine", &HybridStrokeTextViewSpec::setTextDecorationLine);
|
|
41
|
+
prototype.registerHybridGetter("textTransform", &HybridStrokeTextViewSpec::getTextTransform);
|
|
42
|
+
prototype.registerHybridSetter("textTransform", &HybridStrokeTextViewSpec::setTextTransform);
|
|
43
|
+
prototype.registerHybridGetter("opacity", &HybridStrokeTextViewSpec::getOpacity);
|
|
44
|
+
prototype.registerHybridSetter("opacity", &HybridStrokeTextViewSpec::setOpacity);
|
|
45
|
+
prototype.registerHybridGetter("allowFontScaling", &HybridStrokeTextViewSpec::getAllowFontScaling);
|
|
46
|
+
prototype.registerHybridSetter("allowFontScaling", &HybridStrokeTextViewSpec::setAllowFontScaling);
|
|
47
|
+
prototype.registerHybridGetter("maxFontSizeMultiplier", &HybridStrokeTextViewSpec::getMaxFontSizeMultiplier);
|
|
48
|
+
prototype.registerHybridSetter("maxFontSizeMultiplier", &HybridStrokeTextViewSpec::setMaxFontSizeMultiplier);
|
|
49
|
+
prototype.registerHybridGetter("includeFontPadding", &HybridStrokeTextViewSpec::getIncludeFontPadding);
|
|
50
|
+
prototype.registerHybridSetter("includeFontPadding", &HybridStrokeTextViewSpec::setIncludeFontPadding);
|
|
51
|
+
prototype.registerHybridGetter("numberOfLines", &HybridStrokeTextViewSpec::getNumberOfLines);
|
|
52
|
+
prototype.registerHybridSetter("numberOfLines", &HybridStrokeTextViewSpec::setNumberOfLines);
|
|
53
|
+
prototype.registerHybridGetter("ellipsizeMode", &HybridStrokeTextViewSpec::getEllipsizeMode);
|
|
54
|
+
prototype.registerHybridSetter("ellipsizeMode", &HybridStrokeTextViewSpec::setEllipsizeMode);
|
|
55
|
+
prototype.registerHybridGetter("padding", &HybridStrokeTextViewSpec::getPadding);
|
|
56
|
+
prototype.registerHybridSetter("padding", &HybridStrokeTextViewSpec::setPadding);
|
|
57
|
+
prototype.registerHybridGetter("paddingVertical", &HybridStrokeTextViewSpec::getPaddingVertical);
|
|
58
|
+
prototype.registerHybridSetter("paddingVertical", &HybridStrokeTextViewSpec::setPaddingVertical);
|
|
59
|
+
prototype.registerHybridGetter("paddingHorizontal", &HybridStrokeTextViewSpec::getPaddingHorizontal);
|
|
60
|
+
prototype.registerHybridSetter("paddingHorizontal", &HybridStrokeTextViewSpec::setPaddingHorizontal);
|
|
61
|
+
prototype.registerHybridGetter("paddingTop", &HybridStrokeTextViewSpec::getPaddingTop);
|
|
62
|
+
prototype.registerHybridSetter("paddingTop", &HybridStrokeTextViewSpec::setPaddingTop);
|
|
63
|
+
prototype.registerHybridGetter("paddingRight", &HybridStrokeTextViewSpec::getPaddingRight);
|
|
64
|
+
prototype.registerHybridSetter("paddingRight", &HybridStrokeTextViewSpec::setPaddingRight);
|
|
65
|
+
prototype.registerHybridGetter("paddingBottom", &HybridStrokeTextViewSpec::getPaddingBottom);
|
|
66
|
+
prototype.registerHybridSetter("paddingBottom", &HybridStrokeTextViewSpec::setPaddingBottom);
|
|
67
|
+
prototype.registerHybridGetter("paddingLeft", &HybridStrokeTextViewSpec::getPaddingLeft);
|
|
68
|
+
prototype.registerHybridSetter("paddingLeft", &HybridStrokeTextViewSpec::setPaddingLeft);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
} // namespace margelo::nitro::stroketext
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridStrokeTextViewSpec.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/HybridObject.hpp>)
|
|
11
|
+
#include <NitroModules/HybridObject.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
// Forward declaration of `StrokeTextFontStyle` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::stroketext { enum class StrokeTextFontStyle; }
|
|
18
|
+
// Forward declaration of `StrokeTextAlign` to properly resolve imports.
|
|
19
|
+
namespace margelo::nitro::stroketext { enum class StrokeTextAlign; }
|
|
20
|
+
// Forward declaration of `StrokeTextDecorationLine` to properly resolve imports.
|
|
21
|
+
namespace margelo::nitro::stroketext { enum class StrokeTextDecorationLine; }
|
|
22
|
+
// Forward declaration of `StrokeTextTransform` to properly resolve imports.
|
|
23
|
+
namespace margelo::nitro::stroketext { enum class StrokeTextTransform; }
|
|
24
|
+
// Forward declaration of `StrokeTextEllipsizeMode` to properly resolve imports.
|
|
25
|
+
namespace margelo::nitro::stroketext { enum class StrokeTextEllipsizeMode; }
|
|
26
|
+
|
|
27
|
+
#include <string>
|
|
28
|
+
#include <optional>
|
|
29
|
+
#include "StrokeTextFontStyle.hpp"
|
|
30
|
+
#include "StrokeTextAlign.hpp"
|
|
31
|
+
#include "StrokeTextDecorationLine.hpp"
|
|
32
|
+
#include "StrokeTextTransform.hpp"
|
|
33
|
+
#include "StrokeTextEllipsizeMode.hpp"
|
|
34
|
+
|
|
35
|
+
namespace margelo::nitro::stroketext {
|
|
36
|
+
|
|
37
|
+
using namespace margelo::nitro;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* An abstract base class for `StrokeTextView`
|
|
41
|
+
* Inherit this class to create instances of `HybridStrokeTextViewSpec` in C++.
|
|
42
|
+
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
43
|
+
* @example
|
|
44
|
+
* ```cpp
|
|
45
|
+
* class HybridStrokeTextView: public HybridStrokeTextViewSpec {
|
|
46
|
+
* public:
|
|
47
|
+
* HybridStrokeTextView(...): HybridObject(TAG) { ... }
|
|
48
|
+
* // ...
|
|
49
|
+
* };
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
class HybridStrokeTextViewSpec: public virtual HybridObject {
|
|
53
|
+
public:
|
|
54
|
+
// Constructor
|
|
55
|
+
explicit HybridStrokeTextViewSpec(): HybridObject(TAG) { }
|
|
56
|
+
|
|
57
|
+
// Destructor
|
|
58
|
+
~HybridStrokeTextViewSpec() override = default;
|
|
59
|
+
|
|
60
|
+
public:
|
|
61
|
+
// Properties
|
|
62
|
+
virtual std::string getText() = 0;
|
|
63
|
+
virtual void setText(const std::string& text) = 0;
|
|
64
|
+
virtual std::optional<std::string> getColor() = 0;
|
|
65
|
+
virtual void setColor(const std::optional<std::string>& color) = 0;
|
|
66
|
+
virtual std::optional<std::string> getStrokeColor() = 0;
|
|
67
|
+
virtual void setStrokeColor(const std::optional<std::string>& strokeColor) = 0;
|
|
68
|
+
virtual std::optional<double> getStrokeWidth() = 0;
|
|
69
|
+
virtual void setStrokeWidth(std::optional<double> strokeWidth) = 0;
|
|
70
|
+
virtual std::optional<double> getFontSize() = 0;
|
|
71
|
+
virtual void setFontSize(std::optional<double> fontSize) = 0;
|
|
72
|
+
virtual std::optional<std::string> getFontWeight() = 0;
|
|
73
|
+
virtual void setFontWeight(const std::optional<std::string>& fontWeight) = 0;
|
|
74
|
+
virtual std::optional<std::string> getFontFamily() = 0;
|
|
75
|
+
virtual void setFontFamily(const std::optional<std::string>& fontFamily) = 0;
|
|
76
|
+
virtual std::optional<StrokeTextFontStyle> getFontStyle() = 0;
|
|
77
|
+
virtual void setFontStyle(std::optional<StrokeTextFontStyle> fontStyle) = 0;
|
|
78
|
+
virtual std::optional<double> getLineHeight() = 0;
|
|
79
|
+
virtual void setLineHeight(std::optional<double> lineHeight) = 0;
|
|
80
|
+
virtual std::optional<double> getLetterSpacing() = 0;
|
|
81
|
+
virtual void setLetterSpacing(std::optional<double> letterSpacing) = 0;
|
|
82
|
+
virtual std::optional<StrokeTextAlign> getTextAlign() = 0;
|
|
83
|
+
virtual void setTextAlign(std::optional<StrokeTextAlign> textAlign) = 0;
|
|
84
|
+
virtual std::optional<StrokeTextDecorationLine> getTextDecorationLine() = 0;
|
|
85
|
+
virtual void setTextDecorationLine(std::optional<StrokeTextDecorationLine> textDecorationLine) = 0;
|
|
86
|
+
virtual std::optional<StrokeTextTransform> getTextTransform() = 0;
|
|
87
|
+
virtual void setTextTransform(std::optional<StrokeTextTransform> textTransform) = 0;
|
|
88
|
+
virtual std::optional<double> getOpacity() = 0;
|
|
89
|
+
virtual void setOpacity(std::optional<double> opacity) = 0;
|
|
90
|
+
virtual std::optional<bool> getAllowFontScaling() = 0;
|
|
91
|
+
virtual void setAllowFontScaling(std::optional<bool> allowFontScaling) = 0;
|
|
92
|
+
virtual std::optional<double> getMaxFontSizeMultiplier() = 0;
|
|
93
|
+
virtual void setMaxFontSizeMultiplier(std::optional<double> maxFontSizeMultiplier) = 0;
|
|
94
|
+
virtual std::optional<bool> getIncludeFontPadding() = 0;
|
|
95
|
+
virtual void setIncludeFontPadding(std::optional<bool> includeFontPadding) = 0;
|
|
96
|
+
virtual std::optional<double> getNumberOfLines() = 0;
|
|
97
|
+
virtual void setNumberOfLines(std::optional<double> numberOfLines) = 0;
|
|
98
|
+
virtual std::optional<StrokeTextEllipsizeMode> getEllipsizeMode() = 0;
|
|
99
|
+
virtual void setEllipsizeMode(std::optional<StrokeTextEllipsizeMode> ellipsizeMode) = 0;
|
|
100
|
+
virtual std::optional<double> getPadding() = 0;
|
|
101
|
+
virtual void setPadding(std::optional<double> padding) = 0;
|
|
102
|
+
virtual std::optional<double> getPaddingVertical() = 0;
|
|
103
|
+
virtual void setPaddingVertical(std::optional<double> paddingVertical) = 0;
|
|
104
|
+
virtual std::optional<double> getPaddingHorizontal() = 0;
|
|
105
|
+
virtual void setPaddingHorizontal(std::optional<double> paddingHorizontal) = 0;
|
|
106
|
+
virtual std::optional<double> getPaddingTop() = 0;
|
|
107
|
+
virtual void setPaddingTop(std::optional<double> paddingTop) = 0;
|
|
108
|
+
virtual std::optional<double> getPaddingRight() = 0;
|
|
109
|
+
virtual void setPaddingRight(std::optional<double> paddingRight) = 0;
|
|
110
|
+
virtual std::optional<double> getPaddingBottom() = 0;
|
|
111
|
+
virtual void setPaddingBottom(std::optional<double> paddingBottom) = 0;
|
|
112
|
+
virtual std::optional<double> getPaddingLeft() = 0;
|
|
113
|
+
virtual void setPaddingLeft(std::optional<double> paddingLeft) = 0;
|
|
114
|
+
|
|
115
|
+
public:
|
|
116
|
+
// Methods
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
protected:
|
|
120
|
+
// Hybrid Setup
|
|
121
|
+
void loadHybridMethods() override;
|
|
122
|
+
|
|
123
|
+
protected:
|
|
124
|
+
// Tag for logging
|
|
125
|
+
static constexpr auto TAG = "StrokeTextView";
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
} // namespace margelo::nitro::stroketext
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// StrokeTextAlign.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/NitroHash.hpp>)
|
|
11
|
+
#include <NitroModules/NitroHash.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
16
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
21
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::stroketext {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (StrokeTextAlign).
|
|
30
|
+
*/
|
|
31
|
+
enum class StrokeTextAlign {
|
|
32
|
+
AUTO SWIFT_NAME(auto) = 0,
|
|
33
|
+
LEFT SWIFT_NAME(left) = 1,
|
|
34
|
+
RIGHT SWIFT_NAME(right) = 2,
|
|
35
|
+
CENTER SWIFT_NAME(center) = 3,
|
|
36
|
+
JUSTIFY SWIFT_NAME(justify) = 4,
|
|
37
|
+
} CLOSED_ENUM;
|
|
38
|
+
|
|
39
|
+
} // namespace margelo::nitro::stroketext
|
|
40
|
+
|
|
41
|
+
namespace margelo::nitro {
|
|
42
|
+
|
|
43
|
+
// C++ StrokeTextAlign <> JS StrokeTextAlign (union)
|
|
44
|
+
template <>
|
|
45
|
+
struct JSIConverter<margelo::nitro::stroketext::StrokeTextAlign> final {
|
|
46
|
+
static inline margelo::nitro::stroketext::StrokeTextAlign fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
47
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
48
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
49
|
+
case hashString("auto"): return margelo::nitro::stroketext::StrokeTextAlign::AUTO;
|
|
50
|
+
case hashString("left"): return margelo::nitro::stroketext::StrokeTextAlign::LEFT;
|
|
51
|
+
case hashString("right"): return margelo::nitro::stroketext::StrokeTextAlign::RIGHT;
|
|
52
|
+
case hashString("center"): return margelo::nitro::stroketext::StrokeTextAlign::CENTER;
|
|
53
|
+
case hashString("justify"): return margelo::nitro::stroketext::StrokeTextAlign::JUSTIFY;
|
|
54
|
+
default: [[unlikely]]
|
|
55
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum StrokeTextAlign - invalid value!");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::stroketext::StrokeTextAlign arg) {
|
|
59
|
+
switch (arg) {
|
|
60
|
+
case margelo::nitro::stroketext::StrokeTextAlign::AUTO: return JSIConverter<std::string>::toJSI(runtime, "auto");
|
|
61
|
+
case margelo::nitro::stroketext::StrokeTextAlign::LEFT: return JSIConverter<std::string>::toJSI(runtime, "left");
|
|
62
|
+
case margelo::nitro::stroketext::StrokeTextAlign::RIGHT: return JSIConverter<std::string>::toJSI(runtime, "right");
|
|
63
|
+
case margelo::nitro::stroketext::StrokeTextAlign::CENTER: return JSIConverter<std::string>::toJSI(runtime, "center");
|
|
64
|
+
case margelo::nitro::stroketext::StrokeTextAlign::JUSTIFY: return JSIConverter<std::string>::toJSI(runtime, "justify");
|
|
65
|
+
default: [[unlikely]]
|
|
66
|
+
throw std::invalid_argument("Cannot convert StrokeTextAlign to JS - invalid value: "
|
|
67
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
71
|
+
if (!value.isString()) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
75
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
76
|
+
case hashString("auto"):
|
|
77
|
+
case hashString("left"):
|
|
78
|
+
case hashString("right"):
|
|
79
|
+
case hashString("center"):
|
|
80
|
+
case hashString("justify"):
|
|
81
|
+
return true;
|
|
82
|
+
default:
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// StrokeTextDecorationLine.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/NitroHash.hpp>)
|
|
11
|
+
#include <NitroModules/NitroHash.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
16
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
21
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::stroketext {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (StrokeTextDecorationLine).
|
|
30
|
+
*/
|
|
31
|
+
enum class StrokeTextDecorationLine {
|
|
32
|
+
NONE SWIFT_NAME(none) = 0,
|
|
33
|
+
UNDERLINE SWIFT_NAME(underline) = 1,
|
|
34
|
+
LINE_THROUGH SWIFT_NAME(lineThrough) = 2,
|
|
35
|
+
UNDERLINE_LINE_THROUGH SWIFT_NAME(underlineLineThrough) = 3,
|
|
36
|
+
} CLOSED_ENUM;
|
|
37
|
+
|
|
38
|
+
} // namespace margelo::nitro::stroketext
|
|
39
|
+
|
|
40
|
+
namespace margelo::nitro {
|
|
41
|
+
|
|
42
|
+
// C++ StrokeTextDecorationLine <> JS StrokeTextDecorationLine (union)
|
|
43
|
+
template <>
|
|
44
|
+
struct JSIConverter<margelo::nitro::stroketext::StrokeTextDecorationLine> final {
|
|
45
|
+
static inline margelo::nitro::stroketext::StrokeTextDecorationLine fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
46
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
47
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
48
|
+
case hashString("none"): return margelo::nitro::stroketext::StrokeTextDecorationLine::NONE;
|
|
49
|
+
case hashString("underline"): return margelo::nitro::stroketext::StrokeTextDecorationLine::UNDERLINE;
|
|
50
|
+
case hashString("line-through"): return margelo::nitro::stroketext::StrokeTextDecorationLine::LINE_THROUGH;
|
|
51
|
+
case hashString("underline line-through"): return margelo::nitro::stroketext::StrokeTextDecorationLine::UNDERLINE_LINE_THROUGH;
|
|
52
|
+
default: [[unlikely]]
|
|
53
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum StrokeTextDecorationLine - invalid value!");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::stroketext::StrokeTextDecorationLine arg) {
|
|
57
|
+
switch (arg) {
|
|
58
|
+
case margelo::nitro::stroketext::StrokeTextDecorationLine::NONE: return JSIConverter<std::string>::toJSI(runtime, "none");
|
|
59
|
+
case margelo::nitro::stroketext::StrokeTextDecorationLine::UNDERLINE: return JSIConverter<std::string>::toJSI(runtime, "underline");
|
|
60
|
+
case margelo::nitro::stroketext::StrokeTextDecorationLine::LINE_THROUGH: return JSIConverter<std::string>::toJSI(runtime, "line-through");
|
|
61
|
+
case margelo::nitro::stroketext::StrokeTextDecorationLine::UNDERLINE_LINE_THROUGH: return JSIConverter<std::string>::toJSI(runtime, "underline line-through");
|
|
62
|
+
default: [[unlikely]]
|
|
63
|
+
throw std::invalid_argument("Cannot convert StrokeTextDecorationLine to JS - invalid value: "
|
|
64
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
68
|
+
if (!value.isString()) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
72
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
73
|
+
case hashString("none"):
|
|
74
|
+
case hashString("underline"):
|
|
75
|
+
case hashString("line-through"):
|
|
76
|
+
case hashString("underline line-through"):
|
|
77
|
+
return true;
|
|
78
|
+
default:
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// StrokeTextEllipsizeMode.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/NitroHash.hpp>)
|
|
11
|
+
#include <NitroModules/NitroHash.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
16
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
21
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::stroketext {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (StrokeTextEllipsizeMode).
|
|
30
|
+
*/
|
|
31
|
+
enum class StrokeTextEllipsizeMode {
|
|
32
|
+
HEAD SWIFT_NAME(head) = 0,
|
|
33
|
+
MIDDLE SWIFT_NAME(middle) = 1,
|
|
34
|
+
TAIL SWIFT_NAME(tail) = 2,
|
|
35
|
+
CLIP SWIFT_NAME(clip) = 3,
|
|
36
|
+
} CLOSED_ENUM;
|
|
37
|
+
|
|
38
|
+
} // namespace margelo::nitro::stroketext
|
|
39
|
+
|
|
40
|
+
namespace margelo::nitro {
|
|
41
|
+
|
|
42
|
+
// C++ StrokeTextEllipsizeMode <> JS StrokeTextEllipsizeMode (union)
|
|
43
|
+
template <>
|
|
44
|
+
struct JSIConverter<margelo::nitro::stroketext::StrokeTextEllipsizeMode> final {
|
|
45
|
+
static inline margelo::nitro::stroketext::StrokeTextEllipsizeMode fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
46
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
47
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
48
|
+
case hashString("head"): return margelo::nitro::stroketext::StrokeTextEllipsizeMode::HEAD;
|
|
49
|
+
case hashString("middle"): return margelo::nitro::stroketext::StrokeTextEllipsizeMode::MIDDLE;
|
|
50
|
+
case hashString("tail"): return margelo::nitro::stroketext::StrokeTextEllipsizeMode::TAIL;
|
|
51
|
+
case hashString("clip"): return margelo::nitro::stroketext::StrokeTextEllipsizeMode::CLIP;
|
|
52
|
+
default: [[unlikely]]
|
|
53
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum StrokeTextEllipsizeMode - invalid value!");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::stroketext::StrokeTextEllipsizeMode arg) {
|
|
57
|
+
switch (arg) {
|
|
58
|
+
case margelo::nitro::stroketext::StrokeTextEllipsizeMode::HEAD: return JSIConverter<std::string>::toJSI(runtime, "head");
|
|
59
|
+
case margelo::nitro::stroketext::StrokeTextEllipsizeMode::MIDDLE: return JSIConverter<std::string>::toJSI(runtime, "middle");
|
|
60
|
+
case margelo::nitro::stroketext::StrokeTextEllipsizeMode::TAIL: return JSIConverter<std::string>::toJSI(runtime, "tail");
|
|
61
|
+
case margelo::nitro::stroketext::StrokeTextEllipsizeMode::CLIP: return JSIConverter<std::string>::toJSI(runtime, "clip");
|
|
62
|
+
default: [[unlikely]]
|
|
63
|
+
throw std::invalid_argument("Cannot convert StrokeTextEllipsizeMode to JS - invalid value: "
|
|
64
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
68
|
+
if (!value.isString()) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
72
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
73
|
+
case hashString("head"):
|
|
74
|
+
case hashString("middle"):
|
|
75
|
+
case hashString("tail"):
|
|
76
|
+
case hashString("clip"):
|
|
77
|
+
return true;
|
|
78
|
+
default:
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// StrokeTextFontStyle.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/NitroHash.hpp>)
|
|
11
|
+
#include <NitroModules/NitroHash.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
16
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
21
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::stroketext {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (StrokeTextFontStyle).
|
|
30
|
+
*/
|
|
31
|
+
enum class StrokeTextFontStyle {
|
|
32
|
+
NORMAL SWIFT_NAME(normal) = 0,
|
|
33
|
+
ITALIC SWIFT_NAME(italic) = 1,
|
|
34
|
+
} CLOSED_ENUM;
|
|
35
|
+
|
|
36
|
+
} // namespace margelo::nitro::stroketext
|
|
37
|
+
|
|
38
|
+
namespace margelo::nitro {
|
|
39
|
+
|
|
40
|
+
// C++ StrokeTextFontStyle <> JS StrokeTextFontStyle (union)
|
|
41
|
+
template <>
|
|
42
|
+
struct JSIConverter<margelo::nitro::stroketext::StrokeTextFontStyle> final {
|
|
43
|
+
static inline margelo::nitro::stroketext::StrokeTextFontStyle fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
44
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
45
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
46
|
+
case hashString("normal"): return margelo::nitro::stroketext::StrokeTextFontStyle::NORMAL;
|
|
47
|
+
case hashString("italic"): return margelo::nitro::stroketext::StrokeTextFontStyle::ITALIC;
|
|
48
|
+
default: [[unlikely]]
|
|
49
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum StrokeTextFontStyle - invalid value!");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::stroketext::StrokeTextFontStyle arg) {
|
|
53
|
+
switch (arg) {
|
|
54
|
+
case margelo::nitro::stroketext::StrokeTextFontStyle::NORMAL: return JSIConverter<std::string>::toJSI(runtime, "normal");
|
|
55
|
+
case margelo::nitro::stroketext::StrokeTextFontStyle::ITALIC: return JSIConverter<std::string>::toJSI(runtime, "italic");
|
|
56
|
+
default: [[unlikely]]
|
|
57
|
+
throw std::invalid_argument("Cannot convert StrokeTextFontStyle to JS - invalid value: "
|
|
58
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
62
|
+
if (!value.isString()) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
66
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
67
|
+
case hashString("normal"):
|
|
68
|
+
case hashString("italic"):
|
|
69
|
+
return true;
|
|
70
|
+
default:
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
} // namespace margelo::nitro
|