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

Use Style for unknown eta color #549

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions MapboxNavigation/RouteTableViewController.swift
Expand Up @@ -16,6 +16,8 @@ class RouteTableViewController: UIViewController {
@IBOutlet var headerView: RouteTableViewHeaderView!
@IBOutlet weak var tableView: UITableView!

var defaultTimeRemainingColor: UIColor!

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
setupTableView()
Expand All @@ -25,6 +27,10 @@ class RouteTableViewController: UIViewController {
distanceFormatter.numberFormatter.locale = .nationalizedCurrent
}

override func viewDidLoad() {
defaultTimeRemainingColor = headerView.timeRemaining.textColor
Copy link
Contributor

Choose a reason for hiding this comment

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

Not calling super here can result in all kinds of obscure behavior.

}

func setupTableView() {
tableView.tableHeaderView = headerView
tableView.rowHeight = UITableViewAutomaticDimension
Expand Down Expand Up @@ -52,7 +58,7 @@ class RouteTableViewController: UIViewController {
let coordinatesLeftOnStepCount = Int(floor((Double(routeProgress.currentLegProgress.currentStepProgress.step.coordinateCount)) * routeProgress.currentLegProgress.currentStepProgress.fractionTraveled))

guard coordinatesLeftOnStepCount >= 0 else {
headerView.timeRemaining.textColor = TimeRemainingLabel.appearance(for: traitCollection).textColor
headerView.timeRemaining.textColor = defaultTimeRemainingColor
return
}

Expand All @@ -79,7 +85,7 @@ class RouteTableViewController: UIViewController {
if let max = remainingStepCongestionTotals.max(by: { a, b in a.value < b.value }) {
switch max.key {
case .unknown:
headerView.timeRemaining.textColor = TimeRemainingLabel.appearance(for: traitCollection).textColor
headerView.timeRemaining.textColor = defaultTimeRemainingColor
case .low:
headerView.timeRemaining.textColor = .trafficAlternateLow
case .moderate:
Expand Down