-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New methods for view annotations API #1136
Conversation
d487975
to
cfb4322
Compare
cfb4322
to
14a1e69
Compare
ca85176
to
9593d32
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did review protocol only 😉
API differs slightly from Android but in terms of usability and platform details we should be aligned.
@@ -1,6 +1,7 @@ | |||
import UIKit | |||
@_implementationOnly import MapboxCommon_Private | |||
@_implementationOnly import MapboxCoreMaps_Private | |||
import SwiftUI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need SwiftUI
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't. Probably an accidental auto-import.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True this, gotta be more careful with Xcode auto-importing things.
/// Manager API to control View Annotations. | ||
/// | ||
/// View annotations are `UIView` instances that are drawn on top of the `MapView` and bound to some `Geometry` (only `Point` is supported for now). | ||
/// View annotations are `UIView` instances that are drawn on top of the ``MapView`` and bound to some ``Geometry`` (only ``Point`` is supported for now). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will these links for Geometry and Point do the right thing? Turf docs aren't well integrated at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not as such it seems. I did check that it generates links to those types, but there's nothing in the documentation pages for them. Doesn't look like a right thing, indeed. I'll revert these changes back.
@@ -123,19 +153,36 @@ public final class ViewAnnotationManager { | |||
} | |||
} | |||
|
|||
/// Update given `UIView` with `ViewAnnotationOptions`. | |||
public func removeAll() { | |||
let viewsByIdCopy = viewsById |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we actually need a copy here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so. Swift value types should avoid the troubles with mutation during iteration we had in Objective-C
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Old habits...
view.isHidden = false | ||
expectedHiddenByView[view] = false | ||
visibleAnnotationIds.insert(position.identifier) | ||
} | ||
|
||
assert(!viewsWithUpdatedFrame.contains(where: {$0.isHidden == true })) | ||
notifyViewAnnotationObserversFrameDidChange(for: Array(viewsWithUpdatedFrame)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to wait until the end of the method just before notifyViewAnnotationObserversVisibilityDidChange
to make this call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just thinking it might avoid letting the developer see the views in an inconsistent state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also may make sense to put this block to the defer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the idea with defer
will work well. It will make more sense to first notify about visibility changes and only after that is established to notify about frame changes.
Tests/MapboxMapsTests/Annotations/ViewAnnotationManagerTests.swift
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you preview the changes to the generated docs?
Co-authored-by: Andrew Hershberger <andrew.hershberger@mapbox.com>
Co-authored-by: Andrew Hershberger <andrew.hershberger@mapbox.com>
Co-authored-by: Andrew Hershberger <andrew.hershberger@mapbox.com>
Co-authored-by: Andrew Hershberger <andrew.hershberger@mapbox.com>
Co-authored-by: Andrew Hershberger <andrew.hershberger@mapbox.com>
Co-authored-by: Andrew Hershberger <andrew.hershberger@mapbox.com>
…wift Co-authored-by: Andrew Hershberger <andrew.hershberger@mapbox.com>
305a6d6
to
c15031b
Compare
c15031b
to
35e76d7
Compare
Yeah, looks good except for symbol references to Turf docs(fixed it). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, few nits.
view.isHidden = true | ||
expectedHiddenByView[view] = true | ||
} | ||
|
||
notifyViewAnnotationObserversVisibilityDidChange(for: Array(viewsWithUpdatedVisibility)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make it defer
as well for consistency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
Co-authored-by: Roman Gardukevich <roman.gardukevich@mapbox.com>
0540c6f
to
561fa9a
Compare
Add automation workflow to move new issues to backlog
Summary
This PR introduces
ViewAnnotationUpdateObserver
protocol for notifying when annotion views get their frames or visibility changed. As well as corresponding methods to add/remove view annotation update observers toViewAnnotationManager
.In addition
removeAll()
method is added toViewAnnotationManager
that removes all annotations added before.Fixes: https://github.com/mapbox/mapbox-maps-internal/issues/1280
Pull request checklist:
custom_categories
(scripts/doc-generation/.jazzy.yaml)## main
heading near the top).