@react-navigation/native 8.0.0-alpha.3 → 8.0.0-alpha.4

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 (151) hide show
  1. package/android/build/.transforms/586a73aab4c351d3f13dc604ca6964e8/transformed/classes/classes_dex/classes.dex +0 -0
  2. package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/facebook/fbreact/specs/NativeMaterialSymbolModuleSpec.dex +0 -0
  3. package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/facebook/react/viewmanagers/ReactNavigationMaterialSymbolViewManagerDelegate.dex +0 -0
  4. package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/reactnavigation/MaterialSymbolModule$getImageSource$1.dex +0 -0
  5. package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/reactnavigation/MaterialSymbolModule.dex +0 -0
  6. package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/reactnavigation/MaterialSymbolTypeface.dex +0 -0
  7. package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/reactnavigation/MaterialSymbolTypefaceResult.dex +0 -0
  8. package/android/build/.transforms/fb9c4b42fa16b6541a5819cb4bf06272/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/reactnavigation/MaterialSymbolView.dex +0 -0
  9. package/android/build/generated/source/codegen/java/com/facebook/fbreact/specs/NativeMaterialSymbolModuleSpec.java +2 -1
  10. package/android/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNavigationMaterialSymbolViewManagerDelegate.java +1 -1
  11. package/android/build/generated/source/codegen/jni/ReactNavigationSpec-generated.cpp +2 -2
  12. package/android/build/generated/source/codegen/jni/react/renderer/components/ReactNavigationSpec/Props.cpp +1 -1
  13. package/android/build/generated/source/codegen/jni/react/renderer/components/ReactNavigationSpec/Props.h +7 -2
  14. package/android/build/generated/source/codegen/jni/react/renderer/components/ReactNavigationSpec/ReactNavigationSpecJSI-generated.cpp +4 -5
  15. package/android/build/generated/source/codegen/jni/react/renderer/components/ReactNavigationSpec/ReactNavigationSpecJSI.h +5 -5
  16. package/android/build/generated/source/codegen/schema.json +1 -1
  17. package/android/build/intermediates/assets/debug/mergeDebugAssets/fonts/MaterialSymbols.hash +1 -0
  18. package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
  19. package/android/build/intermediates/incremental/mergeDebugAssets/merger.xml +1 -1
  20. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/facebook/fbreact/specs/NativeMaterialSymbolModuleSpec.class +0 -0
  21. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/facebook/react/viewmanagers/ReactNavigationMaterialSymbolViewManagerDelegate.class +0 -0
  22. package/android/build/intermediates/react-navigation/fonts/MaterialSymbols.hash +1 -0
  23. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/facebook/fbreact/specs/NativeMaterialSymbolModuleSpec.class +0 -0
  24. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/facebook/react/viewmanagers/ReactNavigationMaterialSymbolViewManagerDelegate.class +0 -0
  25. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/reactnavigation/MaterialSymbolModule$getImageSource$1.class +0 -0
  26. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/reactnavigation/MaterialSymbolModule.class +0 -0
  27. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/reactnavigation/MaterialSymbolTypeface.class +0 -0
  28. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/reactnavigation/MaterialSymbolTypefaceResult.class +0 -0
  29. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/reactnavigation/MaterialSymbolView.class +0 -0
  30. package/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar +0 -0
  31. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab +0 -0
  32. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
  33. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab +0 -0
  34. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream +0 -0
  35. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream.len +0 -0
  36. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.len +0 -0
  37. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at +0 -0
  38. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i +0 -0
  39. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
  40. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream +0 -0
  41. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream.len +0 -0
  42. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.len +0 -0
  43. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at +0 -0
  44. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i +0 -0
  45. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab +0 -0
  46. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab.values.at +0 -0
  47. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
  48. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
  49. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
  50. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len +0 -0
  51. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at +0 -0
  52. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
  53. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
  54. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream +0 -0
  55. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream.len +0 -0
  56. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.len +0 -0
  57. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
  58. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i +0 -0
  59. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
  60. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
  61. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab +0 -0
  62. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at +0 -0
  63. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
  64. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.at +0 -0
  65. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/counters.tab +1 -1
  66. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab +0 -0
  67. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.at +0 -0
  68. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab +0 -0
  69. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream +0 -0
  70. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.len +0 -0
  71. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len +0 -0
  72. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.at +0 -0
  73. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i +0 -0
  74. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
  75. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
  76. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
  77. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len +0 -0
  78. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
  79. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
  80. package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
  81. package/android/build/kotlin/compileDebugKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin +0 -0
  82. package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
  83. package/android/build/tmp/kotlin-classes/debug/org/reactnavigation/MaterialSymbolModule$getImageSource$1.class +0 -0
  84. package/android/build/tmp/kotlin-classes/debug/org/reactnavigation/MaterialSymbolModule.class +0 -0
  85. package/android/build/tmp/kotlin-classes/debug/org/reactnavigation/MaterialSymbolTypeface.class +0 -0
  86. package/android/build/tmp/kotlin-classes/debug/org/reactnavigation/MaterialSymbolTypefaceResult.class +0 -0
  87. package/android/build/tmp/kotlin-classes/debug/org/reactnavigation/MaterialSymbolView.class +0 -0
  88. package/android/build.gradle +80 -6
  89. package/android/src/main/java/org/reactnavigation/MaterialSymbolModule.kt +14 -4
  90. package/android/src/main/java/org/reactnavigation/MaterialSymbolTypeface.kt +40 -10
  91. package/android/src/main/java/org/reactnavigation/MaterialSymbolView.kt +13 -5
  92. package/assets/fonts/MaterialSymbolsOutlined_100.ttf +0 -0
  93. package/assets/fonts/MaterialSymbolsOutlined_200.ttf +0 -0
  94. package/assets/fonts/MaterialSymbolsOutlined_300.ttf +0 -0
  95. package/assets/fonts/MaterialSymbolsOutlined_500.ttf +0 -0
  96. package/assets/fonts/MaterialSymbolsOutlined_600.ttf +0 -0
  97. package/assets/fonts/MaterialSymbolsOutlined_700.ttf +0 -0
  98. package/assets/fonts/MaterialSymbolsRounded.codepoints +4102 -0
  99. package/assets/fonts/MaterialSymbolsRounded_100.ttf +0 -0
  100. package/assets/fonts/MaterialSymbolsRounded_200.ttf +0 -0
  101. package/assets/fonts/MaterialSymbolsRounded_300.ttf +0 -0
  102. package/assets/fonts/MaterialSymbolsRounded_400.ttf +0 -0
  103. package/assets/fonts/MaterialSymbolsRounded_500.ttf +0 -0
  104. package/assets/fonts/MaterialSymbolsRounded_600.ttf +0 -0
  105. package/assets/fonts/MaterialSymbolsRounded_700.ttf +0 -0
  106. package/assets/fonts/MaterialSymbolsSharp.codepoints +4102 -0
  107. package/assets/fonts/MaterialSymbolsSharp_100.ttf +0 -0
  108. package/assets/fonts/MaterialSymbolsSharp_200.ttf +0 -0
  109. package/assets/fonts/MaterialSymbolsSharp_300.ttf +0 -0
  110. package/assets/fonts/MaterialSymbolsSharp_400.ttf +0 -0
  111. package/assets/fonts/MaterialSymbolsSharp_500.ttf +0 -0
  112. package/assets/fonts/MaterialSymbolsSharp_600.ttf +0 -0
  113. package/assets/fonts/MaterialSymbolsSharp_700.ttf +0 -0
  114. package/ios/ReactNavigationSFSymbolView.mm +21 -0
  115. package/ios/ReactNavigationSFSymbolView.swift +257 -7
  116. package/lib/module/native/MaterialSymbol.android.js +11 -13
  117. package/lib/module/native/MaterialSymbol.android.js.map +1 -1
  118. package/lib/module/native/MaterialSymbolData.js +0 -7
  119. package/lib/module/native/MaterialSymbolData.js.map +1 -1
  120. package/lib/module/native/MaterialSymbolViewNativeComponent.ts +3 -3
  121. package/lib/module/native/NativeMaterialSymbolModule.js.map +1 -1
  122. package/lib/module/native/SFSymbol.ios.js +24 -1
  123. package/lib/module/native/SFSymbol.ios.js.map +1 -1
  124. package/lib/module/native/SFSymbolViewNativeComponent.ts +15 -1
  125. package/lib/module/native/constants.js +14 -0
  126. package/lib/module/native/constants.js.map +1 -0
  127. package/lib/typescript/src/native/MaterialSymbol.android.d.ts +2 -2
  128. package/lib/typescript/src/native/MaterialSymbol.android.d.ts.map +1 -1
  129. package/lib/typescript/src/native/MaterialSymbolData.d.ts +0 -3
  130. package/lib/typescript/src/native/MaterialSymbolData.d.ts.map +1 -1
  131. package/lib/typescript/src/native/MaterialSymbolViewNativeComponent.d.ts +2 -2
  132. package/lib/typescript/src/native/MaterialSymbolViewNativeComponent.d.ts.map +1 -1
  133. package/lib/typescript/src/native/NativeMaterialSymbolModule.d.ts +1 -1
  134. package/lib/typescript/src/native/NativeMaterialSymbolModule.d.ts.map +1 -1
  135. package/lib/typescript/src/native/SFSymbol.ios.d.ts +1 -1
  136. package/lib/typescript/src/native/SFSymbol.ios.d.ts.map +1 -1
  137. package/lib/typescript/src/native/SFSymbolViewNativeComponent.d.ts +15 -1
  138. package/lib/typescript/src/native/SFSymbolViewNativeComponent.d.ts.map +1 -1
  139. package/lib/typescript/src/native/constants.d.ts +12 -0
  140. package/lib/typescript/src/native/constants.d.ts.map +1 -0
  141. package/lib/typescript/src/native/types.d.ts +144 -0
  142. package/lib/typescript/src/native/types.d.ts.map +1 -1
  143. package/package.json +2 -2
  144. package/src/native/MaterialSymbol.android.tsx +12 -15
  145. package/src/native/MaterialSymbolData.tsx +0 -4
  146. package/src/native/MaterialSymbolViewNativeComponent.ts +3 -3
  147. package/src/native/NativeMaterialSymbolModule.ts +3 -4
  148. package/src/native/SFSymbol.ios.tsx +24 -1
  149. package/src/native/SFSymbolViewNativeComponent.ts +15 -1
  150. package/src/native/constants.tsx +11 -0
  151. package/src/native/types.tsx +179 -0
@@ -19,6 +19,7 @@ import com.facebook.react.bridge.ReactMethod;
19
19
  import com.facebook.react.bridge.ReadableMap;
20
20
  import com.facebook.react.turbomodule.core.interfaces.TurboModule;
21
21
  import javax.annotation.Nonnull;
22
+ import javax.annotation.Nullable;
22
23
 
23
24
  public abstract class NativeMaterialSymbolModuleSpec extends ReactContextBaseJavaModule implements TurboModule {
24
25
  public static final String NAME = "ReactNavigationMaterialSymbolModule";
@@ -34,5 +35,5 @@ public abstract class NativeMaterialSymbolModuleSpec extends ReactContextBaseJav
34
35
 
35
36
  @ReactMethod(isBlockingSynchronousMethod = true)
36
37
  @DoNotStrip
37
- public abstract String getImageSource(String name, String variant, double size, double weight, ReadableMap color, String hash);
38
+ public abstract String getImageSource(String name, @Nullable String variant, @Nullable Double weight, double size, ReadableMap color);
38
39
  }
@@ -30,7 +30,7 @@ public class ReactNavigationMaterialSymbolViewManagerDelegate<T extends View, U
30
30
  mViewManager.setVariant(view, value == null ? null : (String) value);
31
31
  break;
32
32
  case "weight":
33
- mViewManager.setWeight(view, value == null ? 400 : ((Double) value).intValue());
33
+ mViewManager.setWeight(view, value == null ? 0 : ((Double) value).intValue());
34
34
  break;
35
35
  case "size":
36
36
  mViewManager.setSize(view, value == null ? Float.NaN : ((Double) value).floatValue());
@@ -14,12 +14,12 @@ namespace facebook::react {
14
14
 
15
15
  static facebook::jsi::Value __hostFunction_NativeMaterialSymbolModuleSpecJSI_getImageSource(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
16
16
  static jmethodID cachedMethodId = nullptr;
17
- return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, StringKind, "getImageSource", "(Ljava/lang/String;Ljava/lang/String;DDLcom/facebook/react/bridge/ReadableMap;Ljava/lang/String;)Ljava/lang/String;", args, count, cachedMethodId);
17
+ return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, StringKind, "getImageSource", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Double;DLcom/facebook/react/bridge/ReadableMap;)Ljava/lang/String;", args, count, cachedMethodId);
18
18
  }
19
19
 
20
20
  NativeMaterialSymbolModuleSpecJSI::NativeMaterialSymbolModuleSpecJSI(const JavaTurboModule::InitParams &params)
21
21
  : JavaTurboModule(params) {
22
- methodMap_["getImageSource"] = MethodMetadata {6, __hostFunction_NativeMaterialSymbolModuleSpecJSI_getImageSource};
22
+ methodMap_["getImageSource"] = MethodMetadata {5, __hostFunction_NativeMaterialSymbolModuleSpecJSI_getImageSource};
23
23
  }
24
24
 
25
25
  std::shared_ptr<TurboModule> ReactNavigationSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params) {
@@ -21,7 +21,7 @@ ReactNavigationMaterialSymbolViewProps::ReactNavigationMaterialSymbolViewProps(
21
21
 
22
22
  name(convertRawProp(context, rawProps, "name", sourceProps.name, {})),
23
23
  variant(convertRawProp(context, rawProps, "variant", sourceProps.variant, {})),
24
- weight(convertRawProp(context, rawProps, "weight", sourceProps.weight, {ReactNavigationMaterialSymbolViewWeight::Weight400})),
24
+ weight(convertRawProp(context, rawProps, "weight", sourceProps.weight, {ReactNavigationMaterialSymbolViewWeight::Weight0})),
25
25
  size(convertRawProp(context, rawProps, "size", sourceProps.size, {0.0})),
26
26
  color(convertRawProp(context, rawProps, "color", sourceProps.color, {})) {}
27
27
 
@@ -15,12 +15,15 @@
15
15
 
16
16
  namespace facebook::react {
17
17
 
18
- enum class ReactNavigationMaterialSymbolViewWeight { Weight100 = 100, Weight200 = 200, Weight300 = 300, Weight400 = 400, Weight500 = 500, Weight600 = 600, Weight700 = 700 };
18
+ enum class ReactNavigationMaterialSymbolViewWeight { Weight0 = 0, Weight100 = 100, Weight200 = 200, Weight300 = 300, Weight400 = 400, Weight500 = 500, Weight600 = 600, Weight700 = 700 };
19
19
 
20
20
  static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ReactNavigationMaterialSymbolViewWeight &result) {
21
21
  assert(value.hasType<int>());
22
22
  auto integerValue = (int)value;
23
23
  switch (integerValue) {
24
+ case 0:
25
+ result = ReactNavigationMaterialSymbolViewWeight::Weight0;
26
+ return;
24
27
  case 100:
25
28
  result = ReactNavigationMaterialSymbolViewWeight::Weight100;
26
29
  return;
@@ -48,6 +51,7 @@ static inline void fromRawValue(const PropsParserContext& context, const RawValu
48
51
 
49
52
  static inline std::string toString(const ReactNavigationMaterialSymbolViewWeight &value) {
50
53
  switch (value) {
54
+ case ReactNavigationMaterialSymbolViewWeight::Weight0: return "0";
51
55
  case ReactNavigationMaterialSymbolViewWeight::Weight100: return "100";
52
56
  case ReactNavigationMaterialSymbolViewWeight::Weight200: return "200";
53
57
  case ReactNavigationMaterialSymbolViewWeight::Weight300: return "300";
@@ -61,6 +65,7 @@ static inline std::string toString(const ReactNavigationMaterialSymbolViewWeight
61
65
  #ifdef RN_SERIALIZABLE_STATE
62
66
  static inline folly::dynamic toDynamic(const ReactNavigationMaterialSymbolViewWeight &value) {
63
67
  switch (value) {
68
+ case ReactNavigationMaterialSymbolViewWeight::Weight0: return 0;
64
69
  case ReactNavigationMaterialSymbolViewWeight::Weight100: return 100;
65
70
  case ReactNavigationMaterialSymbolViewWeight::Weight200: return 200;
66
71
  case ReactNavigationMaterialSymbolViewWeight::Weight300: return 300;
@@ -81,7 +86,7 @@ class ReactNavigationMaterialSymbolViewProps final : public ViewProps {
81
86
 
82
87
  std::string name{};
83
88
  std::string variant{};
84
- ReactNavigationMaterialSymbolViewWeight weight{ReactNavigationMaterialSymbolViewWeight::Weight400};
89
+ ReactNavigationMaterialSymbolViewWeight weight{ReactNavigationMaterialSymbolViewWeight::Weight0};
85
90
  Float size{0.0};
86
91
  SharedColor color{};
87
92
 
@@ -15,17 +15,16 @@ static jsi::Value __hostFunction_NativeMaterialSymbolModuleCxxSpecJSI_getImageSo
15
15
  return static_cast<NativeMaterialSymbolModuleCxxSpecJSI *>(&turboModule)->getImageSource(
16
16
  rt,
17
17
  count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
18
- count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asString(rt),
19
- count <= 2 ? throw jsi::JSError(rt, "Expected argument in position 2 to be passed") : args[2].asNumber(),
18
+ count <= 1 || args[1].isNull() || args[1].isUndefined() ? std::nullopt : std::make_optional(args[1].asString(rt)),
19
+ count <= 2 || args[2].isNull() || args[2].isUndefined() ? std::nullopt : std::make_optional(args[2].asNumber()),
20
20
  count <= 3 ? throw jsi::JSError(rt, "Expected argument in position 3 to be passed") : args[3].asNumber(),
21
- count <= 4 ? throw jsi::JSError(rt, "Expected argument in position 4 to be passed") : args[4].asObject(rt),
22
- count <= 5 ? throw jsi::JSError(rt, "Expected argument in position 5 to be passed") : args[5].asString(rt)
21
+ count <= 4 ? throw jsi::JSError(rt, "Expected argument in position 4 to be passed") : args[4].asObject(rt)
23
22
  );
24
23
  }
25
24
 
26
25
  NativeMaterialSymbolModuleCxxSpecJSI::NativeMaterialSymbolModuleCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
27
26
  : TurboModule("ReactNavigationMaterialSymbolModule", jsInvoker) {
28
- methodMap_["getImageSource"] = MethodMetadata {6, __hostFunction_NativeMaterialSymbolModuleCxxSpecJSI_getImageSource};
27
+ methodMap_["getImageSource"] = MethodMetadata {5, __hostFunction_NativeMaterialSymbolModuleCxxSpecJSI_getImageSource};
29
28
  }
30
29
 
31
30
 
@@ -20,7 +20,7 @@ protected:
20
20
  NativeMaterialSymbolModuleCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
21
21
 
22
22
  public:
23
- virtual jsi::String getImageSource(jsi::Runtime &rt, jsi::String name, jsi::String variant, double size, double weight, jsi::Object color, jsi::String hash) = 0;
23
+ virtual jsi::String getImageSource(jsi::Runtime &rt, jsi::String name, std::optional<jsi::String> variant, std::optional<double> weight, double size, jsi::Object color) = 0;
24
24
 
25
25
  };
26
26
 
@@ -51,13 +51,13 @@ private:
51
51
 
52
52
  }
53
53
 
54
- jsi::String getImageSource(jsi::Runtime &rt, jsi::String name, jsi::String variant, double size, double weight, jsi::Object color, jsi::String hash) override {
54
+ jsi::String getImageSource(jsi::Runtime &rt, jsi::String name, std::optional<jsi::String> variant, std::optional<double> weight, double size, jsi::Object color) override {
55
55
  static_assert(
56
- bridging::getParameterCount(&T::getImageSource) == 7,
57
- "Expected getImageSource(...) to have 7 parameters");
56
+ bridging::getParameterCount(&T::getImageSource) == 6,
57
+ "Expected getImageSource(...) to have 6 parameters");
58
58
 
59
59
  return bridging::callFromJs<jsi::String>(
60
- rt, &T::getImageSource, jsInvoker_, instance_, std::move(name), std::move(variant), std::move(size), std::move(weight), std::move(color), std::move(hash));
60
+ rt, &T::getImageSource, jsInvoker_, instance_, std::move(name), std::move(variant), std::move(weight), std::move(size), std::move(color));
61
61
  }
62
62
 
63
63
  private:
@@ -1 +1 @@
1
- {"libraryName":"","modules":{"ReactNavigationMaterialSymbolView":{"type":"Component","components":{"ReactNavigationMaterialSymbolView":{"extendsProps":[{"type":"ReactNativeBuiltInType","knownTypeName":"ReactNativeCoreViewProps"}],"events":[],"props":[{"name":"name","optional":false,"typeAnnotation":{"type":"StringTypeAnnotation","default":null}},{"name":"variant","optional":false,"typeAnnotation":{"type":"StringTypeAnnotation","default":null}},{"name":"weight","optional":true,"typeAnnotation":{"type":"Int32EnumTypeAnnotation","default":400,"options":[100,200,300,400,500,600,700]}},{"name":"size","optional":false,"typeAnnotation":{"type":"FloatTypeAnnotation","default":0}},{"name":"color","optional":false,"typeAnnotation":{"type":"ReservedPropTypeAnnotation","name":"ColorPrimitive"}}],"commands":[]}}},"NativeMaterialSymbolModule":{"type":"NativeModule","aliasMap":{},"enumMap":{},"spec":{"eventEmitters":[],"methods":[{"name":"getImageSource","optional":false,"typeAnnotation":{"type":"FunctionTypeAnnotation","returnTypeAnnotation":{"type":"StringTypeAnnotation"},"params":[{"name":"name","optional":false,"typeAnnotation":{"type":"StringTypeAnnotation"}},{"name":"variant","optional":false,"typeAnnotation":{"type":"StringTypeAnnotation"}},{"name":"size","optional":false,"typeAnnotation":{"type":"NumberTypeAnnotation"}},{"name":"weight","optional":false,"typeAnnotation":{"type":"UnionTypeAnnotation","memberType":"NumberTypeAnnotation"}},{"name":"color","optional":false,"typeAnnotation":{"type":"GenericObjectTypeAnnotation"}},{"name":"hash","optional":false,"typeAnnotation":{"type":"StringTypeAnnotation"}}]}}]},"moduleName":"ReactNavigationMaterialSymbolModule"},"ReactNavigationSFSymbolView":{"type":"Component","components":{"ReactNavigationSFSymbolView":{"extendsProps":[{"type":"ReactNativeBuiltInType","knownTypeName":"ReactNativeCoreViewProps"}],"events":[],"props":[{"name":"name","optional":false,"typeAnnotation":{"type":"StringTypeAnnotation","default":null}},{"name":"size","optional":false,"typeAnnotation":{"type":"FloatTypeAnnotation","default":0}},{"name":"color","optional":false,"typeAnnotation":{"type":"ReservedPropTypeAnnotation","name":"ColorPrimitive"}}],"commands":[]}}}}}
1
+ {"libraryName":"","modules":{"ReactNavigationMaterialSymbolView":{"type":"Component","components":{"ReactNavigationMaterialSymbolView":{"extendsProps":[{"type":"ReactNativeBuiltInType","knownTypeName":"ReactNativeCoreViewProps"}],"events":[],"props":[{"name":"name","optional":false,"typeAnnotation":{"type":"StringTypeAnnotation","default":null}},{"name":"variant","optional":true,"typeAnnotation":{"type":"StringTypeAnnotation","default":null}},{"name":"weight","optional":true,"typeAnnotation":{"type":"Int32EnumTypeAnnotation","default":0,"options":[0,100,200,300,400,500,600,700]}},{"name":"size","optional":false,"typeAnnotation":{"type":"FloatTypeAnnotation","default":0}},{"name":"color","optional":false,"typeAnnotation":{"type":"ReservedPropTypeAnnotation","name":"ColorPrimitive"}}],"commands":[]}}},"NativeMaterialSymbolModule":{"type":"NativeModule","aliasMap":{},"enumMap":{},"spec":{"eventEmitters":[],"methods":[{"name":"getImageSource","optional":false,"typeAnnotation":{"type":"FunctionTypeAnnotation","returnTypeAnnotation":{"type":"StringTypeAnnotation"},"params":[{"name":"name","optional":false,"typeAnnotation":{"type":"StringTypeAnnotation"}},{"name":"variant","optional":false,"typeAnnotation":{"type":"NullableTypeAnnotation","typeAnnotation":{"type":"StringTypeAnnotation"}}},{"name":"weight","optional":false,"typeAnnotation":{"type":"NullableTypeAnnotation","typeAnnotation":{"type":"UnionTypeAnnotation","memberType":"NumberTypeAnnotation"}}},{"name":"size","optional":false,"typeAnnotation":{"type":"NumberTypeAnnotation"}},{"name":"color","optional":false,"typeAnnotation":{"type":"GenericObjectTypeAnnotation"}}]}}]},"moduleName":"ReactNavigationMaterialSymbolModule"},"ReactNavigationSFSymbolView":{"type":"Component","components":{"ReactNavigationSFSymbolView":{"extendsProps":[{"type":"ReactNativeBuiltInType","knownTypeName":"ReactNativeCoreViewProps"}],"events":[],"props":[{"name":"name","optional":false,"typeAnnotation":{"type":"StringTypeAnnotation","default":null}},{"name":"size","optional":false,"typeAnnotation":{"type":"FloatTypeAnnotation","default":0}},{"name":"color","optional":false,"typeAnnotation":{"type":"ReservedPropTypeAnnotation","name":"ColorPrimitive"}}],"commands":[]}}}}}
@@ -1,2 +1,2 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
- <merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/satya/Developer/Projects/react-navigation/packages/native/android/src/main/assets"/><source path="/Users/satya/Developer/Projects/react-navigation/packages/native/android/build/intermediates/react-navigation"><file name="fonts/MaterialSymbolsOutlined_400.ttf" path="/Users/satya/Developer/Projects/react-navigation/packages/native/android/build/intermediates/react-navigation/fonts/MaterialSymbolsOutlined_400.ttf"/></source></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/satya/Developer/Projects/react-navigation/packages/native/android/src/debug/assets"/></dataSet><dataSet config="generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/satya/Developer/Projects/react-navigation/packages/native/android/build/intermediates/shader_assets/debug/compileDebugShaders/out"/></dataSet></merger>
2
+ <merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/satya/Developer/Projects/react-navigation/packages/native/android/src/main/assets"/><source path="/Users/satya/Developer/Projects/react-navigation/packages/native/android/build/intermediates/react-navigation"><file name="fonts/MaterialSymbols.hash" path="/Users/satya/Developer/Projects/react-navigation/packages/native/android/build/intermediates/react-navigation/fonts/MaterialSymbols.hash"/><file name="fonts/MaterialSymbolsOutlined_400.ttf" path="/Users/satya/Developer/Projects/react-navigation/packages/native/android/build/intermediates/react-navigation/fonts/MaterialSymbolsOutlined_400.ttf"/></source></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/satya/Developer/Projects/react-navigation/packages/native/android/src/debug/assets"/></dataSet><dataSet config="generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/satya/Developer/Projects/react-navigation/packages/native/android/build/intermediates/shader_assets/debug/compileDebugShaders/out"/></dataSet></merger>
@@ -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
- task copyAssets(type: Copy) {
62
- from "../assets/fonts"
63
- include "*.ttf"
64
- 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
+ }
65
139
  }
66
140
 
67
- android.sourceSets.main.assets.srcDirs += file("${buildDir}/intermediates/react-navigation")
141
+ android.sourceSets.main.assets.srcDirs += layout.buildDirectory.dir("intermediates/react-navigation")
68
142
 
69
- preBuild.dependsOn(copyAssets)
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, size: Double, weight: Double, color: ReadableMap, hash: 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, "react_navigation/material_symbols/$variant-$weight/$hash"
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 != hash }
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 = MaterialSymbolTypeface.get(reactApplicationContext, variant, weight.toInt())
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?): Typeface {
10
- val resolvedVariant = when (variant) {
11
- "rounded" -> "Rounded"
12
- "sharp" -> "Sharp"
13
- else -> "Outlined"
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
- val suffix = "${resolvedVariant}_$resolvedWeight"
20
+ "${resolvedVariant}_$weight"
21
+ } else {
22
+ getDefaultSuffix(context)
23
+ }
19
24
 
20
- return typefaces.getOrPut(suffix) {
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
  }