@react-navigation/native 8.0.0-alpha.3 → 8.0.0-alpha.5
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/android/build/.transforms/586a73aab4c351d3f13dc604ca6964e8/transformed/classes/classes_dex/classes.dex +0 -0
- package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/facebook/fbreact/specs/NativeMaterialSymbolModuleSpec.dex +0 -0
- package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/facebook/react/viewmanagers/ReactNavigationMaterialSymbolViewManagerDelegate.dex +0 -0
- package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/facebook/react/viewmanagers/ReactNavigationSFSymbolViewManagerDelegate.dex +0 -0
- package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/facebook/react/viewmanagers/ReactNavigationSFSymbolViewManagerInterface.dex +0 -0
- package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/reactnavigation/MaterialSymbolModule$getImageSource$1.dex +0 -0
- package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/reactnavigation/MaterialSymbolModule.dex +0 -0
- package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/reactnavigation/MaterialSymbolTypeface.dex +0 -0
- package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/reactnavigation/MaterialSymbolTypefaceResult.dex +0 -0
- package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/reactnavigation/MaterialSymbolView.dex +0 -0
- package/android/build/generated/source/codegen/java/com/facebook/fbreact/specs/NativeMaterialSymbolModuleSpec.java +2 -1
- package/android/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNavigationMaterialSymbolViewManagerDelegate.java +1 -1
- package/android/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNavigationSFSymbolViewManagerDelegate.java +42 -0
- package/android/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNavigationSFSymbolViewManagerInterface.java +14 -0
- package/android/build/generated/source/codegen/jni/ReactNavigationSpec-generated.cpp +2 -2
- package/android/build/generated/source/codegen/jni/react/renderer/components/ReactNavigationSpec/Props.cpp +72 -2
- package/android/build/generated/source/codegen/jni/react/renderer/components/ReactNavigationSpec/Props.h +21 -2
- package/android/build/generated/source/codegen/jni/react/renderer/components/ReactNavigationSpec/ReactNavigationSpecJSI-generated.cpp +4 -5
- package/android/build/generated/source/codegen/jni/react/renderer/components/ReactNavigationSpec/ReactNavigationSpecJSI.h +5 -5
- package/android/build/generated/source/codegen/schema.json +1 -1
- package/android/build/intermediates/assets/debug/mergeDebugAssets/fonts/MaterialSymbols.hash +1 -0
- package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
- package/android/build/intermediates/incremental/mergeDebugAssets/merger.xml +1 -1
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/facebook/fbreact/specs/NativeMaterialSymbolModuleSpec.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/facebook/react/viewmanagers/ReactNavigationMaterialSymbolViewManagerDelegate.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/facebook/react/viewmanagers/ReactNavigationSFSymbolViewManagerDelegate.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/facebook/react/viewmanagers/ReactNavigationSFSymbolViewManagerInterface.class +0 -0
- package/android/build/intermediates/react-navigation/fonts/MaterialSymbols.hash +1 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/facebook/fbreact/specs/NativeMaterialSymbolModuleSpec.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/facebook/react/viewmanagers/ReactNavigationMaterialSymbolViewManagerDelegate.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/facebook/react/viewmanagers/ReactNavigationSFSymbolViewManagerDelegate.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/facebook/react/viewmanagers/ReactNavigationSFSymbolViewManagerInterface.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/reactnavigation/MaterialSymbolModule$getImageSource$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/reactnavigation/MaterialSymbolModule.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/reactnavigation/MaterialSymbolTypeface.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/reactnavigation/MaterialSymbolTypefaceResult.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/reactnavigation/MaterialSymbolView.class +0 -0
- package/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/counters.tab +1 -1
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/local-state/build-history.bin +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/ReactNavigationSFSymbolViewManagerDelegate.class.uniqueId0 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/ReactNavigationSFSymbolViewManagerInterface.class.uniqueId1 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
- package/android/build/tmp/kotlin-classes/debug/org/reactnavigation/MaterialSymbolModule$getImageSource$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/org/reactnavigation/MaterialSymbolModule.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/org/reactnavigation/MaterialSymbolTypeface.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/org/reactnavigation/MaterialSymbolTypefaceResult.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/org/reactnavigation/MaterialSymbolView.class +0 -0
- package/android/build.gradle +80 -6
- package/android/src/main/java/org/reactnavigation/MaterialSymbolModule.kt +14 -4
- package/android/src/main/java/org/reactnavigation/MaterialSymbolTypeface.kt +40 -10
- package/android/src/main/java/org/reactnavigation/MaterialSymbolView.kt +15 -1
- package/assets/fonts/MaterialSymbolsOutlined_100.ttf +0 -0
- package/assets/fonts/MaterialSymbolsOutlined_200.ttf +0 -0
- package/assets/fonts/MaterialSymbolsOutlined_300.ttf +0 -0
- package/assets/fonts/MaterialSymbolsOutlined_500.ttf +0 -0
- package/assets/fonts/MaterialSymbolsOutlined_600.ttf +0 -0
- package/assets/fonts/MaterialSymbolsOutlined_700.ttf +0 -0
- package/assets/fonts/MaterialSymbolsRounded.codepoints +4102 -0
- package/assets/fonts/MaterialSymbolsRounded_100.ttf +0 -0
- package/assets/fonts/MaterialSymbolsRounded_200.ttf +0 -0
- package/assets/fonts/MaterialSymbolsRounded_300.ttf +0 -0
- package/assets/fonts/MaterialSymbolsRounded_400.ttf +0 -0
- package/assets/fonts/MaterialSymbolsRounded_500.ttf +0 -0
- package/assets/fonts/MaterialSymbolsRounded_600.ttf +0 -0
- package/assets/fonts/MaterialSymbolsRounded_700.ttf +0 -0
- package/assets/fonts/MaterialSymbolsSharp.codepoints +4102 -0
- package/assets/fonts/MaterialSymbolsSharp_100.ttf +0 -0
- package/assets/fonts/MaterialSymbolsSharp_200.ttf +0 -0
- package/assets/fonts/MaterialSymbolsSharp_300.ttf +0 -0
- package/assets/fonts/MaterialSymbolsSharp_400.ttf +0 -0
- package/assets/fonts/MaterialSymbolsSharp_500.ttf +0 -0
- package/assets/fonts/MaterialSymbolsSharp_600.ttf +0 -0
- package/assets/fonts/MaterialSymbolsSharp_700.ttf +0 -0
- package/ios/ReactNavigationSFSymbolView.mm +21 -0
- package/ios/ReactNavigationSFSymbolView.swift +257 -7
- package/lib/module/native/MaterialSymbol.android.js +11 -13
- package/lib/module/native/MaterialSymbol.android.js.map +1 -1
- package/lib/module/native/MaterialSymbolData.js +0 -7
- package/lib/module/native/MaterialSymbolData.js.map +1 -1
- package/lib/module/native/MaterialSymbolViewNativeComponent.ts +3 -3
- package/lib/module/native/NativeMaterialSymbolModule.js.map +1 -1
- package/lib/module/native/SFSymbol.ios.js +24 -1
- package/lib/module/native/SFSymbol.ios.js.map +1 -1
- package/lib/module/native/SFSymbolViewNativeComponent.ts +15 -1
- package/lib/module/native/constants.js +14 -0
- package/lib/module/native/constants.js.map +1 -0
- package/lib/typescript/src/native/MaterialSymbol.android.d.ts +2 -2
- package/lib/typescript/src/native/MaterialSymbol.android.d.ts.map +1 -1
- package/lib/typescript/src/native/MaterialSymbolData.d.ts +0 -3
- package/lib/typescript/src/native/MaterialSymbolData.d.ts.map +1 -1
- package/lib/typescript/src/native/MaterialSymbolViewNativeComponent.d.ts +2 -2
- package/lib/typescript/src/native/MaterialSymbolViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/native/NativeMaterialSymbolModule.d.ts +1 -1
- package/lib/typescript/src/native/NativeMaterialSymbolModule.d.ts.map +1 -1
- package/lib/typescript/src/native/SFSymbol.ios.d.ts +1 -1
- package/lib/typescript/src/native/SFSymbol.ios.d.ts.map +1 -1
- package/lib/typescript/src/native/SFSymbolViewNativeComponent.d.ts +15 -1
- package/lib/typescript/src/native/SFSymbolViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/native/constants.d.ts +12 -0
- package/lib/typescript/src/native/constants.d.ts.map +1 -0
- package/lib/typescript/src/native/types.d.ts +144 -0
- package/lib/typescript/src/native/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/native/MaterialSymbol.android.tsx +12 -15
- package/src/native/MaterialSymbolData.tsx +0 -4
- package/src/native/MaterialSymbolViewNativeComponent.ts +3 -3
- package/src/native/NativeMaterialSymbolModule.ts +3 -4
- package/src/native/SFSymbol.ios.tsx +24 -1
- package/src/native/SFSymbolViewNativeComponent.ts +15 -1
- package/src/native/constants.tsx +11 -0
- package/src/native/types.tsx +179 -0
package/android/build.gradle
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import groovy.json.JsonSlurper
|
|
2
|
+
|
|
1
3
|
buildscript {
|
|
2
4
|
ext.ReactNavigation = [
|
|
3
5
|
kotlinVersion: "2.0.21",
|
|
@@ -58,15 +60,87 @@ android {
|
|
|
58
60
|
}
|
|
59
61
|
}
|
|
60
62
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
tasks.register('copyMaterialFonts', Copy) {
|
|
64
|
+
def packageJsonFile = file(rootDir.path + "/../package.json")
|
|
65
|
+
def fontsConfig = null
|
|
66
|
+
|
|
67
|
+
if (packageJsonFile.exists()) {
|
|
68
|
+
def packageJson = new JsonSlurper().parse(packageJsonFile)
|
|
69
|
+
|
|
70
|
+
fontsConfig = packageJson["react-navigation"]?.get("material-symbols")?.get("fonts")
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
fontsConfig = fontsConfig != null ? fontsConfig : [[variant: "outlined", weights: [400]]]
|
|
74
|
+
|
|
75
|
+
def assetsFontsDir = file("../assets/fonts")
|
|
76
|
+
def availableFonts = assetsFontsDir.listFiles()
|
|
77
|
+
?.findAll { it.name.startsWith("MaterialSymbols") && it.name.endsWith(".ttf") }
|
|
78
|
+
?.collect { it.name.replaceFirst(/^MaterialSymbols/, '').replaceFirst(/\.ttf$/, '') } ?: []
|
|
79
|
+
|
|
80
|
+
def validVariants = availableFonts.collect { it.split('_')[0].toLowerCase() }.unique().sort()
|
|
81
|
+
def validWeights = availableFonts.collect { it.split('_')[1] as int }.unique().sort()
|
|
82
|
+
|
|
83
|
+
def errors = [] as Set
|
|
84
|
+
|
|
85
|
+
fontsConfig.each { font ->
|
|
86
|
+
if (font.variant && !validVariants.contains(font.variant.toLowerCase())) {
|
|
87
|
+
errors << "Invalid font variant: ${font.variant}"
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
font.weights.each { weight ->
|
|
91
|
+
if (!validWeights.contains(weight)) {
|
|
92
|
+
errors << "Invalid font weight: ${weight}"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (errors) {
|
|
98
|
+
throw new GradleException(
|
|
99
|
+
errors.join("\n") + "\n\nAvailable variants: ${validVariants.join(", ")}.\nAvailable weights: ${validWeights.join(", ")}."
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
def fontFiles = fontsConfig.collectMany { font ->
|
|
104
|
+
def variant = font.variant?.capitalize() ?: ""
|
|
105
|
+
|
|
106
|
+
font.weights.collect { weight -> "MaterialSymbols${variant}_${weight}.ttf" }
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (fontFiles) {
|
|
110
|
+
from(assetsFontsDir) { include fontFiles }
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
into layout.buildDirectory.dir("intermediates/react-navigation/fonts")
|
|
114
|
+
|
|
115
|
+
doFirst {
|
|
116
|
+
if (destinationDir.exists()) {
|
|
117
|
+
def extraFiles = destinationDir.listFiles()?.findAll { file -> !fontFiles.contains(file.name) }
|
|
118
|
+
|
|
119
|
+
extraFiles?.each { file -> file.delete() }
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
doLast {
|
|
124
|
+
def digest = java.security.MessageDigest.getInstance("MD5")
|
|
125
|
+
|
|
126
|
+
fontFiles.sort().each { name ->
|
|
127
|
+
def fontFile = new File(assetsFontsDir, name)
|
|
128
|
+
|
|
129
|
+
if (fontFile.exists()) {
|
|
130
|
+
digest.update(fontFile.bytes)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
def hash = digest.digest().encodeHex().toString().take(8)
|
|
135
|
+
def hashFile = new File(destinationDir, "MaterialSymbols.hash")
|
|
136
|
+
|
|
137
|
+
hashFile.text = hash
|
|
138
|
+
}
|
|
65
139
|
}
|
|
66
140
|
|
|
67
|
-
android.sourceSets.main.assets.srcDirs +=
|
|
141
|
+
android.sourceSets.main.assets.srcDirs += layout.buildDirectory.dir("intermediates/react-navigation")
|
|
68
142
|
|
|
69
|
-
preBuild.dependsOn(
|
|
143
|
+
preBuild.dependsOn(copyMaterialFonts)
|
|
70
144
|
|
|
71
145
|
dependencies {
|
|
72
146
|
implementation "com.facebook.react:react-android"
|
|
@@ -26,8 +26,13 @@ class MaterialSymbolModule(reactContext: ReactApplicationContext) :
|
|
|
26
26
|
private val scope = CoroutineScope(Dispatchers.IO + SupervisorJob())
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
private val fontHash: String by lazy {
|
|
30
|
+
reactApplicationContext.assets.open("fonts/MaterialSymbols.hash").bufferedReader().readText()
|
|
31
|
+
.trim()
|
|
32
|
+
}
|
|
33
|
+
|
|
29
34
|
override fun getImageSource(
|
|
30
|
-
name: String, variant: String
|
|
35
|
+
name: String, variant: String?, weight: Double?, size: Double, color: ReadableMap
|
|
31
36
|
): String {
|
|
32
37
|
val colorValue = color.getDynamic("value").let {
|
|
33
38
|
when (it.type) {
|
|
@@ -43,8 +48,13 @@ class MaterialSymbolModule(reactContext: ReactApplicationContext) :
|
|
|
43
48
|
val density = reactApplicationContext.resources.displayMetrics.density
|
|
44
49
|
val scaledSize = (size * density).roundToInt().coerceAtLeast(1)
|
|
45
50
|
|
|
51
|
+
val (resolvedTypeface, typefaceSuffix) = MaterialSymbolTypeface.get(
|
|
52
|
+
reactApplicationContext, variant, weight?.toInt()
|
|
53
|
+
)
|
|
54
|
+
|
|
46
55
|
val cacheDir = File(
|
|
47
|
-
reactApplicationContext.cacheDir,
|
|
56
|
+
reactApplicationContext.cacheDir,
|
|
57
|
+
"react_navigation/material_symbols/$typefaceSuffix/$fontHash"
|
|
48
58
|
)
|
|
49
59
|
|
|
50
60
|
val cacheKey = "${name.hashCode()}_${scaledSize}_$resolvedColor"
|
|
@@ -55,14 +65,14 @@ class MaterialSymbolModule(reactContext: ReactApplicationContext) :
|
|
|
55
65
|
}
|
|
56
66
|
|
|
57
67
|
scope.launch {
|
|
58
|
-
cacheDir.parentFile?.listFiles { it.isDirectory && it.name !=
|
|
68
|
+
cacheDir.parentFile?.listFiles { it.isDirectory && it.name != fontHash }
|
|
59
69
|
?.forEach { it.deleteRecursively() }
|
|
60
70
|
}
|
|
61
71
|
|
|
62
72
|
cacheDir.mkdirs()
|
|
63
73
|
|
|
64
74
|
val paint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
|
|
65
|
-
typeface =
|
|
75
|
+
typeface = resolvedTypeface
|
|
66
76
|
textSize = scaledSize.toFloat()
|
|
67
77
|
textAlign = Paint.Align.CENTER
|
|
68
78
|
|
|
@@ -3,21 +3,26 @@ package org.reactnavigation
|
|
|
3
3
|
import android.content.Context
|
|
4
4
|
import android.graphics.Typeface
|
|
5
5
|
|
|
6
|
+
data class MaterialSymbolTypefaceResult(val typeface: Typeface, val suffix: String)
|
|
7
|
+
|
|
6
8
|
object MaterialSymbolTypeface {
|
|
7
9
|
private val typefaces = mutableMapOf<String, Typeface>()
|
|
10
|
+
private var defaultSuffix: String? = null
|
|
8
11
|
|
|
9
|
-
fun get(context: Context, variant: String?, weight: Int?):
|
|
10
|
-
val
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
val resolvedWeight = weight ?: 400
|
|
12
|
+
fun get(context: Context, variant: String?, weight: Int?): MaterialSymbolTypefaceResult {
|
|
13
|
+
val suffix = if (variant != null && weight != null) {
|
|
14
|
+
val resolvedVariant = when (variant) {
|
|
15
|
+
"rounded" -> "Rounded"
|
|
16
|
+
"sharp" -> "Sharp"
|
|
17
|
+
else -> "Outlined"
|
|
18
|
+
}
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
"${resolvedVariant}_$weight"
|
|
21
|
+
} else {
|
|
22
|
+
getDefaultSuffix(context)
|
|
23
|
+
}
|
|
19
24
|
|
|
20
|
-
|
|
25
|
+
val typeface = typefaces.getOrPut(suffix) {
|
|
21
26
|
val path = "fonts/MaterialSymbols${suffix}.ttf"
|
|
22
27
|
|
|
23
28
|
try {
|
|
@@ -26,5 +31,30 @@ object MaterialSymbolTypeface {
|
|
|
26
31
|
throw RuntimeException("$path not found.", e)
|
|
27
32
|
}
|
|
28
33
|
}
|
|
34
|
+
|
|
35
|
+
return MaterialSymbolTypefaceResult(typeface, suffix)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
private fun getDefaultSuffix(context: Context): String {
|
|
39
|
+
defaultSuffix?.let { return it }
|
|
40
|
+
|
|
41
|
+
val fonts = context.assets.list("fonts")
|
|
42
|
+
?.filter { it.startsWith("MaterialSymbols") && it.endsWith(".ttf") } ?: emptyList()
|
|
43
|
+
|
|
44
|
+
if (fonts.isEmpty()) {
|
|
45
|
+
throw RuntimeException("No MaterialSymbols font found in assets.")
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (fonts.size > 1) {
|
|
49
|
+
throw RuntimeException(
|
|
50
|
+
"Multiple MaterialSymbols fonts found in assets: ${fonts.joinToString()}. " + "Please specify a variant and weight explicitly."
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
val suffix = fonts[0].removePrefix("MaterialSymbols").removeSuffix(".ttf")
|
|
55
|
+
|
|
56
|
+
defaultSuffix = suffix
|
|
57
|
+
|
|
58
|
+
return suffix
|
|
29
59
|
}
|
|
30
60
|
}
|
|
@@ -12,6 +12,10 @@ class MaterialSymbolView @JvmOverloads constructor(
|
|
|
12
12
|
private var variant: String? = null
|
|
13
13
|
private var weight: Int? = null
|
|
14
14
|
|
|
15
|
+
init {
|
|
16
|
+
updateTypeface()
|
|
17
|
+
}
|
|
18
|
+
|
|
15
19
|
override fun onDraw(canvas: Canvas) {
|
|
16
20
|
val text = text?.toString() ?: return
|
|
17
21
|
|
|
@@ -27,6 +31,8 @@ class MaterialSymbolView @JvmOverloads constructor(
|
|
|
27
31
|
|
|
28
32
|
fun setName(name: String) {
|
|
29
33
|
text = name
|
|
34
|
+
|
|
35
|
+
invalidate()
|
|
30
36
|
}
|
|
31
37
|
|
|
32
38
|
fun setVariant(variant: String) {
|
|
@@ -35,6 +41,7 @@ class MaterialSymbolView @JvmOverloads constructor(
|
|
|
35
41
|
}
|
|
36
42
|
|
|
37
43
|
this.variant = variant
|
|
44
|
+
|
|
38
45
|
updateTypeface()
|
|
39
46
|
}
|
|
40
47
|
|
|
@@ -44,11 +51,18 @@ class MaterialSymbolView @JvmOverloads constructor(
|
|
|
44
51
|
}
|
|
45
52
|
|
|
46
53
|
this.weight = weight
|
|
54
|
+
|
|
47
55
|
updateTypeface()
|
|
48
56
|
}
|
|
49
57
|
|
|
50
58
|
private fun updateTypeface() {
|
|
51
|
-
setTypeface(
|
|
59
|
+
setTypeface(
|
|
60
|
+
MaterialSymbolTypeface.get(
|
|
61
|
+
context,
|
|
62
|
+
variant?.ifEmpty { null },
|
|
63
|
+
weight.takeIf { it != 0 }).typeface
|
|
64
|
+
)
|
|
65
|
+
|
|
52
66
|
invalidate()
|
|
53
67
|
}
|
|
54
68
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|