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

Improve API of StatusView. #4139

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions Sources/MapboxNavigation/NavigationViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -560,9 +560,11 @@ open class NavigationViewController: UIViewController, NavigationStatusPresenter
return self
}

var topViewController: ContainerViewController?
// :nodoc:
public private(set) var topContainerViewController: ContainerViewController?

var bottomViewController: ContainerViewController?
// :nodoc:
public private(set) var bottomContainerViewController: ContainerViewController?

var arrivalController: ArrivalController?
var cameraController: CameraController?
Expand Down Expand Up @@ -615,7 +617,7 @@ open class NavigationViewController: UIViewController, NavigationStatusPresenter
return viewController
}()

topViewController = topBanner
topContainerViewController = topBanner

return topBanner
}
Expand All @@ -628,7 +630,7 @@ open class NavigationViewController: UIViewController, NavigationStatusPresenter
return viewController
}()

bottomViewController = bottomBanner
bottomContainerViewController = bottomBanner

return bottomBanner
}
Expand Down Expand Up @@ -683,11 +685,11 @@ open class NavigationViewController: UIViewController, NavigationStatusPresenter
components.append(overlayController)
}

if let topViewController = topViewController {
if let topViewController = topContainerViewController {
components.append(topViewController)
}

if let bottomViewController = bottomViewController {
if let bottomViewController = bottomContainerViewController {
components.append(bottomViewController)
}

Expand Down
39 changes: 36 additions & 3 deletions Sources/MapboxNavigation/StatusView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ public class StatusView: UIControl {
*/
public struct Status {
/**
A string that uniquely identifies the `Status`
A string that uniquely identifies the `Status`
*/
public var identifier: String
/**
The text that will appear on the `Status`
The text that will appear on the `Status`
*/
public let title: String
/**
Expand Down Expand Up @@ -57,6 +57,35 @@ public class StatusView: UIControl {
A lower `priority` value corresponds to a higher priority
*/
public var priority: Priority

/**
Initializes `Status` instance.

- parameter identifier: A string that uniquely identifies the `Status`.
- parameter title: The text that will appear on the `Status`.
- parameter spinner: A boolean that indicates whether a spinner is shown.
- parameter duration: A `TimeInterval` that designates the length of time the `Status`
will be displayed (in seconds).
- parameter animated: A boolean that indicates whether showing and hiding of the `Status`
should be animated.
- parameter interactive: Indicates whether the `Status` should respond to touch events.
- parameter priority: `Priority` that defines priority of the status view.
*/
public init(identifier: String,
title: String,
spinner: Bool = false,
duration: TimeInterval,
animated: Bool = true,
interactive: Bool = false,
priority: Priority) {
self.identifier = identifier
self.title = title
self.spinner = spinner
self.duration = duration
self.animated = animated
self.interactive = interactive
self.priority = priority
}
}

/**
Expand Down Expand Up @@ -190,7 +219,11 @@ public class StatusView: UIControl {
isEnabled = status.interactive
textLabel.text = status.title
activityIndicatorView.hidesWhenStopped = true
if (!status.spinner) { activityIndicatorView.stopAnimating() }
if (!status.spinner) {
activityIndicatorView.stopAnimating()
} else {
activityIndicatorView.startAnimating()
}

guard !isCurrentlyVisible, isHidden else { return }

Expand Down