Closed fbernutz closed 2 years ago
There are two patches which help adding a FriendAnnotation. But this should be cleaned up and be fixed, because it's not working correctly.
FriendAnnotation
The Friends Feature is hidden behind a Feature Toggle. To use this Feature, go to Feature.swift and change this:
Feature.swift
private var currentState: [Feature: Bool] = [ .friends: true ]
diffs.zip
What should we do with the friends feature? Should we give it another try to implement it on both platforms?
I'm going to close it since friends feature is not in sight
There are two patches which help adding a
FriendAnnotation
. But this should be cleaned up and be fixed, because it's not working correctly.The Friends Feature is hidden behind a Feature Toggle. To use this Feature, go to
Feature.swift
and change this:patch 1
``` diff --git a/CriticalMass/BikeAnnotationController.swift b/CriticalMass/BikeAnnotationController.swift index 1abfe70..b5435d3 100644 --- a/CriticalMass/BikeAnnotationController.swift +++ b/CriticalMass/BikeAnnotationController.swift @@ -29,6 +29,13 @@ class BikeAnnotationController: AnnotationControllerpatch 2
``` diff --git a/CriticalMass/MapViewController.swift b/CriticalMass/MapViewController.swift index ee459f5..66d375f 100644 --- a/CriticalMass/MapViewController.swift +++ b/CriticalMass/MapViewController.swift @@ -196,15 +196,42 @@ extension MapViewController: MKMapViewDelegate { // MARK: MKMapViewDelegate func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? { - guard annotation is MKUserLocation == false else { + guard let userAnnotation = annotation as? IdentifiableAnnnotation else { + debugPrint("⚠️ Not a UserAnnotation.") return nil } + var view: MKAnnotationView + switch userAnnotation.type { + case .friend: + if #available(iOS 11.0, *) { + if let dequedView = mapView.dequeueReusableAnnotationView(withIdentifier: FriendAnnotationView.reuseIdentifier, for: userAnnotation) as? FriendAnnotationView { + dequedView.annotation = userAnnotation + view = dequedView + } else { + view = FriendAnnotationView(annotation: userAnnotation, + reuseIdentifier: FriendAnnotationView.reuseIdentifier) + } + } else { + view = FriendAnnotationView(annotation: userAnnotation, + reuseIdentifier: FriendAnnotationView.reuseIdentifier) + } - guard let matchingController = annotationController.first(where: { type(of: annotation) == $0.annotationType }) else { - return nil + (view as? FriendAnnotationView)?.friend = userAnnotation.friend + case .user: + if #available(iOS 11.0, *) { + if let dequedView = mapView.dequeueReusableAnnotationView(withIdentifier: BikeAnnoationView.reuseIdentifier, for: userAnnotation) as? BikeAnnoationView { + dequedView.annotation = userAnnotation + view = dequedView + } else { + view = BikeAnnoationView(annotation: userAnnotation, + reuseIdentifier: BikeAnnoationView.reuseIdentifier) + } + } else { + view = BikeAnnoationView(annotation: userAnnotation, + reuseIdentifier: BikeAnnoationView.reuseIdentifier) + } } - - return mapView.dequeueReusableAnnotationView(ofType: matchingController.annotationViewType, with: annotation) + return view } func mapView(_: MKMapView, didChange mode: MKUserTrackingMode, animated _: Bool) { ```diffs.zip