@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,51 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroRnStrokeText-Swift-Cxx-Umbrella.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
|
+
// Include C++ defined types
|
|
19
|
+
#include "Dimensions.hpp"
|
|
20
|
+
#include "HybridMatiksStrokeTextSpec.hpp"
|
|
21
|
+
#include "TextAlign.hpp"
|
|
22
|
+
#include <NitroModules/Result.hpp>
|
|
23
|
+
#include <exception>
|
|
24
|
+
#include <memory>
|
|
25
|
+
#include <optional>
|
|
26
|
+
#include <string>
|
|
27
|
+
|
|
28
|
+
// C++ helpers for Swift
|
|
29
|
+
#include "NitroRnStrokeText-Swift-Cxx-Bridge.hpp"
|
|
30
|
+
|
|
31
|
+
// Common C++ types used in Swift
|
|
32
|
+
#include <NitroModules/ArrayBufferHolder.hpp>
|
|
33
|
+
#include <NitroModules/AnyMapUtils.hpp>
|
|
34
|
+
#include <NitroModules/RuntimeError.hpp>
|
|
35
|
+
#include <NitroModules/DateToChronoDate.hpp>
|
|
36
|
+
|
|
37
|
+
// Forward declarations of Swift defined types
|
|
38
|
+
// Forward declaration of `HybridMatiksStrokeTextSpec_cxx` to properly resolve imports.
|
|
39
|
+
namespace NitroRnStrokeText { class HybridMatiksStrokeTextSpec_cxx; }
|
|
40
|
+
|
|
41
|
+
// Include Swift defined types
|
|
42
|
+
#if __has_include("NitroRnStrokeText-Swift.h")
|
|
43
|
+
// This header is generated by Xcode/Swift on every app build.
|
|
44
|
+
// If it cannot be found, make sure the Swift module's name (= podspec name) is actually "NitroRnStrokeText".
|
|
45
|
+
#include "NitroRnStrokeText-Swift.h"
|
|
46
|
+
// Same as above, but used when building with frameworks (`use_frameworks`)
|
|
47
|
+
#elif __has_include(<NitroRnStrokeText/NitroRnStrokeText-Swift.h>)
|
|
48
|
+
#include <NitroRnStrokeText/NitroRnStrokeText-Swift.h>
|
|
49
|
+
#else
|
|
50
|
+
#error NitroRnStrokeText's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "NitroRnStrokeText", and try building the app first.
|
|
51
|
+
#endif
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroRnStrokeTextAutolinking.mm
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#import <Foundation/Foundation.h>
|
|
9
|
+
#import <NitroModules/HybridObjectRegistry.hpp>
|
|
10
|
+
#import "NitroRnStrokeText-Swift-Cxx-Umbrella.hpp"
|
|
11
|
+
#import <type_traits>
|
|
12
|
+
|
|
13
|
+
#include "HybridMatiksStrokeTextSpecSwift.hpp"
|
|
14
|
+
|
|
15
|
+
@interface NitroRnStrokeTextAutolinking : NSObject
|
|
16
|
+
@end
|
|
17
|
+
|
|
18
|
+
@implementation NitroRnStrokeTextAutolinking
|
|
19
|
+
|
|
20
|
+
+ (void) load {
|
|
21
|
+
using namespace margelo::nitro;
|
|
22
|
+
using namespace margelo::nitro::rnstroketext;
|
|
23
|
+
|
|
24
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
25
|
+
"MatiksStrokeText",
|
|
26
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
27
|
+
std::shared_ptr<HybridMatiksStrokeTextSpec> hybridObject = NitroRnStrokeText::NitroRnStrokeTextAutolinking::createMatiksStrokeText();
|
|
28
|
+
return hybridObject;
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroRnStrokeTextAutolinking.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
|
+
public final class NitroRnStrokeTextAutolinking {
|
|
9
|
+
public typealias bridge = margelo.nitro.rnstroketext.bridge.swift
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of a Swift class that implements `HybridMatiksStrokeTextSpec`,
|
|
13
|
+
* and wraps it in a Swift class that can directly interop with C++ (`HybridMatiksStrokeTextSpec_cxx`)
|
|
14
|
+
*
|
|
15
|
+
* This is generated by Nitrogen and will initialize the class specified
|
|
16
|
+
* in the `"autolinking"` property of `nitro.json` (in this case, `HybridMatiksStrokeText`).
|
|
17
|
+
*/
|
|
18
|
+
public static func createMatiksStrokeText() -> bridge.std__shared_ptr_HybridMatiksStrokeTextSpec_ {
|
|
19
|
+
let hybridObject = HybridMatiksStrokeText()
|
|
20
|
+
return { () -> bridge.std__shared_ptr_HybridMatiksStrokeTextSpec_ in
|
|
21
|
+
let __cxxWrapped = hybridObject.getCxxWrapper()
|
|
22
|
+
return __cxxWrapped.getCxxPart()
|
|
23
|
+
}()
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridMatiksStrokeTextSpecSwift.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 "HybridMatiksStrokeTextSpecSwift.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::rnstroketext {
|
|
11
|
+
} // namespace margelo::nitro::rnstroketext
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridMatiksStrokeTextSpecSwift.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 "HybridMatiksStrokeTextSpec.hpp"
|
|
11
|
+
|
|
12
|
+
// Forward declaration of `HybridMatiksStrokeTextSpec_cxx` to properly resolve imports.
|
|
13
|
+
namespace NitroRnStrokeText { class HybridMatiksStrokeTextSpec_cxx; }
|
|
14
|
+
|
|
15
|
+
// Forward declaration of `TextAlign` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::rnstroketext { enum class TextAlign; }
|
|
17
|
+
// Forward declaration of `Dimensions` to properly resolve imports.
|
|
18
|
+
namespace margelo::nitro::rnstroketext { struct Dimensions; }
|
|
19
|
+
|
|
20
|
+
#include <optional>
|
|
21
|
+
#include <string>
|
|
22
|
+
#include "TextAlign.hpp"
|
|
23
|
+
#include "Dimensions.hpp"
|
|
24
|
+
|
|
25
|
+
#include "NitroRnStrokeText-Swift-Cxx-Umbrella.hpp"
|
|
26
|
+
|
|
27
|
+
namespace margelo::nitro::rnstroketext {
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The C++ part of HybridMatiksStrokeTextSpec_cxx.swift.
|
|
31
|
+
*
|
|
32
|
+
* HybridMatiksStrokeTextSpecSwift (C++) accesses HybridMatiksStrokeTextSpec_cxx (Swift), and might
|
|
33
|
+
* contain some additional bridging code for C++ <> Swift interop.
|
|
34
|
+
*
|
|
35
|
+
* Since this obviously introduces an overhead, I hope at some point in
|
|
36
|
+
* the future, HybridMatiksStrokeTextSpec_cxx can directly inherit from the C++ class HybridMatiksStrokeTextSpec
|
|
37
|
+
* to simplify the whole structure and memory management.
|
|
38
|
+
*/
|
|
39
|
+
class HybridMatiksStrokeTextSpecSwift: public virtual HybridMatiksStrokeTextSpec {
|
|
40
|
+
public:
|
|
41
|
+
// Constructor from a Swift instance
|
|
42
|
+
explicit HybridMatiksStrokeTextSpecSwift(const NitroRnStrokeText::HybridMatiksStrokeTextSpec_cxx& swiftPart):
|
|
43
|
+
HybridObject(HybridMatiksStrokeTextSpec::TAG),
|
|
44
|
+
_swiftPart(swiftPart) { }
|
|
45
|
+
|
|
46
|
+
public:
|
|
47
|
+
// Get the Swift part
|
|
48
|
+
inline NitroRnStrokeText::HybridMatiksStrokeTextSpec_cxx& getSwiftPart() noexcept {
|
|
49
|
+
return _swiftPart;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public:
|
|
53
|
+
inline size_t getExternalMemorySize() noexcept override {
|
|
54
|
+
return _swiftPart.getMemorySize();
|
|
55
|
+
}
|
|
56
|
+
bool equals(const std::shared_ptr<HybridObject>& other) override {
|
|
57
|
+
if (auto otherCast = std::dynamic_pointer_cast<HybridMatiksStrokeTextSpecSwift>(other)) {
|
|
58
|
+
return _swiftPart.equals(otherCast->_swiftPart);
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
void dispose() noexcept override {
|
|
63
|
+
_swiftPart.dispose();
|
|
64
|
+
}
|
|
65
|
+
std::string toString() override {
|
|
66
|
+
return _swiftPart.toString();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public:
|
|
70
|
+
// Properties
|
|
71
|
+
inline std::optional<double> getWidth() noexcept override {
|
|
72
|
+
auto __result = _swiftPart.getWidth();
|
|
73
|
+
return __result;
|
|
74
|
+
}
|
|
75
|
+
inline void setWidth(std::optional<double> width) noexcept override {
|
|
76
|
+
_swiftPart.setWidth(width);
|
|
77
|
+
}
|
|
78
|
+
inline std::string getText() noexcept override {
|
|
79
|
+
auto __result = _swiftPart.getText();
|
|
80
|
+
return __result;
|
|
81
|
+
}
|
|
82
|
+
inline void setText(const std::string& text) noexcept override {
|
|
83
|
+
_swiftPart.setText(text);
|
|
84
|
+
}
|
|
85
|
+
inline std::optional<double> getFontSize() noexcept override {
|
|
86
|
+
auto __result = _swiftPart.getFontSize();
|
|
87
|
+
return __result;
|
|
88
|
+
}
|
|
89
|
+
inline void setFontSize(std::optional<double> fontSize) noexcept override {
|
|
90
|
+
_swiftPart.setFontSize(fontSize);
|
|
91
|
+
}
|
|
92
|
+
inline std::optional<std::string> getColor() noexcept override {
|
|
93
|
+
auto __result = _swiftPart.getColor();
|
|
94
|
+
return __result;
|
|
95
|
+
}
|
|
96
|
+
inline void setColor(const std::optional<std::string>& color) noexcept override {
|
|
97
|
+
_swiftPart.setColor(color);
|
|
98
|
+
}
|
|
99
|
+
inline std::optional<std::string> getStrokeColor() noexcept override {
|
|
100
|
+
auto __result = _swiftPart.getStrokeColor();
|
|
101
|
+
return __result;
|
|
102
|
+
}
|
|
103
|
+
inline void setStrokeColor(const std::optional<std::string>& strokeColor) noexcept override {
|
|
104
|
+
_swiftPart.setStrokeColor(strokeColor);
|
|
105
|
+
}
|
|
106
|
+
inline std::optional<double> getStrokeWidth() noexcept override {
|
|
107
|
+
auto __result = _swiftPart.getStrokeWidth();
|
|
108
|
+
return __result;
|
|
109
|
+
}
|
|
110
|
+
inline void setStrokeWidth(std::optional<double> strokeWidth) noexcept override {
|
|
111
|
+
_swiftPart.setStrokeWidth(strokeWidth);
|
|
112
|
+
}
|
|
113
|
+
inline std::optional<std::string> getFontFamily() noexcept override {
|
|
114
|
+
auto __result = _swiftPart.getFontFamily();
|
|
115
|
+
return __result;
|
|
116
|
+
}
|
|
117
|
+
inline void setFontFamily(const std::optional<std::string>& fontFamily) noexcept override {
|
|
118
|
+
_swiftPart.setFontFamily(fontFamily);
|
|
119
|
+
}
|
|
120
|
+
inline std::optional<TextAlign> getAlign() noexcept override {
|
|
121
|
+
auto __result = _swiftPart.getAlign();
|
|
122
|
+
return __result;
|
|
123
|
+
}
|
|
124
|
+
inline void setAlign(std::optional<TextAlign> align) noexcept override {
|
|
125
|
+
_swiftPart.setAlign(align);
|
|
126
|
+
}
|
|
127
|
+
inline std::optional<double> getNumberOfLines() noexcept override {
|
|
128
|
+
auto __result = _swiftPart.getNumberOfLines();
|
|
129
|
+
return __result;
|
|
130
|
+
}
|
|
131
|
+
inline void setNumberOfLines(std::optional<double> numberOfLines) noexcept override {
|
|
132
|
+
_swiftPart.setNumberOfLines(numberOfLines);
|
|
133
|
+
}
|
|
134
|
+
inline std::optional<bool> getEllipsis() noexcept override {
|
|
135
|
+
auto __result = _swiftPart.getEllipsis();
|
|
136
|
+
return __result;
|
|
137
|
+
}
|
|
138
|
+
inline void setEllipsis(std::optional<bool> ellipsis) noexcept override {
|
|
139
|
+
_swiftPart.setEllipsis(ellipsis);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
public:
|
|
143
|
+
// Methods
|
|
144
|
+
inline Dimensions measureDimensions() override {
|
|
145
|
+
auto __result = _swiftPart.measureDimensions();
|
|
146
|
+
if (__result.hasError()) [[unlikely]] {
|
|
147
|
+
std::rethrow_exception(__result.error());
|
|
148
|
+
}
|
|
149
|
+
auto __value = std::move(__result.value());
|
|
150
|
+
return __value;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
private:
|
|
154
|
+
NitroRnStrokeText::HybridMatiksStrokeTextSpec_cxx _swiftPart;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
} // namespace margelo::nitro::rnstroketext
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridMatiksStrokeTextComponent.mm
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#import "HybridMatiksStrokeTextComponent.hpp"
|
|
9
|
+
#import <memory>
|
|
10
|
+
#import <react/renderer/componentregistry/ComponentDescriptorProvider.h>
|
|
11
|
+
#import <React/RCTViewComponentView.h>
|
|
12
|
+
#import <React/RCTComponentViewFactory.h>
|
|
13
|
+
#import <React/UIView+ComponentViewProtocol.h>
|
|
14
|
+
#import <NitroModules/NitroDefines.hpp>
|
|
15
|
+
#import <UIKit/UIKit.h>
|
|
16
|
+
|
|
17
|
+
#import "HybridMatiksStrokeTextSpecSwift.hpp"
|
|
18
|
+
#import "NitroRnStrokeText-Swift-Cxx-Umbrella.hpp"
|
|
19
|
+
|
|
20
|
+
using namespace facebook;
|
|
21
|
+
using namespace margelo::nitro::rnstroketext;
|
|
22
|
+
using namespace margelo::nitro::rnstroketext::views;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Represents the React Native View holder for the Nitro "MatiksStrokeText" HybridView.
|
|
26
|
+
*/
|
|
27
|
+
@interface HybridMatiksStrokeTextComponent: RCTViewComponentView
|
|
28
|
+
+ (BOOL)shouldBeRecycled;
|
|
29
|
+
@end
|
|
30
|
+
|
|
31
|
+
@implementation HybridMatiksStrokeTextComponent {
|
|
32
|
+
std::shared_ptr<HybridMatiksStrokeTextSpecSwift> _hybridView;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
+ (void) load {
|
|
36
|
+
[super load];
|
|
37
|
+
[RCTComponentViewFactory.currentComponentViewFactory registerComponentViewClass:[HybridMatiksStrokeTextComponent class]];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
+ (react::ComponentDescriptorProvider) componentDescriptorProvider {
|
|
41
|
+
return react::concreteComponentDescriptorProvider<HybridMatiksStrokeTextComponentDescriptor>();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
+ (BOOL)shouldBeRecycled {
|
|
45
|
+
// TODO: Recycling should be controllable by the user. WIP, but disabled for now.
|
|
46
|
+
return NO;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
- (instancetype) init {
|
|
50
|
+
if (self = [super init]) {
|
|
51
|
+
std::shared_ptr<HybridMatiksStrokeTextSpec> hybridView = NitroRnStrokeText::NitroRnStrokeTextAutolinking::createMatiksStrokeText();
|
|
52
|
+
_hybridView = std::dynamic_pointer_cast<HybridMatiksStrokeTextSpecSwift>(hybridView);
|
|
53
|
+
[self updateView];
|
|
54
|
+
}
|
|
55
|
+
return self;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
- (void) updateView {
|
|
59
|
+
// 1. Get Swift part
|
|
60
|
+
NitroRnStrokeText::HybridMatiksStrokeTextSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
61
|
+
|
|
62
|
+
// 2. Get UIView*
|
|
63
|
+
void* viewUnsafe = swiftPart.getView();
|
|
64
|
+
UIView* view = (__bridge_transfer UIView*) viewUnsafe;
|
|
65
|
+
|
|
66
|
+
// 3. Update RCTViewComponentView's [contentView]
|
|
67
|
+
[self setContentView:view];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
- (void) updateProps:(const std::shared_ptr<const react::Props>&)props
|
|
71
|
+
oldProps:(const std::shared_ptr<const react::Props>&)oldProps {
|
|
72
|
+
// 1. Downcast props
|
|
73
|
+
const auto& newViewPropsConst = *std::static_pointer_cast<HybridMatiksStrokeTextProps const>(props);
|
|
74
|
+
auto& newViewProps = const_cast<HybridMatiksStrokeTextProps&>(newViewPropsConst);
|
|
75
|
+
NitroRnStrokeText::HybridMatiksStrokeTextSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
76
|
+
|
|
77
|
+
// 2. Update each prop individually
|
|
78
|
+
swiftPart.beforeUpdate();
|
|
79
|
+
|
|
80
|
+
// width: optional
|
|
81
|
+
if (newViewProps.width.isDirty) {
|
|
82
|
+
swiftPart.setWidth(newViewProps.width.value);
|
|
83
|
+
newViewProps.width.isDirty = false;
|
|
84
|
+
}
|
|
85
|
+
// text: string
|
|
86
|
+
if (newViewProps.text.isDirty) {
|
|
87
|
+
swiftPart.setText(newViewProps.text.value);
|
|
88
|
+
newViewProps.text.isDirty = false;
|
|
89
|
+
}
|
|
90
|
+
// fontSize: optional
|
|
91
|
+
if (newViewProps.fontSize.isDirty) {
|
|
92
|
+
swiftPart.setFontSize(newViewProps.fontSize.value);
|
|
93
|
+
newViewProps.fontSize.isDirty = false;
|
|
94
|
+
}
|
|
95
|
+
// color: optional
|
|
96
|
+
if (newViewProps.color.isDirty) {
|
|
97
|
+
swiftPart.setColor(newViewProps.color.value);
|
|
98
|
+
newViewProps.color.isDirty = false;
|
|
99
|
+
}
|
|
100
|
+
// strokeColor: optional
|
|
101
|
+
if (newViewProps.strokeColor.isDirty) {
|
|
102
|
+
swiftPart.setStrokeColor(newViewProps.strokeColor.value);
|
|
103
|
+
newViewProps.strokeColor.isDirty = false;
|
|
104
|
+
}
|
|
105
|
+
// strokeWidth: optional
|
|
106
|
+
if (newViewProps.strokeWidth.isDirty) {
|
|
107
|
+
swiftPart.setStrokeWidth(newViewProps.strokeWidth.value);
|
|
108
|
+
newViewProps.strokeWidth.isDirty = false;
|
|
109
|
+
}
|
|
110
|
+
// fontFamily: optional
|
|
111
|
+
if (newViewProps.fontFamily.isDirty) {
|
|
112
|
+
swiftPart.setFontFamily(newViewProps.fontFamily.value);
|
|
113
|
+
newViewProps.fontFamily.isDirty = false;
|
|
114
|
+
}
|
|
115
|
+
// align: optional
|
|
116
|
+
if (newViewProps.align.isDirty) {
|
|
117
|
+
swiftPart.setAlign(newViewProps.align.value);
|
|
118
|
+
newViewProps.align.isDirty = false;
|
|
119
|
+
}
|
|
120
|
+
// numberOfLines: optional
|
|
121
|
+
if (newViewProps.numberOfLines.isDirty) {
|
|
122
|
+
swiftPart.setNumberOfLines(newViewProps.numberOfLines.value);
|
|
123
|
+
newViewProps.numberOfLines.isDirty = false;
|
|
124
|
+
}
|
|
125
|
+
// ellipsis: optional
|
|
126
|
+
if (newViewProps.ellipsis.isDirty) {
|
|
127
|
+
swiftPart.setEllipsis(newViewProps.ellipsis.value);
|
|
128
|
+
newViewProps.ellipsis.isDirty = false;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
swiftPart.afterUpdate();
|
|
132
|
+
|
|
133
|
+
// 3. Update hybridRef if it changed
|
|
134
|
+
if (newViewProps.hybridRef.isDirty) {
|
|
135
|
+
// hybridRef changed - call it with new this
|
|
136
|
+
const auto& maybeFunc = newViewProps.hybridRef.value;
|
|
137
|
+
if (maybeFunc.has_value()) {
|
|
138
|
+
maybeFunc.value()(_hybridView);
|
|
139
|
+
}
|
|
140
|
+
newViewProps.hybridRef.isDirty = false;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// 4. Continue in base class
|
|
144
|
+
[super updateProps:props oldProps:oldProps];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
@end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Dimensions.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Represents an instance of `Dimensions`, backed by a C++ struct.
|
|
13
|
+
*/
|
|
14
|
+
public typealias Dimensions = margelo.nitro.rnstroketext.Dimensions
|
|
15
|
+
|
|
16
|
+
public extension Dimensions {
|
|
17
|
+
private typealias bridge = margelo.nitro.rnstroketext.bridge.swift
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Create a new instance of `Dimensions`.
|
|
21
|
+
*/
|
|
22
|
+
init(width: Double, height: Double) {
|
|
23
|
+
self.init(width, height)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@inline(__always)
|
|
27
|
+
var width: Double {
|
|
28
|
+
return self.__width
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@inline(__always)
|
|
32
|
+
var height: Double {
|
|
33
|
+
return self.__height
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridMatiksStrokeTextSpec.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/// See ``HybridMatiksStrokeTextSpec``
|
|
12
|
+
public protocol HybridMatiksStrokeTextSpec_protocol: HybridObject, HybridView {
|
|
13
|
+
// Properties
|
|
14
|
+
var width: Double? { get set }
|
|
15
|
+
var text: String { get set }
|
|
16
|
+
var fontSize: Double? { get set }
|
|
17
|
+
var color: String? { get set }
|
|
18
|
+
var strokeColor: String? { get set }
|
|
19
|
+
var strokeWidth: Double? { get set }
|
|
20
|
+
var fontFamily: String? { get set }
|
|
21
|
+
var align: TextAlign? { get set }
|
|
22
|
+
var numberOfLines: Double? { get set }
|
|
23
|
+
var ellipsis: Bool? { get set }
|
|
24
|
+
|
|
25
|
+
// Methods
|
|
26
|
+
func measureDimensions() throws -> Dimensions
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public extension HybridMatiksStrokeTextSpec_protocol {
|
|
30
|
+
/// Default implementation of ``HybridObject.toString``
|
|
31
|
+
func toString() -> String {
|
|
32
|
+
return "[HybridObject MatiksStrokeText]"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/// See ``HybridMatiksStrokeTextSpec``
|
|
37
|
+
open class HybridMatiksStrokeTextSpec_base {
|
|
38
|
+
private weak var cxxWrapper: HybridMatiksStrokeTextSpec_cxx? = nil
|
|
39
|
+
public init() { }
|
|
40
|
+
public func getCxxWrapper() -> HybridMatiksStrokeTextSpec_cxx {
|
|
41
|
+
#if DEBUG
|
|
42
|
+
guard self is HybridMatiksStrokeTextSpec else {
|
|
43
|
+
fatalError("`self` is not a `HybridMatiksStrokeTextSpec`! Did you accidentally inherit from `HybridMatiksStrokeTextSpec_base` instead of `HybridMatiksStrokeTextSpec`?")
|
|
44
|
+
}
|
|
45
|
+
#endif
|
|
46
|
+
if let cxxWrapper = self.cxxWrapper {
|
|
47
|
+
return cxxWrapper
|
|
48
|
+
} else {
|
|
49
|
+
let cxxWrapper = HybridMatiksStrokeTextSpec_cxx(self as! HybridMatiksStrokeTextSpec)
|
|
50
|
+
self.cxxWrapper = cxxWrapper
|
|
51
|
+
return cxxWrapper
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* A Swift base-protocol representing the MatiksStrokeText HybridObject.
|
|
58
|
+
* Implement this protocol to create Swift-based instances of MatiksStrokeText.
|
|
59
|
+
* ```swift
|
|
60
|
+
* class HybridMatiksStrokeText : HybridMatiksStrokeTextSpec {
|
|
61
|
+
* // ...
|
|
62
|
+
* }
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
public typealias HybridMatiksStrokeTextSpec = HybridMatiksStrokeTextSpec_protocol & HybridMatiksStrokeTextSpec_base
|