@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,31 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "NitroRnStrokeText"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = package["homepage"]
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.authors = package["author"]
|
|
12
|
+
|
|
13
|
+
s.platforms = { :ios => min_ios_version_supported, :visionos => 1.0 }
|
|
14
|
+
s.source = { :git => "https://github.com/mrousavy/nitro.git", :tag => "#{s.version}" }
|
|
15
|
+
|
|
16
|
+
s.source_files = [
|
|
17
|
+
# Implementation (Swift)
|
|
18
|
+
"ios/**/*.{swift}",
|
|
19
|
+
# Autolinking/Registration (Objective-C++)
|
|
20
|
+
"ios/**/*.{m,mm}",
|
|
21
|
+
# Implementation (C++ objects)
|
|
22
|
+
"cpp/**/*.{hpp,cpp}",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
load 'nitrogen/generated/ios/NitroRnStrokeText+autolinking.rb'
|
|
26
|
+
add_nitrogen_files(s)
|
|
27
|
+
|
|
28
|
+
s.dependency 'React-jsi'
|
|
29
|
+
s.dependency 'React-callinvoker'
|
|
30
|
+
install_modules_dependencies(s)
|
|
31
|
+
end
|
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# react-native-nitro-template
|
|
2
|
+
|
|
3
|
+
This is a template for Nitro Modules.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
Clone this repo, and change all `$$*$$` names according to your `nitro.json` file.
|
|
8
|
+
|
|
9
|
+
## Contributing
|
|
10
|
+
|
|
11
|
+
Contribute a change to this template to update it for newer React Native versions.
|
|
12
|
+
|
|
13
|
+
## Structure
|
|
14
|
+
|
|
15
|
+
- [`android/`](android): All your `android`-specific implementations.
|
|
16
|
+
- [`build.gradle`](android/build.gradle): The gradle build file. This contains four important pieces:
|
|
17
|
+
1. Standard react-native library boilerplate code
|
|
18
|
+
2. Configures Kotlin (`apply plugin: 'org.jetbrains.kotlin.android'`)
|
|
19
|
+
3. Adds all Nitrogen files (`apply from: '.../NitroRnStrokeText+autolinking.gradle'`)
|
|
20
|
+
4. Triggers the native C++ build (via CMake/`externalNativeBuild`)
|
|
21
|
+
- [`CMakeLists.txt`](android/CMakeLists.txt): The CMake build file to build C++ code. This contains four important pieces:
|
|
22
|
+
1. Creates a library called `NitroRnStrokeText` (same as in `nitro.json`)
|
|
23
|
+
2. Adds all Nitrogen files (`include(.../NitroRnStrokeText+autolinking.cmake)`)
|
|
24
|
+
3. Adds all custom C++ files (only `HybridTestObjectCpp.cpp`)
|
|
25
|
+
4. Adds a `cpp-adapter.cpp` file, which autolinks all C++ HybridObjects (only `HybridTestObjectCpp`)
|
|
26
|
+
- [`src/main/java/com/margelo/nitro/rnstroketext/`](android/src/main/java/com/margelo/nitro/rnstroketext/): All Kotlin implementations.
|
|
27
|
+
- [`NitroRnStrokeTextPackage.kt`](android/src/main/java/com/margelo/nitro/rnstroketext/NitroRnStrokeTextPackage.kt): The react-native package. You need this because the react-native CLI only adds libraries if they have a `*Package.kt` file. In here, you can autolink all Kotlin HybridObjects.
|
|
28
|
+
- [`cpp/`](cpp): All your cross-platform implementations. (only `HybridTestObjectCpp.cpp`)
|
|
29
|
+
- [`ios/`](ios): All your iOS-specific implementations.
|
|
30
|
+
- [`nitrogen/`](nitrogen): All files generated by nitrogen. You should commit this folder to git.
|
|
31
|
+
- [`src/`](src): The TypeScript codebase. This defines all HybridObjects and loads them at runtime.
|
|
32
|
+
- [`specs/`](src/specs): All HybridObject types. Nitrogen will run on all `*.nitro.ts` files.
|
|
33
|
+
- [`nitro.json`](nitro.json): The configuration file for nitrogen. This will define all native namespaces, as well as the library name.
|
|
34
|
+
- [`NitroRnStrokeText.podspec`](NitroRnStrokeText.podspec): The iOS podspec build file to build the iOS code. This contains three important pieces:
|
|
35
|
+
1. Specifies the Pod's name. This must be identical to the name specified in `nitro.json`.
|
|
36
|
+
2. Adds all of your `.swift` or `.cpp` files (implementations).
|
|
37
|
+
3. Adds all Nitrogen files (`add_nitrogen_files(s)`)
|
|
38
|
+
- [`package.json`](package.json): The npm package.json file. `react-native-nitro-modules` should be a `peerDependency`.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
project(NitroRnStrokeText)
|
|
2
|
+
cmake_minimum_required(VERSION 3.9.0)
|
|
3
|
+
|
|
4
|
+
set (PACKAGE_NAME NitroRnStrokeText)
|
|
5
|
+
set (CMAKE_VERBOSE_MAKEFILE ON)
|
|
6
|
+
set (CMAKE_CXX_STANDARD 20)
|
|
7
|
+
|
|
8
|
+
# Define C++ library and add all sources
|
|
9
|
+
add_library(${PACKAGE_NAME} SHARED
|
|
10
|
+
src/main/cpp/cpp-adapter.cpp
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
# Add Nitrogen specs :)
|
|
14
|
+
include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/NitroRnStrokeText+autolinking.cmake)
|
|
15
|
+
|
|
16
|
+
# Set up local includes
|
|
17
|
+
include_directories(
|
|
18
|
+
"src/main/cpp"
|
|
19
|
+
"../cpp"
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
find_library(LOG_LIB log)
|
|
23
|
+
|
|
24
|
+
# Link all libraries together
|
|
25
|
+
target_link_libraries(
|
|
26
|
+
${PACKAGE_NAME}
|
|
27
|
+
${LOG_LIB}
|
|
28
|
+
android # <-- Android core
|
|
29
|
+
)
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
repositories {
|
|
3
|
+
google()
|
|
4
|
+
mavenCentral()
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
dependencies {
|
|
8
|
+
classpath "com.android.tools.build:gradle:8.13.2"
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
def reactNativeArchitectures() {
|
|
13
|
+
def value = rootProject.getProperties().get("reactNativeArchitectures")
|
|
14
|
+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
def isNewArchitectureEnabled() {
|
|
18
|
+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
apply plugin: "com.android.library"
|
|
22
|
+
apply plugin: 'org.jetbrains.kotlin.android'
|
|
23
|
+
apply from: '../nitrogen/generated/android/NitroRnStrokeText+autolinking.gradle'
|
|
24
|
+
apply from: "./fix-prefab.gradle"
|
|
25
|
+
|
|
26
|
+
def getExtOrDefault(name) {
|
|
27
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["NitroRnStrokeText_" + name]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
def getExtOrIntegerDefault(name) {
|
|
31
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["NitroRnStrokeText_" + name]).toInteger()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
android {
|
|
35
|
+
namespace "com.margelo.nitro.rnstroketext"
|
|
36
|
+
|
|
37
|
+
ndkVersion getExtOrDefault("ndkVersion")
|
|
38
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
39
|
+
|
|
40
|
+
defaultConfig {
|
|
41
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
42
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
43
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
44
|
+
|
|
45
|
+
externalNativeBuild {
|
|
46
|
+
cmake {
|
|
47
|
+
cppFlags "-frtti -fexceptions -Wall -Wextra -fstack-protector-all"
|
|
48
|
+
arguments "-DANDROID_STL=c++_shared", "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
|
|
49
|
+
abiFilters (*reactNativeArchitectures())
|
|
50
|
+
|
|
51
|
+
buildTypes {
|
|
52
|
+
debug {
|
|
53
|
+
cppFlags "-O1 -g"
|
|
54
|
+
}
|
|
55
|
+
release {
|
|
56
|
+
cppFlags "-O2"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
externalNativeBuild {
|
|
64
|
+
cmake {
|
|
65
|
+
path "CMakeLists.txt"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
packagingOptions {
|
|
70
|
+
excludes = [
|
|
71
|
+
"META-INF",
|
|
72
|
+
"META-INF/**",
|
|
73
|
+
"**/libc++_shared.so",
|
|
74
|
+
"**/libNitroModules.so",
|
|
75
|
+
"**/libfbjni.so",
|
|
76
|
+
"**/libjsi.so",
|
|
77
|
+
"**/libfolly_json.so",
|
|
78
|
+
"**/libfolly_runtime.so",
|
|
79
|
+
"**/libglog.so",
|
|
80
|
+
"**/libhermes.so",
|
|
81
|
+
"**/libhermes-executor-debug.so",
|
|
82
|
+
"**/libhermes_executor.so",
|
|
83
|
+
"**/libreactnative.so",
|
|
84
|
+
"**/libreactnativejni.so",
|
|
85
|
+
"**/libturbomodulejsijni.so",
|
|
86
|
+
"**/libreact_nativemodule_core.so",
|
|
87
|
+
"**/libjscexecutor.so"
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
buildFeatures {
|
|
92
|
+
buildConfig true
|
|
93
|
+
prefab true
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
buildTypes {
|
|
97
|
+
release {
|
|
98
|
+
minifyEnabled false
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
lintOptions {
|
|
103
|
+
disable "GradleCompatible"
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
compileOptions {
|
|
107
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
108
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
sourceSets {
|
|
112
|
+
main {
|
|
113
|
+
if (isNewArchitectureEnabled()) {
|
|
114
|
+
java.srcDirs += [
|
|
115
|
+
// React Codegen files
|
|
116
|
+
"${project.buildDir}/generated/source/codegen/java"
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
repositories {
|
|
124
|
+
mavenCentral()
|
|
125
|
+
google()
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
dependencies {
|
|
130
|
+
// For < 0.71, this will be from the local maven repo
|
|
131
|
+
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
132
|
+
//noinspection GradleDynamicVersion
|
|
133
|
+
compileOnly "com.facebook.react:react-native:+"
|
|
134
|
+
|
|
135
|
+
// Add a dependency on NitroModules
|
|
136
|
+
compileOnly project(":react-native-nitro-modules")
|
|
137
|
+
}
|
|
138
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
tasks.configureEach { task ->
|
|
2
|
+
// Make sure that we generate our prefab publication file only after having built the native library
|
|
3
|
+
// so that not a header publication file, but a full configuration publication will be generated, which
|
|
4
|
+
// will include the .so file
|
|
5
|
+
|
|
6
|
+
def prefabConfigurePattern = ~/^prefab(.+)ConfigurePackage$/
|
|
7
|
+
def matcher = task.name =~ prefabConfigurePattern
|
|
8
|
+
if (matcher.matches()) {
|
|
9
|
+
def variantName = matcher[0][1]
|
|
10
|
+
task.outputs.upToDateWhen { false }
|
|
11
|
+
task.dependsOn("externalNativeBuild${variantName}")
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
afterEvaluate {
|
|
16
|
+
def abis = reactNativeArchitectures()
|
|
17
|
+
rootProject.allprojects.each { proj ->
|
|
18
|
+
if (proj === rootProject) return
|
|
19
|
+
|
|
20
|
+
def dependsOnThisLib = proj.configurations.findAll { it.canBeResolved }.any { config ->
|
|
21
|
+
config.dependencies.any { dep ->
|
|
22
|
+
dep.group == project.group && dep.name == project.name
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (!dependsOnThisLib && proj != project) return
|
|
26
|
+
|
|
27
|
+
if (!proj.plugins.hasPlugin('com.android.application') && !proj.plugins.hasPlugin('com.android.library')) {
|
|
28
|
+
return
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
def variants = proj.android.hasProperty('applicationVariants') ? proj.android.applicationVariants : proj.android.libraryVariants
|
|
32
|
+
// Touch the prefab_config.json files to ensure that in ExternalNativeJsonGenerator.kt we will re-trigger the prefab CLI to
|
|
33
|
+
// generate a libnameConfig.cmake file that will contain our native library (.so).
|
|
34
|
+
// See this condition: https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:build-system/gradle-core/src/main/java/com/android/build/gradle/tasks/ExternalNativeJsonGenerator.kt;l=207-219?q=createPrefabBuildSystemGlue
|
|
35
|
+
variants.all { variant ->
|
|
36
|
+
def variantName = variant.name
|
|
37
|
+
abis.each { abi ->
|
|
38
|
+
def searchDir = new File(proj.projectDir, ".cxx/${variantName}")
|
|
39
|
+
if (!searchDir.exists()) return
|
|
40
|
+
def matches = []
|
|
41
|
+
searchDir.eachDir { randomDir ->
|
|
42
|
+
def prefabFile = new File(randomDir, "${abi}/prefab_config.json")
|
|
43
|
+
if (prefabFile.exists()) matches << prefabFile
|
|
44
|
+
}
|
|
45
|
+
matches.each { prefabConfig ->
|
|
46
|
+
prefabConfig.setLastModified(System.currentTimeMillis())
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
package com.margelo.nitro.rnstroketext
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.graphics.Typeface
|
|
5
|
+
import com.facebook.react.views.text.ReactFontManager
|
|
6
|
+
import java.io.IOException
|
|
7
|
+
|
|
8
|
+
object FontUtil {
|
|
9
|
+
|
|
10
|
+
@JvmStatic
|
|
11
|
+
fun getFont(context: Context, fontFamily: String): Typeface? {
|
|
12
|
+
return getFontFromAssets(context, fontFamily)
|
|
13
|
+
?: getFontFromReactFontManager(context, fontFamily)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
private fun getFontFromAssets(context: Context, fontFamily: String): Typeface? {
|
|
17
|
+
val fontPath = findFontFile(context, "fonts/", fontFamily)
|
|
18
|
+
return fontPath?.let {
|
|
19
|
+
Typeface.createFromAsset(context.assets, it)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
private fun getFontFromReactFontManager(
|
|
24
|
+
context: Context,
|
|
25
|
+
fontFamily: String
|
|
26
|
+
): Typeface? {
|
|
27
|
+
return ReactFontManager.getInstance()
|
|
28
|
+
.getTypeface(fontFamily, Typeface.NORMAL, context.assets)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private fun findFontFile(
|
|
32
|
+
context: Context,
|
|
33
|
+
folderPath: String,
|
|
34
|
+
fontName: String
|
|
35
|
+
): String? {
|
|
36
|
+
return try {
|
|
37
|
+
context.assets.list(folderPath)
|
|
38
|
+
?.firstOrNull { file ->
|
|
39
|
+
file.startsWith(fontName) &&
|
|
40
|
+
(file.endsWith(".ttf") || file.endsWith(".otf"))
|
|
41
|
+
}
|
|
42
|
+
?.let { "$folderPath$it" }
|
|
43
|
+
} catch (e: IOException) {
|
|
44
|
+
e.printStackTrace()
|
|
45
|
+
null
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
package com.margelo.nitro.rnstroketext
|
|
2
|
+
import com.margelo.nitro.rnstroketext.HybridMatiksStrokeTextSpec
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.view.View
|
|
5
|
+
import com.margelo.nitro.rnstroketext.TextAlign
|
|
6
|
+
|
|
7
|
+
class HybridMatiksStrokeText(
|
|
8
|
+
context: Context
|
|
9
|
+
) : HybridMatiksStrokeTextSpec() {
|
|
10
|
+
private val strokeTextView = StrokeTextView(context)
|
|
11
|
+
|
|
12
|
+
override val view: View
|
|
13
|
+
get() = strokeTextView
|
|
14
|
+
|
|
15
|
+
override fun measureDimensions(): Dimensions {
|
|
16
|
+
val (width, height) = strokeTextView.getTextDimensions()
|
|
17
|
+
return Dimensions(width, height)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// props
|
|
21
|
+
override var width: Double? = 0.0
|
|
22
|
+
set(value) {
|
|
23
|
+
field = value
|
|
24
|
+
strokeTextView.setCustomWidth(value?.toFloat() ?: 0f)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
override var text: String = ""
|
|
28
|
+
set(value) {
|
|
29
|
+
field = value
|
|
30
|
+
strokeTextView.setText(value)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
override var fontSize: Double? = 0.0
|
|
34
|
+
set(value) {
|
|
35
|
+
field = value
|
|
36
|
+
strokeTextView.setFontSize(value?.toFloat() ?: 0f)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
override var color: String? = ""
|
|
40
|
+
set(value) {
|
|
41
|
+
field = value
|
|
42
|
+
strokeTextView.setTextColor(value ?: "")
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
override var strokeColor: String? = ""
|
|
46
|
+
set(value) {
|
|
47
|
+
field = value
|
|
48
|
+
strokeTextView.setStrokeColor(value ?: "")
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
override var strokeWidth: Double? = 0.0
|
|
52
|
+
set(value) {
|
|
53
|
+
field = value
|
|
54
|
+
strokeTextView.setStrokeWidth(value?.toFloat() ?: 0f)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
override var fontFamily: String? = ""
|
|
58
|
+
set(value) {
|
|
59
|
+
field = value
|
|
60
|
+
strokeTextView.setFontFamily(value ?: "")
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
override var align: TextAlign? = TextAlign.CENTER
|
|
64
|
+
set(value) {
|
|
65
|
+
field = value
|
|
66
|
+
strokeTextView.setTextAlignment(value?.name?.lowercase() ?: "center")
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
override var numberOfLines: Double? = 0.0
|
|
70
|
+
set(value) {
|
|
71
|
+
field = value
|
|
72
|
+
strokeTextView.setNumberOfLines(value?.toInt() ?: 0)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
override var ellipsis: Boolean? = false
|
|
76
|
+
set(value) {
|
|
77
|
+
field = value
|
|
78
|
+
strokeTextView.setEllipsis(value ?: false)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
package com.margelo.nitro.rnstroketext
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.NativeModule
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
6
|
+
import com.facebook.react.BaseReactPackage
|
|
7
|
+
import com.facebook.react.uimanager.ViewManager
|
|
8
|
+
import com.margelo.nitro.rnstroketext.views.HybridMatiksStrokeTextManager
|
|
9
|
+
|
|
10
|
+
class NitroRnStrokeTextPackage : BaseReactPackage() {
|
|
11
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? = null
|
|
12
|
+
|
|
13
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider = ReactModuleInfoProvider { HashMap() }
|
|
14
|
+
|
|
15
|
+
override fun createViewManagers(
|
|
16
|
+
reactContext: ReactApplicationContext
|
|
17
|
+
): List<ViewManager<*, *>> {
|
|
18
|
+
return listOf(
|
|
19
|
+
HybridMatiksStrokeTextManager()
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
companion object {
|
|
24
|
+
init {
|
|
25
|
+
NitroRnStrokeTextOnLoad.initializeNative()
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|