@lugg/maps 1.0.0-beta.10 → 1.0.0-beta.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.
@@ -4,6 +4,7 @@ import android.content.Context
4
4
  import android.graphics.Bitmap
5
5
  import android.graphics.Canvas
6
6
  import android.view.View
7
+ import android.view.accessibility.AccessibilityEvent
7
8
  import androidx.core.graphics.createBitmap
8
9
  import androidx.core.view.isNotEmpty
9
10
  import com.facebook.react.uimanager.PointerEvents
@@ -53,6 +54,7 @@ class LuggCalloutView(context: Context) : ReactViewGroup(context) {
53
54
 
54
55
  // no-op: avoid accessibility traversal of detached callout children
55
56
  override fun addChildrenForAccessibility(outChildren: ArrayList<View>) {}
57
+ override fun dispatchPopulateAccessibilityEvent(event: AccessibilityEvent): Boolean = false
56
58
 
57
59
  fun createContentBitmap(): Bitmap? {
58
60
  var maxWidth = 0
@@ -3,6 +3,7 @@ package com.luggmaps
3
3
  import android.content.Context
4
4
  import android.graphics.Canvas
5
5
  import android.view.View
6
+ import android.view.accessibility.AccessibilityEvent
6
7
  import androidx.core.graphics.createBitmap
7
8
  import androidx.core.view.isNotEmpty
8
9
  import com.facebook.react.views.view.ReactViewGroup
@@ -220,6 +221,7 @@ class LuggMarkerView(context: Context) : ReactViewGroup(context) {
220
221
 
221
222
  // no-op: avoid accessibility traversal of detached marker children
222
223
  override fun addChildrenForAccessibility(outChildren: ArrayList<View>) {}
224
+ override fun dispatchPopulateAccessibilityEvent(event: AccessibilityEvent): Boolean = false
223
225
 
224
226
  override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
225
227
  super.onSizeChanged(w, h, oldw, oldh)
@@ -21,12 +21,19 @@ class PolylineAnimator {
21
21
  var polyline: Polyline? = null
22
22
  var coordinates: List<LatLng> = emptyList()
23
23
  set(value) {
24
+ if (field === value) return
24
25
  field = value
26
+ dirty = true
25
27
  if (animated && animator != null) {
26
28
  computeCumulativeDistances()
27
29
  }
28
30
  }
29
31
  var strokeColors: List<Int> = listOf(Color.BLACK)
32
+ set(value) {
33
+ if (field === value) return
34
+ field = value
35
+ dirty = true
36
+ }
30
37
  var strokeWidth: Float = 1f
31
38
  var animatedOptions: AnimatedOptions = AnimatedOptions()
32
39
  set(value) {
@@ -53,6 +60,7 @@ class PolylineAnimator {
53
60
  private var animationProgress: Float = 0f
54
61
  private var cumulativeDistances: FloatArray = floatArrayOf()
55
62
  private var totalLength: Float = 0f
63
+ private var dirty: Boolean = true
56
64
 
57
65
  // Reusable collections to avoid per-frame allocations
58
66
  private val reusablePoints = ArrayList<LatLng>()
@@ -73,14 +81,16 @@ class PolylineAnimator {
73
81
 
74
82
  fun update() {
75
83
  if (animated) return
84
+ if (!dirty) return
76
85
 
77
86
  val poly = polyline ?: return
78
87
  if (coordinates.size < 2) return
79
88
 
89
+ dirty = false
80
90
  poly.points = coordinates
81
91
 
82
92
  if (strokeColors.size > 1) {
83
- poly.setSpans(createGradientSpans())
93
+ applyGradientSpans(poly)
84
94
  } else {
85
95
  poly.color = strokeColors.firstOrNull() ?: Color.BLACK
86
96
  }
@@ -256,15 +266,18 @@ class PolylineAnimator {
256
266
  }
257
267
  }
258
268
 
259
- private fun createGradientSpans(): List<StyleSpan> {
269
+ private fun applyGradientSpans(poly: Polyline) {
260
270
  val segmentCount = coordinates.size - 1
261
271
  val spanCount = min(segmentCount, MAX_GRADIENT_SPANS)
262
272
  val segmentsPerSpan = segmentCount.toDouble() / spanCount
263
- return (0 until spanCount).map { i ->
273
+
274
+ reusableSpans.clear()
275
+ for (i in 0 until spanCount) {
264
276
  val position = (i + 0.5f) / spanCount
265
277
  val color = colorAtGradientPosition(position)
266
- StyleSpan(StrokeStyle.colorBuilder(color).build(), segmentsPerSpan)
278
+ reusableSpans.add(StyleSpan(StrokeStyle.colorBuilder(color).build(), segmentsPerSpan))
267
279
  }
280
+ poly.setSpans(reusableSpans)
268
281
  }
269
282
 
270
283
  private fun colorAtGradientPosition(position: Float): Int {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lugg/maps",
3
- "version": "1.0.0-beta.10",
3
+ "version": "1.0.0-beta.11",
4
4
  "description": "Universal maps for React Native.",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",