Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
c79e9f5
WIP - initial instructions card integration for the custom top banner…
vincethecoder Apr 22, 2019
583575e
Updates to resolve broken constraints. Created a custom instructions …
vincethecoder Apr 24, 2019
d8ae437
Added ability to preview routes while scrolling through the instructi…
vincethecoder Apr 26, 2019
fc08027
Added navigation interaction delegate for sending messages whenever t…
vincethecoder Apr 26, 2019
5affdf4
Added implementation to recover from preview mode.
vincethecoder Apr 26, 2019
f3132a5
Displays the appropriate instructions for the current maneuvers.
vincethecoder Apr 30, 2019
5ffec1b
Added snapshot tests before upcoming cards refactor.
vincethecoder Apr 30, 2019
2479706
Added test cases for the size and position of the instructions cards.
vincethecoder May 1, 2019
1f10807
Added a unit and UI tests for the instructions cards.
vincethecoder May 1, 2019
81d0fcf
Fixed broken route preview.
vincethecoder May 1, 2019
cd9ba2b
Updated the width of the cards using a percentile calculation of the …
vincethecoder May 1, 2019
9b3fb20
Updated current branch with upstream branch "jerrad/customize-top-ban…
vincethecoder May 2, 2019
3521993
Refactored the modified steps variables to card steps.
vincethecoder May 2, 2019
24b00a9
Added a test to validate the instructions card collection delegate.
vincethecoder May 3, 2019
986717d
Updated current branch with upstream branch "jerrad/customize-top-ban…
vincethecoder May 3, 2019
704e123
Updated compare images post merging jerrad's custom top banner branch.
vincethecoder May 3, 2019
16ab6e6
Updates to instructions card collections to allow swiping back and fo…
vincethecoder May 6, 2019
789b610
Refactor to avoid using computed properties. Uncommented a method tha…
vincethecoder May 6, 2019
e6f57ae
Deleted the redundant UI test file dedicated to instructions card.
vincethecoder May 7, 2019
4413886
Added factory methods and deleted a few computed properties in the in…
vincethecoder May 7, 2019
35b8f9c
Removed commented code along. Minor changes to group class methods to…
vincethecoder May 8, 2019
d89dab3
Added documentation to the instructions card collection delegate. Rem…
vincethecoder May 8, 2019
2df5532
Merge branch 'jerrad/customize-top-banner' into kobe/top-banner-instr…
vincethecoder May 8, 2019
9a808a8
Temporary setting to mapbox mobile events to 0.8.1 to experimentation.
vincethecoder May 8, 2019
c3b6478
Merge branch 'jerrad/customize-top-banner' into kobe/top-banner-instr…
vincethecoder May 14, 2019
fc8a74f
Updated mobile events version to latest release.
vincethecoder May 14, 2019
6fc7ba5
Updates to use generic view width to fix the broken snapshot tests.
vincethecoder May 14, 2019
25c7fb3
Providing 12.2 snapshot for kobe as requested
May 14, 2019
d92daba
Regenerated the snapshot images to broken instructions card snapshot …
vincethecoder May 17, 2019
41872ae
Deleted redundant reference images stored in the instructions card sn…
vincethecoder May 17, 2019
ac3b9c0
Merge branch 'jerrad/customize-top-banner' into kobe/top-banner-instr…
vincethecoder May 17, 2019
fff6878
Deleted tap sensitive delegate.
vincethecoder May 17, 2019
d491015
Regenerated snapshot images.
vincethecoder May 20, 2019
2c35759
Used 0.02 tolerance.
vincethecoder May 20, 2019
7da0247
Revert "Regenerated snapshot images."
vincethecoder May 20, 2019
28749f1
Reverted to default tolerance of 0.05
vincethecoder May 20, 2019
094fc73
Updated screenshots for the broken CI builds in top banner instructio…
vincethecoder May 20, 2019
38ff25a
Updated the podlock file to fix failing CI build
vincethecoder May 20, 2019
17d57f0
Merge branch 'jerrad/customize-top-banner' into kobe/top-banner-instr…
vincethecoder May 20, 2019
32dfeff
Added an override to set the available bounds for guidance cards. Fix…
vincethecoder May 22, 2019
db9c551
Updated the test cases and the snapshot images.
vincethecoder May 22, 2019
548a958
Declared day instructions card style as public.
vincethecoder May 23, 2019
2673f58
Declared methods for layout prep and distance updates in instructions…
vincethecoder May 23, 2019
d0d8b37
Recent efforts to customize the top banner instructions card and refa…
vincethecoder Jun 12, 2019
32343ff
Merge branch 'master' into kobe/top-banner-instructions-card
vincethecoder Jun 13, 2019
92850fd
Fixed broken constraints and the broken maneuver distances.
vincethecoder Jun 14, 2019
3707eb5
resolved merge conflicts
vincethecoder Jun 14, 2019
f742137
Additional changes to resolve the crashes when the reload items befor…
vincethecoder Jun 17, 2019
0f61079
Merge branch 'master' into kobe/top-banner-instructions-card
vincethecoder Jun 17, 2019
a823fb3
Fixed flicker on cards and crash encountered from reloading visible i…
vincethecoder Jun 20, 2019
ee61580
Reload the cards immediately after a reroute.
vincethecoder Jun 21, 2019
721f602
Removed redundant navigation service instance.
vincethecoder Jun 27, 2019
2ed7b7a
Added dynamic size to the font created.
vincethecoder Jun 27, 2019
0f469e6
Modified delegate method signatures.
vincethecoder Jun 28, 2019
9b18463
Modified to ensure an optimal calculation of the distances from curre…
vincethecoder Jun 28, 2019
8e09967
Separated concerns related to guidance cards into its own file. Place…
vincethecoder Jul 2, 2019
a7ffc14
Resolved a few functionalities to meet user experience requirements.
vincethecoder Jul 2, 2019
3aebbe8
Moved instructions card collection delegates into its own file.
vincethecoder Jul 5, 2019
992f456
Hides lane indications if no unusable lanes exists within the lane co…
vincethecoder Jul 5, 2019
c1966af
Refactored InstructionsCardCollection name and cumulative distances d…
vincethecoder Jul 10, 2019
6fd74ec
Updates to query the steps array when snapping to a new index path in…
vincethecoder Jul 16, 2019
bcd2884
Modified cumulated calculated distances on guidance cards to remainin…
vincethecoder Jul 16, 2019
e239d16
Made classes and properties extensible for custom distance calculatio…
vincethecoder Jul 16, 2019
f2e9dbf
Modified the remaining steps distances implementation to avoid redund…
vincethecoder Jul 17, 2019
5a17173
Fixing redundant checks that were causing lanes & next banner to inte…
Aug 9, 2019
3184056
Merge branch 'master' into kobe/top-banner-instructions-card
Aug 15, 2019
01f932f
Adding snapshot tests to guidance card collection.
Aug 15, 2019
93a6a80
Adding `:nodoc:` to all unannounced classes
Aug 15, 2019
cbf7f5c
Extracted common test code into extension.
Aug 15, 2019
2ab971b
Added snapshot test fixtures
1ec5 Aug 22, 2019
d51ddff
More guidance card snapshot test fixtures
1ec5 Aug 22, 2019
89eb721
Upgraded to Xcode 10.3
1ec5 Aug 22, 2019
cf992d2
Correcting issue with snapshot test failures.
Aug 23, 2019
59028e6
oopsie.
Aug 23, 2019
fd9a3a4
Fixup final issue with tests
Aug 23, 2019
e5f1b5a
Spoke too soon, hopefully this is the final time
Aug 24, 2019
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
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,12 @@ workflows:
workflow:
jobs:
- build-job:
name: "Xcode_10.2_iOS_12.2"
xcode: "10.2.0"
name: "Xcode_10.3_iOS_12.2"
xcode: "10.3.0"
iOS: "12.2"
- build-job:
name: "Xcode_10.1_iOS_12.1"
xcode: "10.1.0"
name: "Xcode_10.3_iOS_12.1"
xcode: "10.3.0"
iOS: "12.1"
codecoverage: true
- build-job:
Expand Down
17 changes: 17 additions & 0 deletions Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,14 @@ class ViewController: UIViewController {
let night: ActionHandler = {_ in self.startNavigation(styles: [NightStyle()]) }
let custom: ActionHandler = {_ in self.startCustomNavigation() }
let styled: ActionHandler = {_ in self.startStyledNavigation() }
let guidanceCards: ActionHandler = {_ in self.startGuidanceCardsNavigation() }

let actionPayloads: [(String, UIAlertAction.Style, ActionHandler?)] = [
("Default UI", .default, basic),
("DayStyle UI", .default, day),
("NightStyle UI", .default, night),
("Custom UI", .default, custom),
("Guidance Card UI", .default, guidanceCards),
("Styled UI", .default, styled),
("Cancel", .cancel, nil)
]
Expand Down Expand Up @@ -286,6 +288,21 @@ class ViewController: UIViewController {

presentAndRemoveMapview(navigationViewController, completion: beginCarPlayNavigation)
}

// MARK: Guidance Cards
func startGuidanceCardsNavigation() {
guard let route = routes?.first else { return }

let instructionsCardCollection = InstructionsCardViewController()
instructionsCardCollection.cardCollectionDelegate = self

let options = NavigationOptions(navigationService: navigationService(route: route), topBanner: instructionsCardCollection)
let navigationViewController = NavigationViewController(for: route, options: options)
navigationViewController.delegate = self

presentAndRemoveMapview(navigationViewController, completion: beginCarPlayNavigation)
}


func navigationService(route: Route) -> NavigationService {
let simulate = simulationButton.isSelected
Expand Down
72 changes: 72 additions & 0 deletions MapboxNavigation.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions MapboxNavigation/Constants+InstructionsCard.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/// :nodoc:
struct InstructionsCardConstants {
static let highlightDistance: CLLocationDistance = 152.4 // 500 ft

static let primaryLabelWidth: CGFloat = 170.0

static let primaryLabelLeadingPadding: CGFloat = 14.0

static let secondaryLabelWidth: CGFloat = 170.0

static let highlightAnimationDuration: TimeInterval = 0.2

static let highlightedBackgroundAlphaComponent: CGFloat = 0.90

static let backgroundColorAlphaComponent: CGFloat = 0.90
}
98 changes: 98 additions & 0 deletions MapboxNavigation/DayInstructionsCardStyle.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/// :nodoc:
public class DayInstructionsCardStyle: InstructionsCardStyle {
public var cornerRadius: CGFloat = 20.0

public var backgroundColor: UIColor = .white

public var highlightedBackgroundColor: UIColor = .cardBlue

public lazy var primaryLabelNormalFont: UIFont = {
return CardFont.create(.bold, with: 24.0)!
}()

public var primaryLabelTextColor: UIColor {
return .cardDark
}

public var primaryLabelHighlightedTextColor: UIColor {
return .cardLight
}

public lazy var secondaryLabelNormalFont: UIFont = {
return CardFont.create(.bold, with: 18.0)!
}()

public var secondaryLabelTextColor: UIColor {
return .cardDark
}

public var secondaryLabelHighlightedTextColor: UIColor {
return .cardLight
}

public lazy var distanceLabelNormalFont: UIFont = {
return CardFont.create(.regular, with: 16.0)!
}()

public var distanceLabelValueTextColor: UIColor {
return .cardDark
}

public var distanceLabelUnitTextColor: UIColor {
return .cardDark
}

public lazy var distanceLabelUnitFont: UIFont = {
return CardFont.create(.regular, with: 16.0)!
}()

public lazy var distanceLabelValueFont: UIFont = {
return CardFont.create(.bold, with: 20.0)!
}()

public var distanceLabelHighlightedTextColor: UIColor {
return .cardLight
}

public var maneuverViewPrimaryColor: UIColor {
return .cardBlue
}

public var maneuverViewSecondaryColor: UIColor {
return .cardLight
}

public var maneuverViewHighlightedColor: UIColor {
return .cardLight
}

public var nextBannerViewPrimaryColor: UIColor {
return .cardBlue
}

public var nextBannerViewSecondaryColor: UIColor {
return .cardLight
}

public var nextBannerInstructionLabelTextColor: UIColor {
return .cardDark
}

public lazy var nextBannerInstructionLabelNormalFont: UIFont = {
return CardFont.create(.regular, with: 14.0)
}()

public var nextBannerInstructionHighlightedColor: UIColor {
return .cardLight
}

public var lanesViewDefaultColor: UIColor {
return .cardBlue
}

public var lanesViewHighlightedColor: UIColor {
return .cardLight
}

public init() {}
}
8 changes: 4 additions & 4 deletions MapboxNavigation/InstructionsBannerViewLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ extension BaseInstructionsBannerView {
addGestureRecognizer(swipeDownGesture)
}

func setupLayout() {
@objc func setupLayout() {
// firstColumnWidth is the width of the left side of the banner containing the maneuver view and distance label
let firstColumnWidth = BaseInstructionsBannerView.maneuverViewSize.width + BaseInstructionsBannerView.padding * 3

Expand Down Expand Up @@ -135,20 +135,20 @@ extension BaseInstructionsBannerView {
}

// Aligns the instruction to the center Y (used for single line primary and/or secondary instructions)
func centerYAlignInstructions() {
@objc func centerYAlignInstructions() {
_separatorView.isHidden = false
baselineConstraints.forEach { $0.isActive = false }
centerYConstraints.forEach { $0.isActive = true }
}

// Aligns primary top to the top of the maneuver view and the secondary baseline to the distance baseline (used for multiline)
func baselineAlignInstructions() {
@objc func baselineAlignInstructions() {
_separatorView.isHidden = true
centerYConstraints.forEach { $0.isActive = false }
baselineConstraints.forEach { $0.isActive = true }
}

func setupAvailableBounds() {
@objc func setupAvailableBounds() {
// Abbreviate if the instructions do not fit on one line
primaryLabel.availableBounds = { [unowned self] in
// Available width H:|-padding-maneuverView-padding-availableWidth-padding-|
Expand Down
16 changes: 16 additions & 0 deletions MapboxNavigation/InstructionsCard+Font.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/// :nodoc:
enum CardFont: String {
case regular
case bold

static func create(_ type: CardFont, with size: CGFloat) -> UIFont! {
let font = type == .bold ? UIFont.boldSystemFont(ofSize: size) : UIFont.systemFont(ofSize: size)
return font.adjustedFont
}
}

/// :nodoc:
struct CardFontType {
static let regular: String = "FontSystem-Regular"
static let bold: String = "FontSystem-Bold"
}
53 changes: 53 additions & 0 deletions MapboxNavigation/InstructionsCardCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import UIKit
import MapboxDirections
import MapboxCoreNavigation

/// :nodoc:
public class InstructionsCardCell: UICollectionViewCell {

public var container: InstructionsCardContainerView!
public var style: InstructionsCardStyle = DayInstructionsCardStyle()

override public init(frame: CGRect) {
super.init(frame: frame)
self.commonInit()
}

required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.commonInit()
}

func commonInit() {
container = InstructionsCardContainerView()
configureLayer()
}

func configureLayer() {
backgroundColor = .clear
layer.shadowColor = UIColor.black.cgColor
layer.shadowOffset = CGSize(width: 1, height: 2)
layer.shadowRadius = 1
layer.shadowOpacity = 0.4
}

func setupConstraints() {
container.translatesAutoresizingMaskIntoConstraints = false
container.topAnchor.constraint(equalTo: topAnchor, constant: 2).isActive = true
container.leadingAnchor.constraint(equalTo: contentView.leadingAnchor).isActive = true
container.trailingAnchor.constraint(equalTo: contentView.trailingAnchor).isActive = true
}

override public func layoutSubviews() {
super.layoutSubviews()
/* TODO: Smoothen animation here. */
}

public func configure(for step: RouteStep, distance: CLLocationDistance) {
addSubview(container)
setupConstraints()
container.prepareLayout(for: style)
container.updateInstruction(for: step, distance: distance)
}
}

25 changes: 25 additions & 0 deletions MapboxNavigation/InstructionsCardCollectionDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import MapboxDirections
import MapboxCoreNavigation

/// :nodoc:
@objc public protocol InstructionsCardCollectionDelegate: InstructionsCardContainerViewDelegate {
/**
Called when previewing the steps on the current route.

Implementing this method will allow developers to move focus to the maneuver that corresponds to the step currently previewed.
- parameter instructionsCardCollection: The instructions card collection instance.
- parameter step: The step for the maneuver instruction in preview.
*/
@objc(instructionsCardCollection:didPreviewStep:)
func instructionsCardCollection(_ instructionsCardCollection: InstructionsCardViewController, didPreview step: RouteStep)

/**
Offers the delegate the opportunity to customize the size of a prototype collection view cell per the associated trait collection.

- parameter instructionsCardCollection: The instructions card collection instance.
- parameter traitCollection: The traitCollection associated to the current container view controller.
- returns: The preferred size of the cards for each cell in the instructions card collection.
*/
@objc(instructionsCardCollection:cardSizeForTraitCollection:)
optional func instructionsCardCollection(_ instructionsCardCollection: InstructionsCardViewController, cardSizeFor traitCollection: UITraitCollection) -> CGSize
}
Loading