@react-navigation/native 8.0.0-alpha.1 → 8.0.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (287) hide show
  1. package/android/build.gradle +96 -15
  2. package/android/src/main/java/org/reactnavigation/MaterialSymbolModule.kt +43 -54
  3. package/android/src/main/java/org/reactnavigation/MaterialSymbolTypeface.kt +54 -3
  4. package/android/src/main/java/org/reactnavigation/MaterialSymbolView.kt +52 -7
  5. package/android/src/main/java/org/reactnavigation/MaterialSymbolViewManager.kt +14 -7
  6. package/android/src/main/java/org/reactnavigation/ReactNavigationPackage.kt +11 -14
  7. package/assets/fonts/MaterialSymbolsOutlined_100.ttf +0 -0
  8. package/assets/fonts/MaterialSymbolsOutlined_200.ttf +0 -0
  9. package/assets/fonts/MaterialSymbolsOutlined_300.ttf +0 -0
  10. package/{android/build/intermediates/assets/debug/mergeDebugAssets/fonts/MaterialSymbolsOutlined.ttf → assets/fonts/MaterialSymbolsOutlined_400.ttf} +0 -0
  11. package/assets/fonts/MaterialSymbolsOutlined_500.ttf +0 -0
  12. package/assets/fonts/MaterialSymbolsOutlined_600.ttf +0 -0
  13. package/assets/fonts/MaterialSymbolsOutlined_700.ttf +0 -0
  14. package/assets/fonts/MaterialSymbolsRounded_100.ttf +0 -0
  15. package/assets/fonts/MaterialSymbolsRounded_200.ttf +0 -0
  16. package/assets/fonts/MaterialSymbolsRounded_300.ttf +0 -0
  17. package/assets/fonts/{MaterialSymbolsRounded.ttf → MaterialSymbolsRounded_400.ttf} +0 -0
  18. package/assets/fonts/MaterialSymbolsRounded_500.ttf +0 -0
  19. package/assets/fonts/MaterialSymbolsRounded_600.ttf +0 -0
  20. package/assets/fonts/MaterialSymbolsRounded_700.ttf +0 -0
  21. package/assets/fonts/MaterialSymbolsSharp_100.ttf +0 -0
  22. package/assets/fonts/MaterialSymbolsSharp_200.ttf +0 -0
  23. package/assets/fonts/MaterialSymbolsSharp_300.ttf +0 -0
  24. package/assets/fonts/{MaterialSymbolsSharp.ttf → MaterialSymbolsSharp_400.ttf} +0 -0
  25. package/assets/fonts/MaterialSymbolsSharp_500.ttf +0 -0
  26. package/assets/fonts/MaterialSymbolsSharp_600.ttf +0 -0
  27. package/assets/fonts/MaterialSymbolsSharp_700.ttf +0 -0
  28. package/ios/ReactNavigationSFSymbolView.mm +21 -0
  29. package/ios/ReactNavigationSFSymbolView.swift +257 -7
  30. package/lib/module/NavigationContainer.js +7 -2
  31. package/lib/module/NavigationContainer.js.map +1 -1
  32. package/lib/module/index.js +2 -1
  33. package/lib/module/index.js.map +1 -1
  34. package/lib/module/native/MaterialSymbol.android.js +11 -10
  35. package/lib/module/native/MaterialSymbol.android.js.map +1 -1
  36. package/lib/module/native/MaterialSymbolData.js +0 -9
  37. package/lib/module/native/MaterialSymbolData.js.map +1 -1
  38. package/lib/module/native/MaterialSymbolViewNativeComponent.ts +6 -2
  39. package/lib/module/native/SFSymbol.ios.js +24 -1
  40. package/lib/module/native/SFSymbol.ios.js.map +1 -1
  41. package/lib/module/native/SFSymbolViewNativeComponent.ts +15 -1
  42. package/lib/module/native/constants.js +14 -0
  43. package/lib/module/native/constants.js.map +1 -0
  44. package/lib/module/theming/DarkTheme.js +4 -4
  45. package/lib/module/theming/{DefaultTheme.js → LightTheme.js} +5 -5
  46. package/lib/module/theming/LightTheme.js.map +1 -0
  47. package/lib/module/theming/MaterialTheme.android.js +29 -0
  48. package/lib/module/theming/MaterialTheme.android.js.map +1 -0
  49. package/lib/module/theming/MaterialTheme.js +18 -0
  50. package/lib/module/theming/MaterialTheme.js.map +1 -0
  51. package/lib/module/useLinking.native.js +20 -3
  52. package/lib/module/useLinking.native.js.map +1 -1
  53. package/lib/typescript/src/NavigationContainer.d.ts +6 -1
  54. package/lib/typescript/src/NavigationContainer.d.ts.map +1 -1
  55. package/lib/typescript/src/index.d.ts +2 -1
  56. package/lib/typescript/src/index.d.ts.map +1 -1
  57. package/lib/typescript/src/native/MaterialSymbol.android.d.ts +2 -2
  58. package/lib/typescript/src/native/MaterialSymbol.android.d.ts.map +1 -1
  59. package/lib/typescript/src/native/MaterialSymbolData.d.ts +0 -5
  60. package/lib/typescript/src/native/MaterialSymbolData.d.ts.map +1 -1
  61. package/lib/typescript/src/native/MaterialSymbolViewNativeComponent.d.ts +3 -2
  62. package/lib/typescript/src/native/MaterialSymbolViewNativeComponent.d.ts.map +1 -1
  63. package/lib/typescript/src/native/NativeMaterialSymbolModule.d.ts +1 -1
  64. package/lib/typescript/src/native/NativeMaterialSymbolModule.d.ts.map +1 -1
  65. package/lib/typescript/src/native/SFSymbol.ios.d.ts +1 -1
  66. package/lib/typescript/src/native/SFSymbol.ios.d.ts.map +1 -1
  67. package/lib/typescript/src/native/SFSymbolViewNativeComponent.d.ts +15 -1
  68. package/lib/typescript/src/native/SFSymbolViewNativeComponent.d.ts.map +1 -1
  69. package/lib/typescript/src/native/constants.d.ts +12 -0
  70. package/lib/typescript/src/native/constants.d.ts.map +1 -0
  71. package/lib/typescript/src/native/types.d.ts +139 -3
  72. package/lib/typescript/src/native/types.d.ts.map +1 -1
  73. package/lib/typescript/src/theming/DarkTheme.d.ts +4 -4
  74. package/lib/typescript/src/theming/{DefaultTheme.d.ts → LightTheme.d.ts} +5 -5
  75. package/lib/typescript/src/theming/LightTheme.d.ts.map +1 -0
  76. package/lib/typescript/src/theming/MaterialTheme.android.d.ts +127 -0
  77. package/lib/typescript/src/theming/MaterialTheme.android.d.ts.map +1 -0
  78. package/lib/typescript/src/theming/MaterialTheme.d.ts +114 -0
  79. package/lib/typescript/src/theming/MaterialTheme.d.ts.map +1 -0
  80. package/lib/typescript/src/useLinking.native.d.ts.map +1 -1
  81. package/package.json +26 -11
  82. package/src/NavigationContainer.tsx +20 -3
  83. package/src/index.tsx +2 -1
  84. package/src/native/MaterialSymbol.android.tsx +12 -10
  85. package/src/native/MaterialSymbolData.tsx +0 -6
  86. package/src/native/MaterialSymbolViewNativeComponent.ts +6 -2
  87. package/src/native/NativeMaterialSymbolModule.ts +3 -3
  88. package/src/native/SFSymbol.ios.tsx +24 -1
  89. package/src/native/SFSymbolViewNativeComponent.ts +15 -1
  90. package/src/native/constants.tsx +11 -0
  91. package/src/native/types.tsx +174 -3
  92. package/src/theming/DarkTheme.tsx +4 -4
  93. package/src/theming/{DefaultTheme.tsx → LightTheme.tsx} +4 -4
  94. package/src/theming/MaterialTheme.android.tsx +30 -0
  95. package/src/theming/MaterialTheme.tsx +19 -0
  96. package/src/useLinking.native.tsx +38 -15
  97. package/android/build/.transforms/586a73aab4c351d3f13dc604ca6964e8/results.bin +0 -1
  98. package/android/build/.transforms/586a73aab4c351d3f13dc604ca6964e8/transformed/classes/classes_dex/classes.dex +0 -0
  99. package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/results.bin +0 -1
  100. package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/facebook/fbreact/specs/NativeMaterialSymbolModuleSpec.dex +0 -0
  101. package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/facebook/react/viewmanagers/ReactNavigationMaterialSymbolViewManagerDelegate.dex +0 -0
  102. package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/facebook/react/viewmanagers/ReactNavigationMaterialSymbolViewManagerInterface.dex +0 -0
  103. package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/facebook/react/viewmanagers/ReactNavigationSFSymbolViewManagerDelegate.dex +0 -0
  104. package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/facebook/react/viewmanagers/ReactNavigationSFSymbolViewManagerInterface.dex +0 -0
  105. package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/reactnavigation/BuildConfig.dex +0 -0
  106. package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/reactnavigation/MaterialSymbolModule$Companion.dex +0 -0
  107. package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/reactnavigation/MaterialSymbolModule$WhenMappings.dex +0 -0
  108. package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/reactnavigation/MaterialSymbolModule$getImageSource$future$1$1$1.dex +0 -0
  109. package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/reactnavigation/MaterialSymbolModule.dex +0 -0
  110. package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/reactnavigation/MaterialSymbolTypeface.dex +0 -0
  111. package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/reactnavigation/MaterialSymbolView.dex +0 -0
  112. package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/reactnavigation/MaterialSymbolViewManager$Companion.dex +0 -0
  113. package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/reactnavigation/MaterialSymbolViewManager.dex +0 -0
  114. package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/reactnavigation/ReactNavigationPackage.dex +0 -0
  115. package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/desugar_graph.bin +0 -0
  116. package/android/build/generated/source/buildConfig/debug/org/reactnavigation/BuildConfig.java +0 -10
  117. package/android/build/generated/source/codegen/java/com/facebook/fbreact/specs/NativeMaterialSymbolModuleSpec.java +0 -38
  118. package/android/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNavigationMaterialSymbolViewManagerDelegate.java +0 -42
  119. package/android/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNavigationMaterialSymbolViewManagerInterface.java +0 -21
  120. package/android/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNavigationSFSymbolViewManagerDelegate.java +0 -39
  121. package/android/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNavigationSFSymbolViewManagerInterface.java +0 -20
  122. package/android/build/generated/source/codegen/jni/CMakeLists.txt +0 -28
  123. package/android/build/generated/source/codegen/jni/ReactNavigationSpec-generated.cpp +0 -32
  124. package/android/build/generated/source/codegen/jni/ReactNavigationSpec.h +0 -31
  125. package/android/build/generated/source/codegen/jni/react/renderer/components/ReactNavigationSpec/ComponentDescriptors.cpp +0 -23
  126. package/android/build/generated/source/codegen/jni/react/renderer/components/ReactNavigationSpec/ComponentDescriptors.h +0 -25
  127. package/android/build/generated/source/codegen/jni/react/renderer/components/ReactNavigationSpec/EventEmitters.cpp +0 -17
  128. package/android/build/generated/source/codegen/jni/react/renderer/components/ReactNavigationSpec/EventEmitters.h +0 -30
  129. package/android/build/generated/source/codegen/jni/react/renderer/components/ReactNavigationSpec/Props.cpp +0 -101
  130. package/android/build/generated/source/codegen/jni/react/renderer/components/ReactNavigationSpec/Props.h +0 -55
  131. package/android/build/generated/source/codegen/jni/react/renderer/components/ReactNavigationSpec/ReactNavigationSpecJSI-generated.cpp +0 -31
  132. package/android/build/generated/source/codegen/jni/react/renderer/components/ReactNavigationSpec/ReactNavigationSpecJSI.h +0 -71
  133. package/android/build/generated/source/codegen/jni/react/renderer/components/ReactNavigationSpec/ShadowNodes.cpp +0 -18
  134. package/android/build/generated/source/codegen/jni/react/renderer/components/ReactNavigationSpec/ShadowNodes.h +0 -43
  135. package/android/build/generated/source/codegen/jni/react/renderer/components/ReactNavigationSpec/States.cpp +0 -16
  136. package/android/build/generated/source/codegen/jni/react/renderer/components/ReactNavigationSpec/States.h +0 -22
  137. package/android/build/generated/source/codegen/schema.json +0 -1
  138. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/AndroidManifest.xml +0 -7
  139. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/output-metadata.json +0 -18
  140. package/android/build/intermediates/aar_metadata/debug/writeDebugAarMetadata/aar-metadata.properties +0 -6
  141. package/android/build/intermediates/annotation_processor_list/debug/javaPreCompileDebug/annotationProcessors.json +0 -1
  142. package/android/build/intermediates/assets/debug/mergeDebugAssets/fonts/MaterialSymbolsRounded.ttf +0 -0
  143. package/android/build/intermediates/assets/debug/mergeDebugAssets/fonts/MaterialSymbolsSharp.ttf +0 -0
  144. package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
  145. package/android/build/intermediates/compile_r_class_jar/debug/generateDebugRFile/R.jar +0 -0
  146. package/android/build/intermediates/compile_symbol_list/debug/generateDebugRFile/R.txt +0 -0
  147. package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +0 -1
  148. package/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +0 -2
  149. package/android/build/intermediates/incremental/mergeDebugAssets/merger.xml +0 -2
  150. package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +0 -2
  151. package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +0 -2
  152. package/android/build/intermediates/java_res/debug/processDebugJavaRes/out/META-INF/react-navigation_native_debug.kotlin_module +0 -0
  153. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/facebook/fbreact/specs/NativeMaterialSymbolModuleSpec.class +0 -0
  154. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/facebook/react/viewmanagers/ReactNavigationMaterialSymbolViewManagerDelegate.class +0 -0
  155. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/facebook/react/viewmanagers/ReactNavigationMaterialSymbolViewManagerInterface.class +0 -0
  156. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/facebook/react/viewmanagers/ReactNavigationSFSymbolViewManagerDelegate.class +0 -0
  157. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/facebook/react/viewmanagers/ReactNavigationSFSymbolViewManagerInterface.class +0 -0
  158. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/reactnavigation/BuildConfig.class +0 -0
  159. package/android/build/intermediates/local_only_symbol_list/debug/parseDebugLocalResources/R-def.txt +0 -2
  160. package/android/build/intermediates/manifest_merge_blame_file/debug/processDebugManifest/manifest-merger-blame-debug-report.txt +0 -7
  161. package/android/build/intermediates/merged_manifest/debug/processDebugManifest/AndroidManifest.xml +0 -7
  162. package/android/build/intermediates/navigation_json/debug/extractDeepLinksDebug/navigation.json +0 -1
  163. package/android/build/intermediates/nested_resources_validation_report/debug/generateDebugResources/nestedResourcesValidationReport.txt +0 -1
  164. package/android/build/intermediates/react-navigation/fonts/MaterialSymbolsOutlined.ttf +0 -0
  165. package/android/build/intermediates/react-navigation/fonts/MaterialSymbolsRounded.ttf +0 -0
  166. package/android/build/intermediates/react-navigation/fonts/MaterialSymbolsSharp.ttf +0 -0
  167. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/META-INF/react-navigation_native_debug.kotlin_module +0 -0
  168. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/facebook/fbreact/specs/NativeMaterialSymbolModuleSpec.class +0 -0
  169. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/facebook/react/viewmanagers/ReactNavigationMaterialSymbolViewManagerDelegate.class +0 -0
  170. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/facebook/react/viewmanagers/ReactNavigationMaterialSymbolViewManagerInterface.class +0 -0
  171. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/facebook/react/viewmanagers/ReactNavigationSFSymbolViewManagerDelegate.class +0 -0
  172. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/facebook/react/viewmanagers/ReactNavigationSFSymbolViewManagerInterface.class +0 -0
  173. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/reactnavigation/BuildConfig.class +0 -0
  174. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/reactnavigation/MaterialSymbolModule$Companion.class +0 -0
  175. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/reactnavigation/MaterialSymbolModule$WhenMappings.class +0 -0
  176. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/reactnavigation/MaterialSymbolModule$getImageSource$future$1$1$1.class +0 -0
  177. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/reactnavigation/MaterialSymbolModule.class +0 -0
  178. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/reactnavigation/MaterialSymbolTypeface.class +0 -0
  179. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/reactnavigation/MaterialSymbolView.class +0 -0
  180. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/reactnavigation/MaterialSymbolViewManager$Companion.class +0 -0
  181. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/reactnavigation/MaterialSymbolViewManager.class +0 -0
  182. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/reactnavigation/ReactNavigationPackage.class +0 -0
  183. package/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar +0 -0
  184. package/android/build/intermediates/symbol_list_with_package_name/debug/generateDebugRFile/package-aware-r.txt +0 -1
  185. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab +0 -0
  186. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream +0 -0
  187. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream.len +0 -0
  188. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.len +0 -0
  189. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
  190. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i +0 -0
  191. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i.len +0 -0
  192. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab +0 -0
  193. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream +0 -0
  194. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream.len +0 -0
  195. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.len +0 -0
  196. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at +0 -0
  197. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i +0 -0
  198. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i.len +0 -0
  199. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
  200. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream +0 -0
  201. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream.len +0 -0
  202. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.len +0 -0
  203. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at +0 -0
  204. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i +0 -0
  205. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i.len +0 -0
  206. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab +0 -0
  207. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab.keystream +0 -0
  208. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab.keystream.len +0 -0
  209. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab.len +0 -0
  210. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab.values.at +0 -0
  211. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab_i +0 -0
  212. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab_i.len +0 -0
  213. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
  214. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
  215. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
  216. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len +0 -0
  217. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at +0 -0
  218. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
  219. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i.len +0 -0
  220. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
  221. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream +0 -0
  222. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream.len +0 -0
  223. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.len +0 -0
  224. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
  225. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i +0 -0
  226. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i.len +0 -0
  227. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
  228. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream +0 -0
  229. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream.len +0 -0
  230. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.len +0 -0
  231. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
  232. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i +0 -0
  233. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i.len +0 -0
  234. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab +0 -0
  235. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream +0 -0
  236. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream.len +0 -0
  237. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.len +0 -0
  238. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at +0 -0
  239. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i +0 -0
  240. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i.len +0 -0
  241. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
  242. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream +0 -0
  243. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream.len +0 -0
  244. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.len +0 -0
  245. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.at +0 -0
  246. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i +0 -0
  247. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i.len +0 -0
  248. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/counters.tab +0 -2
  249. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab +0 -0
  250. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream +0 -0
  251. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream.len +0 -0
  252. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.len +0 -0
  253. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.at +0 -0
  254. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i +0 -0
  255. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i.len +0 -0
  256. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab +0 -0
  257. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream +0 -0
  258. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.len +0 -0
  259. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len +0 -0
  260. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.at +0 -0
  261. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i +0 -0
  262. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i.len +0 -0
  263. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
  264. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
  265. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
  266. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len +0 -0
  267. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
  268. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
  269. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i.len +0 -0
  270. package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
  271. package/android/build/kotlin/compileDebugKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin +0 -0
  272. package/android/build/outputs/logs/manifest-merger-debug-report.txt +0 -16
  273. package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
  274. package/android/build/tmp/kotlin-classes/debug/META-INF/react-navigation_native_debug.kotlin_module +0 -0
  275. package/android/build/tmp/kotlin-classes/debug/org/reactnavigation/MaterialSymbolModule$Companion.class +0 -0
  276. package/android/build/tmp/kotlin-classes/debug/org/reactnavigation/MaterialSymbolModule$WhenMappings.class +0 -0
  277. package/android/build/tmp/kotlin-classes/debug/org/reactnavigation/MaterialSymbolModule$getImageSource$future$1$1$1.class +0 -0
  278. package/android/build/tmp/kotlin-classes/debug/org/reactnavigation/MaterialSymbolModule.class +0 -0
  279. package/android/build/tmp/kotlin-classes/debug/org/reactnavigation/MaterialSymbolTypeface.class +0 -0
  280. package/android/build/tmp/kotlin-classes/debug/org/reactnavigation/MaterialSymbolView.class +0 -0
  281. package/android/build/tmp/kotlin-classes/debug/org/reactnavigation/MaterialSymbolViewManager$Companion.class +0 -0
  282. package/android/build/tmp/kotlin-classes/debug/org/reactnavigation/MaterialSymbolViewManager.class +0 -0
  283. package/android/build/tmp/kotlin-classes/debug/org/reactnavigation/ReactNavigationPackage.class +0 -0
  284. package/android/gradle.properties +0 -5
  285. package/assets/fonts/MaterialSymbolsOutlined.ttf +0 -0
  286. package/lib/module/theming/DefaultTheme.js.map +0 -1
  287. package/lib/typescript/src/theming/DefaultTheme.d.ts.map +0 -1
@@ -1,6 +1,19 @@
1
+ import groovy.json.JsonSlurper
2
+
1
3
  buildscript {
2
- ext.getExtOrDefault = {name ->
3
- return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['ReactNavigation_' + name]
4
+ ext.ReactNavigation = [
5
+ kotlinVersion: "2.0.21",
6
+ minSdkVersion: 24,
7
+ compileSdkVersion: 36,
8
+ targetSdkVersion: 36
9
+ ]
10
+
11
+ ext.getExtOrDefault = { prop ->
12
+ if (rootProject.ext.has(prop)) {
13
+ return rootProject.ext.get(prop)
14
+ }
15
+
16
+ return ReactNavigation[prop]
4
17
  }
5
18
 
6
19
  repositories {
@@ -21,18 +34,14 @@ apply plugin: "kotlin-android"
21
34
 
22
35
  apply plugin: "com.facebook.react"
23
36
 
24
- def getExtOrIntegerDefault(name) {
25
- return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["ReactNavigation_" + name]).toInteger()
26
- }
27
-
28
37
  android {
29
38
  namespace "org.reactnavigation"
30
39
 
31
- compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
40
+ compileSdkVersion getExtOrDefault("compileSdkVersion")
32
41
 
33
42
  defaultConfig {
34
- minSdkVersion getExtOrIntegerDefault("minSdkVersion")
35
- targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
43
+ minSdkVersion getExtOrDefault("minSdkVersion")
44
+ targetSdkVersion getExtOrDefault("targetSdkVersion")
36
45
  }
37
46
 
38
47
  buildTypes {
@@ -51,15 +60,87 @@ android {
51
60
  }
52
61
  }
53
62
 
54
- task copyAssets(type: Copy) {
55
- from "../assets/fonts"
56
- include "*.ttf"
57
- into "${buildDir}/intermediates/react-navigation/fonts"
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
+ }
58
139
  }
59
140
 
60
- android.sourceSets.main.assets.srcDirs += file("${buildDir}/intermediates/react-navigation")
141
+ android.sourceSets.main.assets.srcDirs += layout.buildDirectory.dir("intermediates/react-navigation")
61
142
 
62
- preBuild.dependsOn(copyAssets)
143
+ preBuild.dependsOn(copyMaterialFonts)
63
144
 
64
145
  dependencies {
65
146
  implementation "com.facebook.react:react-android"
@@ -3,6 +3,7 @@ package org.reactnavigation
3
3
  import android.graphics.Bitmap
4
4
  import android.graphics.Canvas
5
5
  import android.graphics.Paint
6
+ import androidx.core.graphics.createBitmap
6
7
  import androidx.core.net.toUri
7
8
  import com.facebook.fbreact.specs.NativeMaterialSymbolModuleSpec
8
9
  import com.facebook.react.bridge.ColorPropConverter
@@ -14,23 +15,24 @@ import kotlinx.coroutines.SupervisorJob
14
15
  import kotlinx.coroutines.launch
15
16
  import java.io.File
16
17
  import java.io.FileOutputStream
17
- import java.util.concurrent.Callable
18
- import java.util.concurrent.ConcurrentHashMap
19
- import java.util.concurrent.Executors
20
- import java.util.concurrent.Future
21
18
  import kotlin.math.roundToInt
22
19
 
23
20
  class MaterialSymbolModule(reactContext: ReactApplicationContext) :
24
21
  NativeMaterialSymbolModuleSpec(reactContext) {
25
22
 
26
23
  companion object {
27
- private val executor = Executors.newCachedThreadPool()
28
- private val futures = ConcurrentHashMap<String, Future<String>>()
24
+ const val NAME = NativeMaterialSymbolModuleSpec.NAME
25
+
29
26
  private val scope = CoroutineScope(Dispatchers.IO + SupervisorJob())
30
27
  }
31
28
 
29
+ private val fontHash: String by lazy {
30
+ reactApplicationContext.assets.open("fonts/MaterialSymbols.hash").bufferedReader().readText()
31
+ .trim()
32
+ }
33
+
32
34
  override fun getImageSource(
33
- name: String, variant: String, size: Double, color: ReadableMap, hash: String
35
+ name: String, variant: String?, weight: Double?, size: Double, color: ReadableMap
34
36
  ): String {
35
37
  val colorValue = color.getDynamic("value").let {
36
38
  when (it.type) {
@@ -46,8 +48,13 @@ class MaterialSymbolModule(reactContext: ReactApplicationContext) :
46
48
  val density = reactApplicationContext.resources.displayMetrics.density
47
49
  val scaledSize = (size * density).roundToInt().coerceAtLeast(1)
48
50
 
51
+ val (resolvedTypeface, typefaceSuffix) = MaterialSymbolTypeface.get(
52
+ reactApplicationContext, variant, weight?.toInt()
53
+ )
54
+
49
55
  val cacheDir = File(
50
- reactApplicationContext.cacheDir, "react_navigation/material_symbols/$variant/$hash"
56
+ reactApplicationContext.cacheDir,
57
+ "react_navigation/material_symbols/$typefaceSuffix/$fontHash"
51
58
  )
52
59
 
53
60
  val cacheKey = "${name.hashCode()}_${scaledSize}_$resolvedColor"
@@ -57,55 +64,37 @@ class MaterialSymbolModule(reactContext: ReactApplicationContext) :
57
64
  return cacheFile.toUri().toString()
58
65
  }
59
66
 
60
- val future = futures.computeIfAbsent(cacheKey) {
61
- executor.submit(
62
- Callable {
63
- try {
64
- scope.launch {
65
- cacheDir.parentFile?.listFiles { it.isDirectory && it.name != hash }
66
- ?.forEach { it.deleteRecursively() }
67
- }
68
-
69
- cacheDir.mkdirs()
70
-
71
- val paint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
72
- typeface = MaterialSymbolTypeface.get(reactApplicationContext, variant)
73
- textSize = scaledSize.toFloat()
74
- textAlign = Paint.Align.CENTER
75
-
76
- this.color = resolvedColor
77
- }
78
-
79
- val fontMetrics = paint.fontMetrics
80
- val bitmap = Bitmap.createBitmap(scaledSize, scaledSize, Bitmap.Config.ARGB_8888)
81
-
82
- try {
83
- val canvas = Canvas(bitmap)
84
- val y =
85
- (scaledSize - (fontMetrics.descent - fontMetrics.ascent)) / 2f - fontMetrics.ascent
86
-
87
- canvas.drawText(name, scaledSize / 2f, y, paint)
88
-
89
- FileOutputStream(cacheFile).use {
90
- bitmap.compress(Bitmap.CompressFormat.PNG, 100, it)
91
- }
92
- } finally {
93
- bitmap.recycle()
94
- }
95
-
96
- return@Callable cacheFile.toUri().toString()
97
- } catch (e: Exception) {
98
- futures.remove(cacheKey)
99
-
100
- throw e
101
- }
102
- })
67
+ scope.launch {
68
+ cacheDir.parentFile?.listFiles { it.isDirectory && it.name != fontHash }
69
+ ?.forEach { it.deleteRecursively() }
70
+ }
71
+
72
+ cacheDir.mkdirs()
73
+
74
+ val paint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
75
+ typeface = resolvedTypeface
76
+ textSize = scaledSize.toFloat()
77
+ textAlign = Paint.Align.CENTER
78
+
79
+ this.color = resolvedColor
103
80
  }
104
81
 
82
+ val fontMetrics = paint.fontMetrics
83
+ val bitmap = createBitmap(scaledSize, scaledSize)
84
+
105
85
  try {
106
- return future.get()
107
- } catch (e: Exception) {
108
- throw (e.cause as? Exception) ?: e
86
+ val canvas = Canvas(bitmap)
87
+ val y = (scaledSize - (fontMetrics.descent - fontMetrics.ascent)) / 2f - fontMetrics.ascent
88
+
89
+ canvas.drawText(name, scaledSize / 2f, y, paint)
90
+
91
+ FileOutputStream(cacheFile).use {
92
+ bitmap.compress(Bitmap.CompressFormat.PNG, 100, it)
93
+ }
94
+ } finally {
95
+ bitmap.recycle()
109
96
  }
97
+
98
+ return cacheFile.toUri().toString()
110
99
  }
111
100
  }
@@ -3,17 +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?): Typeface {
10
- return typefaces.getOrPut(variant ?: "outlined") {
11
- val suffix = when (variant) {
12
+ fun get(context: Context, variant: String?, weight: Int?): MaterialSymbolTypefaceResult {
13
+ val suffix = if (variant != null && weight != null) {
14
+ val resolvedVariant = when (variant) {
12
15
  "rounded" -> "Rounded"
13
16
  "sharp" -> "Sharp"
14
17
  else -> "Outlined"
15
18
  }
16
19
 
20
+ "${resolvedVariant}_$weight"
21
+ } else {
22
+ getDefaultSuffix(context)
23
+ }
24
+
25
+ val typeface = typefaces.getOrPut(suffix) {
17
26
  val path = "fonts/MaterialSymbols${suffix}.ttf"
18
27
 
19
28
  try {
@@ -22,5 +31,47 @@ object MaterialSymbolTypeface {
22
31
  throw RuntimeException("$path not found.", e)
23
32
  }
24
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
+ val outlinedFonts = fonts.filter { it.startsWith("MaterialSymbolsOutlined") }
50
+ val outlinedFont = when {
51
+ outlinedFonts.isEmpty() -> null
52
+ outlinedFonts.size == 1 -> outlinedFonts[0]
53
+ else -> outlinedFonts.firstOrNull {
54
+ it.removePrefix("MaterialSymbols").removeSuffix(".ttf") == "Outlined_400"
55
+ }
56
+ }
57
+
58
+ if (outlinedFont == null) {
59
+ throw RuntimeException(
60
+ "Multiple MaterialSymbols fonts found in assets: ${fonts.joinToString()}. " + "Please specify a variant and weight explicitly."
61
+ )
62
+ }
63
+
64
+ val outlinedSuffix = outlinedFont.removePrefix("MaterialSymbols").removeSuffix(".ttf")
65
+
66
+ defaultSuffix = outlinedSuffix
67
+
68
+ return outlinedSuffix
69
+ }
70
+
71
+ val suffix = fonts[0].removePrefix("MaterialSymbols").removeSuffix(".ttf")
72
+
73
+ defaultSuffix = suffix
74
+
75
+ return suffix
25
76
  }
26
77
  }
@@ -4,13 +4,18 @@ import android.content.Context
4
4
  import android.graphics.Canvas
5
5
  import android.graphics.Paint
6
6
  import android.util.AttributeSet
7
- import android.widget.TextView
8
7
 
9
8
  class MaterialSymbolView @JvmOverloads constructor(
10
9
  context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
11
- ) : TextView(context, attrs, defStyleAttr) {
10
+ ) : androidx.appcompat.widget.AppCompatTextView(context, attrs, defStyleAttr) {
12
11
 
13
12
  private var variant: String? = null
13
+ private var weight: Int? = null
14
+
15
+ init {
16
+ setColor(null)
17
+ updateTypeface()
18
+ }
14
19
 
15
20
  override fun onDraw(canvas: Canvas) {
16
21
  val text = text?.toString() ?: return
@@ -25,23 +30,63 @@ class MaterialSymbolView @JvmOverloads constructor(
25
30
  canvas.drawText(text, x, y, paint)
26
31
  }
27
32
 
28
- fun setName(name: String) {
33
+ fun setName(name: String?) {
29
34
  text = name
35
+
36
+ invalidate()
30
37
  }
31
38
 
32
- fun setVariant(variant: String) {
39
+ fun setVariant(variant: String?) {
33
40
  if (this.variant == variant) {
34
41
  return
35
42
  }
36
43
 
37
44
  this.variant = variant
38
45
 
39
- setTypeface(MaterialSymbolTypeface.get(context, variant))
46
+ updateTypeface()
47
+ }
48
+
49
+ fun setWeight(weight: Int?) {
50
+ if (this.weight == weight) {
51
+ return
52
+ }
53
+
54
+ this.weight = weight
55
+
56
+ updateTypeface()
57
+ }
58
+
59
+ private fun updateTypeface() {
60
+ setTypeface(
61
+ MaterialSymbolTypeface.get(
62
+ context,
63
+ variant?.ifEmpty { null },
64
+ weight.takeIf { it != 0 }).typeface
65
+ )
66
+
40
67
  invalidate()
41
68
  }
42
69
 
43
- fun setColor(color: Int) {
44
- setTextColor(color)
70
+ fun setColor(color: Int?) {
71
+ if (color == null) {
72
+ val typedValue = android.util.TypedValue()
73
+
74
+ context.theme.resolveAttribute(
75
+ android.R.attr.colorForeground, typedValue, true
76
+ )
77
+
78
+ val resolvedColor = if (typedValue.resourceId != 0) {
79
+ context.getColor(typedValue.resourceId)
80
+ } else {
81
+ typedValue.data
82
+ }
83
+
84
+ setTextColor(resolvedColor)
85
+ } else {
86
+ setTextColor(color)
87
+ }
88
+
89
+ invalidate()
45
90
  }
46
91
 
47
92
  fun setSize(size: Float) {
@@ -4,9 +4,11 @@ import com.facebook.react.module.annotations.ReactModule
4
4
  import com.facebook.react.uimanager.SimpleViewManager
5
5
  import com.facebook.react.uimanager.ThemedReactContext
6
6
  import com.facebook.react.uimanager.annotations.ReactProp
7
+ import com.facebook.react.viewmanagers.ReactNavigationMaterialSymbolViewManagerInterface
7
8
 
8
9
  @ReactModule(name = MaterialSymbolViewManager.NAME)
9
- class MaterialSymbolViewManager : SimpleViewManager<MaterialSymbolView>() {
10
+ class MaterialSymbolViewManager : SimpleViewManager<MaterialSymbolView>(),
11
+ ReactNavigationMaterialSymbolViewManagerInterface<MaterialSymbolView> {
10
12
 
11
13
  override fun getName(): String {
12
14
  return NAME
@@ -17,25 +19,30 @@ class MaterialSymbolViewManager : SimpleViewManager<MaterialSymbolView>() {
17
19
  }
18
20
 
19
21
  @ReactProp(name = "name")
20
- fun setName(view: MaterialSymbolView, name: String) {
22
+ override fun setName(view: MaterialSymbolView, name: String?) {
21
23
  view.setName(name)
22
24
  }
23
25
 
24
26
  @ReactProp(name = "variant")
25
- fun setVariant(view: MaterialSymbolView, variant: String) {
27
+ override fun setVariant(view: MaterialSymbolView, variant: String?) {
26
28
  view.setVariant(variant)
27
29
  }
28
30
 
29
- @ReactProp(name = "color", customType = "Color", defaultInt = android.graphics.Color.BLACK)
30
- fun setColor(view: MaterialSymbolView, color: Int) {
31
- view.setColor(color)
31
+ @ReactProp(name = "weight")
32
+ override fun setWeight(view: MaterialSymbolView, weight: Int?) {
33
+ view.setWeight(weight)
32
34
  }
33
35
 
34
36
  @ReactProp(name = "size")
35
- fun setSize(view: MaterialSymbolView, size: Float) {
37
+ override fun setSize(view: MaterialSymbolView, size: Float) {
36
38
  view.setSize(size)
37
39
  }
38
40
 
41
+ @ReactProp(name = "color", customType = "Color")
42
+ override fun setColor(view: MaterialSymbolView, color: Int?) {
43
+ view.setColor(color)
44
+ }
45
+
39
46
  companion object {
40
47
  const val NAME = "ReactNavigationMaterialSymbolView"
41
48
  }
@@ -1,6 +1,5 @@
1
1
  package org.reactnavigation
2
2
 
3
- import com.facebook.fbreact.specs.NativeMaterialSymbolModuleSpec
4
3
  import com.facebook.react.BaseReactPackage
5
4
  import com.facebook.react.bridge.NativeModule
6
5
  import com.facebook.react.bridge.ReactApplicationContext
@@ -15,23 +14,21 @@ class ReactNavigationPackage : BaseReactPackage() {
15
14
 
16
15
  override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
17
16
  return when (name) {
18
- NativeMaterialSymbolModuleSpec.NAME -> MaterialSymbolModule(reactContext)
17
+ MaterialSymbolModule.NAME -> MaterialSymbolModule(reactContext)
19
18
  else -> null
20
19
  }
21
20
  }
22
21
 
23
- override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
24
- return ReactModuleInfoProvider {
25
- mapOf(
26
- NativeMaterialSymbolModuleSpec.NAME to ReactModuleInfo(
27
- NativeMaterialSymbolModuleSpec.NAME,
28
- MaterialSymbolModule::class.java.name,
29
- false, // canOverrideExistingModule
30
- false, // needsEagerInit
31
- false, // isCxxModule
32
- true // isTurboModule
33
- )
22
+ override fun getReactModuleInfoProvider() = ReactModuleInfoProvider {
23
+ mapOf(
24
+ MaterialSymbolModule.NAME to ReactModuleInfo(
25
+ name = MaterialSymbolModule.NAME,
26
+ className = MaterialSymbolModule.NAME,
27
+ canOverrideExistingModule = false,
28
+ needsEagerInit = false,
29
+ isCxxModule = false,
30
+ isTurboModule = true
34
31
  )
35
- }
32
+ )
36
33
  }
37
34
  }
@@ -45,6 +45,27 @@ static ReactNavigationSFSymbolViewImplProps *convertProps(const Props::Shared &p
45
45
  swiftProps.name = RCTNSStringFromString(viewProps.name);
46
46
  swiftProps.size = viewProps.size;
47
47
  swiftProps.color = RCTUIColorFromSharedColor(viewProps.color);
48
+ swiftProps.weight = viewProps.weight;
49
+ swiftProps.scale = RCTNSStringFromString(viewProps.scale);
50
+ swiftProps.mode = RCTNSStringFromString(viewProps.mode);
51
+ swiftProps.animation = RCTNSStringFromString(viewProps.animation);
52
+ swiftProps.animationRepeating = viewProps.animationRepeating;
53
+ swiftProps.animationRepeatCount = viewProps.animationRepeatCount;
54
+ swiftProps.animationSpeed = viewProps.animationSpeed;
55
+ swiftProps.animationWholeSymbol = viewProps.animationWholeSymbol;
56
+ swiftProps.animationDirection = RCTNSStringFromString(viewProps.animationDirection);
57
+ swiftProps.animationReversing = viewProps.animationReversing;
58
+ swiftProps.animationCumulative = viewProps.animationCumulative;
59
+
60
+ if (viewProps.colorPrimary) {
61
+ swiftProps.colorPrimary = RCTUIColorFromSharedColor(viewProps.colorPrimary);
62
+ }
63
+ if (viewProps.colorSecondary) {
64
+ swiftProps.colorSecondary = RCTUIColorFromSharedColor(viewProps.colorSecondary);
65
+ }
66
+ if (viewProps.colorTertiary) {
67
+ swiftProps.colorTertiary = RCTUIColorFromSharedColor(viewProps.colorTertiary);
68
+ }
48
69
 
49
70
  return swiftProps;
50
71
  }