craft-native 0.0.394 → 0.0.396

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.
@@ -1,6 +1,7 @@
1
1
  package {{PACKAGE_NAME}}
2
2
 
3
3
  import android.content.Context
4
+ import android.view.MotionEvent
4
5
  import android.view.View
5
6
  import android.view.ViewGroup
6
7
  import android.widget.FrameLayout
@@ -18,6 +19,9 @@ internal typealias CraftNativeRenderItem = (node: JSONObject, identity: String,
18
19
 
19
20
  /** A stable-key RecyclerView host for stx native FlatList nodes. */
20
21
  internal class CraftNativeFlatList(context: Context) : RecyclerView(context) {
22
+ override fun dispatchTouchEvent(event: MotionEvent): Boolean =
23
+ CraftNativePointers.dispatch(this, event) { super.dispatchTouchEvent(it) }
24
+
21
25
  private data class Item(
22
26
  val identity: String,
23
27
  val node: JSONObject,
@@ -96,6 +100,12 @@ internal class CraftNativeFlatList(context: Context) : RecyclerView(context) {
96
100
  }
97
101
 
98
102
  private var renderItem: CraftNativeRenderItem? = null
103
+ /**
104
+ * The `fontFamily` the rows inherit from the list's ancestors. Rows are
105
+ * rebound only when their own node changes, so the screen redraws them
106
+ * when this changes (`reconcileFlatList` in MainActivity).
107
+ */
108
+ var inheritedFontFamily: String? = null
99
109
  private var recycleItem: ((String) -> Unit)? = null
100
110
  private var removeItem: ((String) -> Unit)? = null
101
111
  private var endReached: (() -> Unit)? = null
@@ -221,11 +231,13 @@ internal class CraftNativeFlatList(context: Context) : RecyclerView(context) {
221
231
  .map { it.second }
222
232
 
223
233
  override fun onInterceptTouchEvent(event: android.view.MotionEvent): Boolean {
234
+ if (event.actionMasked != MotionEvent.ACTION_CANCEL && !CraftNativePointers.ownsTouch(this)) return false
224
235
  if (!scrollEnabled) return false
225
236
  return super.onInterceptTouchEvent(event)
226
237
  }
227
238
 
228
239
  override fun onTouchEvent(event: android.view.MotionEvent): Boolean {
240
+ if (event.actionMasked != MotionEvent.ACTION_CANCEL && !CraftNativePointers.ownsTouch(this)) return false
229
241
  if (!scrollEnabled) return false
230
242
  return super.onTouchEvent(event)
231
243
  }
@@ -298,6 +310,7 @@ internal class CraftNativeFlatList(context: Context) : RecyclerView(context) {
298
310
  }
299
311
  var dismissed = false
300
312
  setOnTouchListener { _, event ->
313
+ if (!CraftNativePointers.ownsTouch(this) && event.actionMasked != MotionEvent.ACTION_CANCEL) return@setOnTouchListener false
301
314
  when (event.actionMasked) {
302
315
  android.view.MotionEvent.ACTION_DOWN -> dismissed = false
303
316
  android.view.MotionEvent.ACTION_MOVE -> if (!dismissed) {
@@ -1,5 +1,8 @@
1
1
  /** The Android host for the small, host-neutral native trail map contract. */
2
2
  private class CraftNativeMapView(context: Context) : FrameLayout(context), OnMapReadyCallback {
3
+ override fun dispatchTouchEvent(event: MotionEvent): Boolean =
4
+ CraftNativePointers.dispatch(this, event) { super.dispatchTouchEvent(it) }
5
+
3
6
  private data class PolygonValue(val points: List<LatLng>, val fillColor: Int, val strokeColor: Int, val strokeWidth: Float)
4
7
  private val mapView = MapView(context)
5
8
  private val scaleView = LinearLayout(context).apply {
@@ -1,5 +1,8 @@
1
1
  /** A key-free native Android map. STX geometry never enters a WebView. */
2
2
  internal class CraftNativeMapView(context: Context) : FrameLayout(context), OnMapReadyCallback {
3
+ override fun dispatchTouchEvent(event: MotionEvent): Boolean =
4
+ CraftNativePointers.dispatch(this, event) { super.dispatchTouchEvent(it) }
5
+
3
6
  private val mapView: MapView
4
7
  private var map: MapLibreMap? = null
5
8
  private var destroyed = false
@@ -1,11 +1,20 @@
1
1
  package {{PACKAGE_NAME}}
2
2
 
3
3
  import android.content.Context
4
+ import android.view.MotionEvent
4
5
  import org.json.JSONObject
5
6
  import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
6
7
 
7
8
  /** Swipe-to-refresh host for a native FlatList. */
8
9
  internal class CraftNativeRefreshableFlatList(context: Context) : SwipeRefreshLayout(context) {
10
+ override fun dispatchTouchEvent(event: MotionEvent): Boolean =
11
+ CraftNativePointers.dispatch(this, event) { super.dispatchTouchEvent(it) }
12
+
13
+ override fun onInterceptTouchEvent(event: MotionEvent): Boolean =
14
+ CraftNativePointers.ownsTouch(this) && super.onInterceptTouchEvent(event)
15
+ override fun onTouchEvent(event: MotionEvent): Boolean =
16
+ (event.actionMasked == MotionEvent.ACTION_CANCEL || CraftNativePointers.ownsTouch(this)) && super.onTouchEvent(event)
17
+
9
18
  val list = CraftNativeFlatList(context)
10
19
  private var refreshHandler: (() -> Unit)? = null
11
20