Skip to content
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

Allow the use of multiple status banners #2747

Merged
merged 40 commits into from Mar 11, 2021

Conversation

jill-cardamon
Copy link
Contributor

@jill-cardamon jill-cardamon commented Nov 24, 2020

Description

This PR allows the use of multiple status banners by refactoring StatusView.swift to manage the display statuses.

  • Create Status struct to represent a status, store them in a statuses array, and refactor as necessary
  • Refactor how statuses are shown and hidden by priority
  • How will we deal with special values associated with a Status? (e.g.: simulation status banner is interactive, allows for changes in simulation speed)
  • Fix #2723 (hide "enable precise location" banner when precise location is switched on)
  • Test (StatusViewTests.swift)
  • Update Changelog

Implementation

Screenshots or Gifs

@jill-cardamon jill-cardamon added op-ex Refactoring, Tech Debt or any other operational excellence work. UI Work related to visual components, Android Auto, Camera, 3D, voice, etc. iOS labels Nov 24, 2020
@jill-cardamon jill-cardamon self-assigned this Nov 24, 2020
@1ec5
Copy link
Contributor

1ec5 commented Nov 25, 2020

CocoaPods integration tests are failing:

[!] CocoaPods could not find compatible versions for pod "Mapbox-iOS-SDK":
  In snapshot (Podfile.lock):
    Mapbox-iOS-SDK (= 6.2.2, ~> 6.0)

CocoaPods picked up the edit to v6.3.0 in mapbox/mapbox-gl-native-ios#549 (comment) but apparently not the earlier edit to v6.2.2 in mapbox/mapbox-gl-native-ios#549 (comment):

  CDN: trunk Relative path: Specs/a/5/9/Mapbox-iOS-SDK/6.3.0/Mapbox-iOS-SDK.podspec.json modified during this run! Returning local
  CDN: trunk Relative path downloaded: all_pods_versions_3_5_2.txt, save ETag: W/"5fbd8072-29e"

This is basically CocoaPods/CocoaPods#10229. We could work around it by forcing the CI job to start with a fresh cache, but at this point, it might be easier to update the integration test fixture by running these commands:

cd MapboxCoreNavigationTests/CocoaPodsTest/PodInstall/
pod update
cd -

@MaximAlien
Copy link
Contributor

Is this PR ready to be reviewed (I can see that it's marked as Draft)? Also it'd be good to fix outstanding conflicts with main branch.

@jill-cardamon
Copy link
Contributor Author

jill-cardamon commented Jan 6, 2021

Yes. Ready to be reviewed. I have two concerns if you could address them in your review:

  • Do I delete method calls in other functions and add a deprecated flag to the definition only?
  • Advice on timer related issue: used a dispatch queue to make things happen when I want them to, but when I was testing, I realized that hiding (which uses a dispatch queue) takes a while. Not sure if it’s because of the loop I implemented or something else. But it takes a while for it to disappear (longer than the delay duration). I did not notice this issue in the example with the current statuses we use.

@jill-cardamon jill-cardamon marked this pull request as ready for review January 6, 2021 15:55
@MaximAlien MaximAlien requested a review from a team January 6, 2021 17:52
@@ -724,21 +743,28 @@ extension NavigationViewController: NavigationServiceDelegate {
public func navigationServiceShouldDisableBatteryMonitoring(_ service: NavigationService) -> Bool {
return navigationComponents.allSatisfy { $0.navigationServiceShouldDisableBatteryMonitoring(service) }
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: removing extra whitespaces and cleaning the code would be great.

public func showStatus(title: String, spinner spin: Bool = false, duration: TimeInterval, animated: Bool = true, interactive: Bool = false) {
show(title, showSpinner: spin, interactive: interactive)
// show(title, showSpinner: spin, interactive: interactive)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: removing the unnecessary comment would be better.

@@ -65,4 +65,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: d4084fe664fbacd0cffd88ab45eaed1ad907ad1d

COCOAPODS: 1.10.0
COCOAPODS: 1.9.3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep CocoaPods 1.10.0 as it's used on CircleCI as well.

@@ -933,7 +934,7 @@
AED2156E208F7FEA009AA673 /* NavigationViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationViewControllerTests.swift; sourceTree = "<group>"; };
AED6285522CBE4CE00058A51 /* ViewController+GuidanceCards.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "ViewController+GuidanceCards.swift"; path = "Example/ViewController+GuidanceCards.swift"; sourceTree = "<group>"; };
AEF2C8F12072B603007B061F /* routeWithTunnels_9thStreetDC.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = routeWithTunnels_9thStreetDC.json; sourceTree = "<group>"; };
B430D2F925534FDC0088CC23 /* UserHaloCourseView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserHaloCourseView.swift; sourceTree = "<group>"; };
C3D225502587F411007DBCDF /* StatusViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusViewTests.swift; sourceTree = "<group>"; }; B430D2F925534FDC0088CC23 /* UserHaloCourseView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserHaloCourseView.swift; sourceTree = "<group>"; };
Copy link
Contributor

@MaximAlien MaximAlien Jan 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this file manually changed to resolve conflicts? Seems that it now has custom format, to fix it C3D225502587F411007DBCDF /* StatusViewTests.swift */ and B430D2F925534FDC0088CC23 /* UserHaloCourseView.swift */ should be in different lines.

}

/**
Shows the status view with an optional spinner.
*/
public func show(_ title: String, showSpinner: Bool, interactive: Bool = false) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be better to extend existing APIs instead of replacing existing ones. If you feel that newly added API is more concise previous one can be deprecated/or left without any changes.

var priority: Priority
}

struct Priority: RawRepresentable {
Copy link
Contributor

@MaximAlien MaximAlien Jan 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be better to use enum for status priority. If Status meant to be used publicly, Priority should be made public as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the idea was to allow for arbitrary priorities, similar to constraint priorities. But making the type public would make sense.

Shows the status view for a specified amount of time.
Shows a Status for a specified amount of time.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think such comment would be accurate for func addNewStatus(status: StatusView.Status). I think it'd better to comment with - parameter statements in this case. Please also add docs for addNewStatus(status:) and hideStatus(status:).

*/
func showStatus(title: String, spinner: Bool, duration: TimeInterval, animated: Bool, interactive: Bool)

func addNewStatus(status: StatusView.Status)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also rename addNewStatus(status:) to func show(_ status: StatusView.Status) and func hideStatus(using: StatusView.Status) to hide(_ status: StatusView.Status).

@@ -411,6 +416,7 @@ extension TopBannerViewController: NavigationComponent {
public func navigationService(_ service: NavigationService, willEndSimulating progress: RouteProgress, becauseOf reason: SimulationIntent) {
guard reason == .manual else { return }
statusView.hide(delay: 0, animated: true)
// statusView.hide("simulating")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is commented part needed? If not, please remove it.

Sources/MapboxNavigation/NavigationViewController.swift Outdated Show resolved Hide resolved
Sources/MapboxNavigation/NavigationViewController.swift Outdated Show resolved Hide resolved
Sources/MapboxNavigation/NavigationViewController.swift Outdated Show resolved Hide resolved
Sources/MapboxNavigation/NavigationComponent.swift Outdated Show resolved Hide resolved
Sources/MapboxNavigation/StatusView.swift Outdated Show resolved Hide resolved
Sources/MapboxNavigation/StatusView.swift Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
Sources/MapboxNavigation/NavigationComponent.swift Outdated Show resolved Hide resolved
Sources/MapboxNavigation/NavigationViewController.swift Outdated Show resolved Hide resolved
Tests/MapboxNavigationTests/StatusViewTests.swift Outdated Show resolved Hide resolved
@1ec5
Copy link
Contributor

1ec5 commented Mar 2, 2021

Looks like the PR branch got munged up somehow, as if it got merged then rebased. If git reflog says merging was the last thing you did, you could try hard-resetting to before that merge then performing just a rebase and finally force-pushing.

@jill-cardamon
Copy link
Contributor Author

The last thing there is a rebase; I didn't use a merge at all.

@1ec5
Copy link
Contributor

1ec5 commented Mar 5, 2021

I think this branch was rebased onto an old copy of the main branch.

Jill Cardamon and others added 19 commits March 5, 2021 15:02
…false to navigationServiceDidChangeAuthorization so that halo view disappears when precise location is enabled so halo disappears
Upgraded to MapboxNavigationNative v31.0.1. Removed explicit routing tile version discovery now that the navigator can automatically choose the most recent version.
…false to navigationServiceDidChangeAuthorization so that halo view disappears when precise location is enabled so halo disappears
@jill-cardamon jill-cardamon force-pushed the jill-enable-precise-location-tailwork-2723 branch from bbac3ca to 515dab5 Compare March 5, 2021 20:48
Copy link
Contributor

@1ec5 1ec5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is tantalizingly close – I think the remaining tasks will be pretty small in nature.

@@ -3,12 +3,13 @@
## v1.3.0

* MapboxCoreNavigation can now be installed using Swift Package Manager. ([#2771](https://github.com/mapbox/mapbox-navigation-ios/pull/2771))
* The CarPlay guidance panel now shows lane guidance. ([#2798](https://github.com/mapbox/mapbox-navigation-ios/pull/2798))
* The CarPlay guidance panel now shows lane guidance. ([#1885](https://github.com/mapbox/mapbox-navigation-ios/pull/1885))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks like a bad merge; can you revert it? Thanks!

Sources/MapboxNavigation/StatusView.swift Outdated Show resolved Hide resolved
Sources/MapboxNavigation/StatusView.swift Outdated Show resolved Hide resolved
Comment on lines 67 to 68
public struct Priority: RawRepresentable {
public typealias RawValue = Int
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since no specific values are defined, it would be simpler to define a type alias than a raw representable type alias inside a struct:

public typealias Priority = Int

Sources/MapboxNavigation/StatusView.swift Outdated Show resolved Hide resolved
Copy link
Contributor

@1ec5 1ec5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good to go once the struct goes away per #2747 (comment) and the changelog is fixed per #2747 (comment).

@@ -52,30 +52,57 @@ public class StatusView: UIControl {
`Status` is a struct which stores information to be displayed by the `StatusView`
*/
public struct Status {
/**
`identifier` is a unique string identifier for a `Status`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, it isn’t necessary to explicitly name the property in the property’s own documentation comment. For example, this could say “A string that uniquely identifies this status.”

Comment on lines 94 to 95
public struct Priority {
public typealias Priority = Int
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace the struct with the typealias. The value property will go away: you’ll be able to use an Int as if it were a Priority.

The previous version with the raw-representable Priority would’ve been appropriate if we wanted to define some preset values like high and low that were tied to specific values. But only a bare typealias is necessary if we’re treating it as just an ordinary number with special semantics.

@jill-cardamon jill-cardamon merged commit fd1daf4 into main Mar 11, 2021
@jill-cardamon jill-cardamon deleted the jill-enable-precise-location-tailwork-2723 branch March 11, 2021 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
op-ex Refactoring, Tech Debt or any other operational excellence work. UI Work related to visual components, Android Auto, Camera, 3D, voice, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants