-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup in MapContentVisitor (#2001)
* Cleanup in MapContentVisitor * Optimize annotation group updates * Return stable annotations order * Fix tests
- Loading branch information
1 parent
d83148d
commit 202ea7f
Showing
17 changed files
with
89 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 11 additions & 10 deletions
21
Sources/MapboxMaps/SwiftUI/Annotations/LayerAnnotationCoordinator.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 15 additions & 10 deletions
25
Sources/MapboxMaps/SwiftUI/Builders/MapContentVisitor.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,40 @@ | ||
import SwiftUI | ||
|
||
protocol MapContentVisitor: AnyObject { | ||
var id: [AnyHashable] { get } | ||
var locationOptions: LocationOptions { get set } | ||
var positionalId: [AnyHashable] { get } | ||
|
||
@available(iOS 13.0, *) | ||
func add(viewAnnotation: MapViewAnnotation) | ||
func add(annotationGroup: AnnotationGroup) | ||
func add(locationOptions: LocationOptions) | ||
|
||
func visit(id: AnyHashable, content: MapContent) | ||
} | ||
|
||
@available(iOS 13.0, *) | ||
final class DefaultMapContentVisitor: MapContentVisitor { | ||
var locationOptions: LocationOptions = LocationOptions() | ||
|
||
private(set) var id: [AnyHashable] = [] | ||
private(set) var locationOptions: LocationOptions = LocationOptions() | ||
private(set) var visitedViewAnnotations: [AnyHashable: MapViewAnnotation] = [:] | ||
private(set) var annotationGroups: [AnnotationGroup] = [] | ||
|
||
private(set) var annotationGroups: [(AnyHashable, AnnotationGroup)] = [] | ||
private(set) var positionalId: [AnyHashable] = [] | ||
|
||
@available(iOS 13.0, *) | ||
func add(viewAnnotation: MapViewAnnotation) { | ||
visitedViewAnnotations[id] = viewAnnotation | ||
visitedViewAnnotations[positionalId] = viewAnnotation | ||
} | ||
|
||
func add(annotationGroup: AnnotationGroup) { | ||
annotationGroups.append((id, annotationGroup)) | ||
annotationGroups.append(annotationGroup) | ||
} | ||
|
||
func add(locationOptions options: LocationOptions) { | ||
locationOptions = options | ||
} | ||
|
||
func visit(id: AnyHashable, content: MapContent) { | ||
self.id.append(id) | ||
positionalId.append(id) | ||
content.visit(self) | ||
self.id.removeLast() | ||
positionalId.removeLast() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters