@onekeyfe/react-native-pager-view 3.0.139 → 3.0.141

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.
@@ -14,6 +14,7 @@ import android.widget.FrameLayout
14
14
  import android.widget.HorizontalScrollView
15
15
  import android.widget.TextView
16
16
  import androidx.core.graphics.ColorUtils
17
+ import com.facebook.react.common.assets.ReactFontManager
17
18
  import org.json.JSONArray
18
19
  import org.json.JSONObject
19
20
  import kotlin.math.ceil
@@ -46,6 +47,18 @@ private fun parseHeaderItems(value: String?): List<CollapsiblePagerNativeHeaderI
46
47
  }.getOrDefault(emptyList())
47
48
  }
48
49
 
50
+ private const val DEFAULT_HEADER_FONT_FAMILY = "sans-serif-medium"
51
+
52
+ // Resolve fonts the way React Native Text does. ReactFontManager reads bundled
53
+ // assets/fonts/<family>.ttf and registered custom fonts; Typeface.create only
54
+ // knows system families and silently falls back to the default font.
55
+ private fun resolveHeaderTypeface(context: Context, fontFamily: String?): Typeface =
56
+ ReactFontManager.getInstance().getTypeface(
57
+ fontFamily?.takeIf(String::isNotEmpty) ?: DEFAULT_HEADER_FONT_FAMILY,
58
+ Typeface.NORMAL,
59
+ context.assets,
60
+ )
61
+
49
62
  private class CollapsiblePagerHorizontalItemsView(
50
63
  context: Context,
51
64
  private val showsProgressIndicator: Boolean,
@@ -177,7 +190,7 @@ private class CollapsiblePagerHorizontalItemsView(
177
190
  }
178
191
 
179
192
  private fun applyTypeface() {
180
- val typeface = Typeface.create(fontFamily ?: "sans-serif-medium", Typeface.NORMAL)
193
+ val typeface = resolveHeaderTypeface(context, fontFamily)
181
194
  buttons.forEach { button ->
182
195
  button.typeface = typeface
183
196
  button.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize.toFloat())
@@ -452,7 +465,7 @@ internal class CollapsiblePagerNativeSubHeaderView(context: Context) : ViewGroup
452
465
  selectedBackgroundColor,
453
466
  activeTextColor,
454
467
  )
455
- val typeface = Typeface.create(fontFamily ?: "sans-serif-medium", Typeface.NORMAL)
468
+ val typeface = resolveHeaderTypeface(context, fontFamily)
456
469
  listOf(leading, middle, trailing).forEach { label ->
457
470
  label.typeface = typeface
458
471
  label.setTextSize(TypedValue.COMPLEX_UNIT_SP, columnFontSize.toFloat())
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-pager-view",
3
- "version": "3.0.139",
3
+ "version": "3.0.141",
4
4
  "description": "React Native wrapper for Android and iOS ViewPager",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/module/index.js",
@@ -66,7 +66,7 @@
66
66
  "typescript": "^5.9.2"
67
67
  },
68
68
  "peerDependencies": {
69
- "@onekeyfe/react-native-native-logger": "3.0.139",
69
+ "@onekeyfe/react-native-native-logger": "3.0.141",
70
70
  "react": "*",
71
71
  "react-native": "*"
72
72
  },