@onekeyfe/react-native-pager-view 3.0.120 → 3.0.121

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.
@@ -760,9 +760,10 @@ class CollapsiblePagerHost(context: Context) : NestedScrollableHost(context), Ne
760
760
 
761
761
  private fun finishHeaderGesture(event: MotionEvent) {
762
762
  val owner = headerGestureOwner.name.lowercase()
763
- if (nativeGestureStarted) {
763
+ if (nativeGestureStarted || nestedNativeGestureStarted) {
764
764
  NativeGestureUtil.notifyNativeGestureEnded(this, event)
765
765
  nativeGestureStarted = false
766
+ nestedNativeGestureStarted = false
766
767
  }
767
768
  log(
768
769
  "gesture-end action=${event.actionMasked} owner=$owner region=$headerTouchRegion " +
@@ -791,6 +792,7 @@ class CollapsiblePagerHost(context: Context) : NestedScrollableHost(context), Ne
791
792
  forwardedRecycler = null
792
793
  pressCancelled = false
793
794
  nativeGestureStarted = false
795
+ nestedNativeGestureStarted = false
794
796
  headerTouchRegion = headerRegionAt(event.y) ?: "none"
795
797
  headerTouchActive = headerTouchRegion != "none"
796
798
  if (!headerTouchActive) return super.dispatchTouchEvent(event)
@@ -979,6 +981,7 @@ class CollapsiblePagerHost(context: Context) : NestedScrollableHost(context), Ne
979
981
  forwardedRecycler = null
980
982
  pressCancelled = false
981
983
  nativeGestureStarted = false
984
+ nestedNativeGestureStarted = false
982
985
  viewTreeObserver.removeOnPreDrawListener(pageContentLayoutListener)
983
986
  detachRecyclerObserver()
984
987
  for (recycler in originalRecyclerPadding.keys.toList()) {
@@ -53,6 +53,9 @@ private class CollapsiblePagerHorizontalItemsView(
53
53
  private val density = resources.displayMetrics.density
54
54
  private val content = FrameLayout(context)
55
55
  private val indicator = View(context)
56
+ private val indicatorBackground = GradientDrawable().apply {
57
+ shape = GradientDrawable.RECTANGLE
58
+ }
56
59
  private val buttons = ArrayList<TextView>()
57
60
  private val itemFrames = ArrayList<IntArray>()
58
61
  private var items: List<CollapsiblePagerNativeHeaderItem> = emptyList()
@@ -80,7 +83,8 @@ private class CollapsiblePagerHorizontalItemsView(
80
83
  isFillViewport = true
81
84
  overScrollMode = OVER_SCROLL_NEVER
82
85
  clipToPadding = false
83
- content.addView(indicator)
86
+ indicator.background = indicatorBackground
87
+ content.addView(indicator, FrameLayout.LayoutParams(0, 0))
84
88
  addView(
85
89
  content,
86
90
  LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT),
@@ -141,6 +145,7 @@ private class CollapsiblePagerHorizontalItemsView(
141
145
  if (showsProgressIndicator) {
142
146
  indicatorHeightPx = max(0, dp(indicatorHeight))
143
147
  indicatorBottomPx = max(0, dp(indicatorBottom))
148
+ indicatorBackground.cornerRadius = indicatorHeightPx / 2f
144
149
  }
145
150
  applyTypeface()
146
151
  requestLayout()
@@ -159,7 +164,7 @@ private class CollapsiblePagerHorizontalItemsView(
159
164
  this.inactiveTextColor = inactiveTextColor
160
165
  this.selectedBackgroundColor = selectedBackgroundColor
161
166
  this.indicatorColor = indicatorColor
162
- indicator.setBackgroundColor(indicatorColor)
167
+ indicatorBackground.setColor(indicatorColor)
163
168
  updatePresentation()
164
169
  }
165
170
 
@@ -216,7 +221,6 @@ private class CollapsiblePagerHorizontalItemsView(
216
221
  MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY),
217
222
  )
218
223
  setMeasuredDimension(width, height)
219
- updatePresentation()
220
224
  }
221
225
 
222
226
  override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
@@ -247,16 +251,14 @@ private class CollapsiblePagerHorizontalItemsView(
247
251
  val to = itemFrames[upper]
248
252
  val indicatorX = (from[2] + (to[2] - from[2]) * fraction).roundToInt()
249
253
  val indicatorWidth = (from[3] + (to[3] - from[3]) * fraction).roundToInt()
250
- indicator.layoutParams = FrameLayout.LayoutParams(indicatorWidth, indicatorHeightPx).apply {
251
- leftMargin = indicatorX
252
- topMargin = max(0, measuredHeight - indicatorBottomPx - indicatorHeightPx)
253
- }
254
+ val indicatorTop = max(0, measuredHeight - indicatorBottomPx - indicatorHeightPx)
255
+ indicator.layout(
256
+ indicatorX,
257
+ indicatorTop,
258
+ indicatorX + indicatorWidth,
259
+ indicatorTop + indicatorHeightPx,
260
+ )
254
261
  indicator.visibility = if (indicatorHeightPx > 0) VISIBLE else GONE
255
- indicator.background = GradientDrawable().apply {
256
- shape = GradientDrawable.RECTANGLE
257
- setColor(indicatorColor)
258
- cornerRadius = indicatorHeightPx / 2f
259
- }
260
262
  selectedIndex = clamped.roundToInt()
261
263
  buttons.forEachIndexed { index, button ->
262
264
  val emphasis = 1f - min(1f, kotlin.math.abs(clamped - index))
@@ -32,7 +32,7 @@ open class NestedScrollableHost : FrameLayout {
32
32
  private var touchSlop = 0
33
33
  private var initialX = 0f
34
34
  private var initialY = 0f
35
- private var nativeGestureStarted: Boolean = false
35
+ protected var nestedNativeGestureStarted: Boolean = false
36
36
  private val parentViewPager: ViewPager2?
37
37
  get() {
38
38
  var v: View? = parent as? View
@@ -110,7 +110,7 @@ open class NestedScrollableHost : FrameLayout {
110
110
 
111
111
  if (scaledDx > touchSlop || scaledDy > touchSlop) {
112
112
  NativeGestureUtil.notifyNativeGestureStarted(this, e)
113
- nativeGestureStarted = true
113
+ nestedNativeGestureStarted = true
114
114
 
115
115
  if (orientation == null) return
116
116
  if (isVpHorizontal == (scaledDy > scaledDx)) {
@@ -132,9 +132,9 @@ open class NestedScrollableHost : FrameLayout {
132
132
 
133
133
  override fun onTouchEvent(e: MotionEvent): Boolean {
134
134
  if (e.actionMasked == MotionEvent.ACTION_UP) {
135
- if (nativeGestureStarted) {
135
+ if (nestedNativeGestureStarted) {
136
136
  NativeGestureUtil.notifyNativeGestureEnded(this, e)
137
- nativeGestureStarted = false
137
+ nestedNativeGestureStarted = false
138
138
  }
139
139
  }
140
140
  return super.onTouchEvent(e)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-pager-view",
3
- "version": "3.0.120",
3
+ "version": "3.0.121",
4
4
  "description": "React Native wrapper for Android and iOS ViewPager",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/module/index.js",
@@ -67,7 +67,7 @@
67
67
  "typescript": "^5.9.2"
68
68
  },
69
69
  "peerDependencies": {
70
- "@onekeyfe/react-native-native-logger": "3.0.120",
70
+ "@onekeyfe/react-native-native-logger": "3.0.121",
71
71
  "react": "*",
72
72
  "react-native": "*"
73
73
  },