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.
- package/dist/android/templates/CraftNativeFlatList.kt.template +13 -0
- package/dist/android/templates/CraftNativeMapGoogle.kt.template +3 -0
- package/dist/android/templates/CraftNativeMapLibre.kt.template +3 -0
- package/dist/android/templates/CraftNativeRefreshableFlatList.kt.template +9 -0
- package/dist/android/templates/MainActivityNative.kt.template +380 -25
- package/dist/cli.js +1 -1
- package/dist/components/index.d.ts +16 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/ios/templates/CraftNativeFlatList.swift +8 -0
- package/dist/ios/templates/CraftNativeMutation.swift +27 -2
- package/dist/ios/templates/CraftNativeScreen.swift +332 -51
- package/dist/macos/templates/CraftNativeMutation.swift +27 -2
- package/package.json +1 -1
|
@@ -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
|
|