@craft-native/ios 0.0.174 → 0.0.175
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/README.md +4 -0
- package/package.json +1 -1
- package/templates/CraftNativeScreen.swift +18 -1
package/README.md
CHANGED
|
@@ -117,6 +117,10 @@ ordinary native children while preserving the shared flex layout contract.
|
|
|
117
117
|
`KeyboardAvoidingView` also responds to the native keyboard with `padding`,
|
|
118
118
|
`position`, or `height` behavior.
|
|
119
119
|
|
|
120
|
+
Native screens also expose the iOS-only `craft.badge` capability. `craft.badge.set(count)`
|
|
121
|
+
and `craft.badge.clear()` update the app icon without requesting notification
|
|
122
|
+
authorization or requiring local notifications to be enabled.
|
|
123
|
+
|
|
120
124
|
Keyboard frame changes update the native controller's additional safe area, so
|
|
121
125
|
focused inputs and responsive `onLayout` measurements move with the keyboard.
|
|
122
126
|
|
package/package.json
CHANGED
|
@@ -431,6 +431,7 @@ private final class CraftNativeMapView: MKMapView, MKMapViewDelegate {
|
|
|
431
431
|
private var annotationsByID: [String: MKPointAnnotation] = [:]
|
|
432
432
|
private var overlaysByID: [String: MKPolyline] = [:]
|
|
433
433
|
private var overlayColors: [ObjectIdentifier: UIColor] = [:]
|
|
434
|
+
private var overlayWidths: [ObjectIdentifier: CGFloat] = [:]
|
|
434
435
|
private(set) var markerHandlers: [String: String] = [:]
|
|
435
436
|
var onMarkerTap: ((String) -> Void)?
|
|
436
437
|
|
|
@@ -453,6 +454,10 @@ private final class CraftNativeMapView: MKMapView, MKMapViewDelegate {
|
|
|
453
454
|
isZoomEnabled = props["zoomEnabled"] as? Bool ?? true
|
|
454
455
|
isRotateEnabled = props["rotateEnabled"] as? Bool ?? false
|
|
455
456
|
mapType = Self.mapType(props["mapType"] as? String)
|
|
457
|
+
// Showing the user dot must not trigger a permission prompt from a
|
|
458
|
+
// renderer pass. The app's existing location capability owns that
|
|
459
|
+
// prompt; a map only opts in after authorization is already granted.
|
|
460
|
+
showsUserLocation = props["showsUserLocation"] as? Bool == true && Self.locationPermissionGranted()
|
|
456
461
|
|
|
457
462
|
var nextMarkers: [String: (coordinate: CLLocationCoordinate2D, title: String?)] = [:]
|
|
458
463
|
var nextHandlers: [String: String] = [:]
|
|
@@ -497,10 +502,12 @@ private final class CraftNativeMapView: MKMapView, MKMapViewDelegate {
|
|
|
497
502
|
removeOverlays(Array(overlaysByID.values))
|
|
498
503
|
overlaysByID.removeAll(keepingCapacity: true)
|
|
499
504
|
overlayColors.removeAll(keepingCapacity: true)
|
|
505
|
+
overlayWidths.removeAll(keepingCapacity: true)
|
|
500
506
|
for (id, value) in nextPolylines {
|
|
501
507
|
let overlay = MKPolyline(coordinates: value.coordinates, count: value.coordinates.count)
|
|
502
508
|
overlaysByID[id] = overlay
|
|
503
509
|
overlayColors[ObjectIdentifier(overlay)] = value.color
|
|
510
|
+
overlayWidths[ObjectIdentifier(overlay)] = value.width
|
|
504
511
|
addOverlay(overlay)
|
|
505
512
|
}
|
|
506
513
|
|
|
@@ -542,7 +549,7 @@ private final class CraftNativeMapView: MKMapView, MKMapViewDelegate {
|
|
|
542
549
|
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
|
|
543
550
|
let renderer = MKPolylineRenderer(overlay: overlay)
|
|
544
551
|
renderer.strokeColor = overlayColors[ObjectIdentifier(overlay)] ?? .systemBlue
|
|
545
|
-
renderer.lineWidth = 3
|
|
552
|
+
renderer.lineWidth = overlayWidths[ObjectIdentifier(overlay)] ?? 3
|
|
546
553
|
return renderer
|
|
547
554
|
}
|
|
548
555
|
|
|
@@ -585,6 +592,16 @@ private final class CraftNativeMapView: MKMapView, MKMapViewDelegate {
|
|
|
585
592
|
default: return .standard
|
|
586
593
|
}
|
|
587
594
|
}
|
|
595
|
+
|
|
596
|
+
private static func locationPermissionGranted() -> Bool {
|
|
597
|
+
let status: CLAuthorizationStatus
|
|
598
|
+
if #available(iOS 14.0, *) {
|
|
599
|
+
status = CLLocationManager().authorizationStatus
|
|
600
|
+
} else {
|
|
601
|
+
status = CLLocationManager.authorizationStatus()
|
|
602
|
+
}
|
|
603
|
+
return status == .authorizedAlways || status == .authorizedWhenInUse
|
|
604
|
+
}
|
|
588
605
|
}
|
|
589
606
|
|
|
590
607
|
/// A WebView-free host for the first stx native vertical slice. The bundled
|