From e5e1fa1e4efa7e66e004c4cd0759617df9fbe986 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Sch=C3=B6nig?= Date: Thu, 26 Oct 2023 13:15:53 +1100 Subject: [PATCH 1/2] Disable polyline selection on trip overview card (#312) Disable polyline selection on trip overview card, just keep it on mode-by-mode card --- Sources/TripKitUI/cards/TKUIMapManager.swift | 10 ++++++++++ Sources/TripKitUI/cards/TKUITripModeByModeCard.swift | 2 ++ Sources/TripKitUI/cards/TKUITripOverviewCard.swift | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/Sources/TripKitUI/cards/TKUIMapManager.swift b/Sources/TripKitUI/cards/TKUIMapManager.swift index f6334d9df..70e8b6fc4 100644 --- a/Sources/TripKitUI/cards/TKUIMapManager.swift +++ b/Sources/TripKitUI/cards/TKUIMapManager.swift @@ -119,6 +119,15 @@ open class TKUIMapManager: TGMapManager { /// Cache of renderers, used to update styling when selection changes private var renderers: [WeakRenderers] = [] + /// Whether user interaction for selecting annotation is enabled, defaults to `true`. + open var annotationSelectionEnabled: Bool = true { + didSet { + if !annotationSelectionEnabled { + selectionIdentifier = nil + } + } + } + /// The identifier for what should be drawn as selected on the map public var selectionIdentifier: String? { didSet { @@ -372,6 +381,7 @@ extension TKUIMapManager { private func updateSelectionForTapping(_ view: MKAnnotationView) { guard + annotationSelectionEnabled, let selectable = view.annotation as? TKUISelectableOnMap, let identifier = selectable.selectionIdentifier else { return } diff --git a/Sources/TripKitUI/cards/TKUITripModeByModeCard.swift b/Sources/TripKitUI/cards/TKUITripModeByModeCard.swift index f983a8fbe..e3377017a 100644 --- a/Sources/TripKitUI/cards/TKUITripModeByModeCard.swift +++ b/Sources/TripKitUI/cards/TKUITripModeByModeCard.swift @@ -188,6 +188,8 @@ public class TKUITripModeByModeCard: TGPageCard { public override func didAppear(animated: Bool) { super.didAppear(animated: animated) + + tripMapManager.annotationSelectionEnabled = true TKUIEventCallback.handler(.cardAppeared(self)) if let controller = self.controller { diff --git a/Sources/TripKitUI/cards/TKUITripOverviewCard.swift b/Sources/TripKitUI/cards/TKUITripOverviewCard.swift index 326a28b27..4e98970a4 100644 --- a/Sources/TripKitUI/cards/TKUITripOverviewCard.swift +++ b/Sources/TripKitUI/cards/TKUITripOverviewCard.swift @@ -222,6 +222,11 @@ public class TKUITripOverviewCard: TKUITableCard { tripMapManager?.deselectSegment(animated: animated) } + // Annotation selection on the trip map manager is used by the mode-by-mode + // card, but not the overview card; as it doesn't do anything useful, and + // you can't undo it. + tripMapManager?.annotationSelectionEnabled = false + TKUIEventCallback.handler(.cardAppeared(self)) } From 1f41ebf1010d51fbb289407a0038b09a8a278598 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Sch=C3=B6nig?= Date: Thu, 26 Oct 2023 13:22:47 +1100 Subject: [PATCH 2/2] Show missing stop name in trip overview card on stops along the way (#313) --- Sources/TripKitUI/helper/TKUIMapManagerHelper.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sources/TripKitUI/helper/TKUIMapManagerHelper.swift b/Sources/TripKitUI/helper/TKUIMapManagerHelper.swift index 75c2d6020..0349c5a9f 100644 --- a/Sources/TripKitUI/helper/TKUIMapManagerHelper.swift +++ b/Sources/TripKitUI/helper/TKUIMapManagerHelper.swift @@ -80,6 +80,7 @@ class TKUIMapManagerHelper: NSObject { points.append(TKUICircleAnnotation( coordinate: visit.coordinate, title: visit.title, + subtitle: visit.subtitle, circleColor: service.color ?? .tkAppTintColor, isTravelled: segment.uses(visit), asLarge: true, @@ -187,9 +188,10 @@ class TKUIMapManagerHelper: NSObject { } fileprivate class TKUICircleAnnotation: NSObject, TKUICircleDisplayable, TKUISelectableOnMap { - internal init(coordinate: CLLocationCoordinate2D, title: String? = nil, circleColor: UIColor, isTravelled: Bool, asLarge: Bool, selectionIdentifier: String?, selectionCondition: TKUISelectionCondition) { + internal init(coordinate: CLLocationCoordinate2D, title: String? = nil, subtitle: String? = nil, circleColor: UIColor, isTravelled: Bool, asLarge: Bool, selectionIdentifier: String?, selectionCondition: TKUISelectionCondition) { self.coordinate = coordinate self.title = title + self.subtitle = subtitle self.circleColor = circleColor self.isTravelled = isTravelled self.asLarge = asLarge @@ -204,6 +206,7 @@ fileprivate class TKUICircleAnnotation: NSObject, TKUICircleDisplayable, TKUISel var coordinate: CLLocationCoordinate2D var title: String? + var subtitle: String? // MARK: TKUICircleDisplayable