Skip to content

Commit

Permalink
Hide the stepViewController and stop the swipe and tap on instruction…
Browse files Browse the repository at this point in the history
… banner on final step.
  • Loading branch information
ShanMa1991 committed Feb 11, 2022
1 parent dc53deb commit 14d96e9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
19 changes: 6 additions & 13 deletions Sources/MapboxNavigation/InstructionsBannerView.swift
Expand Up @@ -145,9 +145,7 @@ open class BaseInstructionsBannerView: UIControl {
}

@objc func swipedInstructionBannerLeft(_ sender: Any) {
if !swipeable {
return
}
guard swipeable && showStepIndicator else { return }

if let gestureRecognizer = sender as? UISwipeGestureRecognizer,
gestureRecognizer.state == .ended {
Expand All @@ -158,9 +156,7 @@ open class BaseInstructionsBannerView: UIControl {
}

@objc func swipedInstructionBannerRight(_ sender: Any) {
if !swipeable {
return
}
guard swipeable && showStepIndicator else { return }

if let gestureRecognizer = sender as? UISwipeGestureRecognizer,
gestureRecognizer.state == .ended {
Expand All @@ -171,21 +167,18 @@ open class BaseInstructionsBannerView: UIControl {
}

@objc func swipedInstructionBannerDown(_ sender: Any) {
guard showStepIndicator else { return }
if let gestureRecognizer = sender as? UISwipeGestureRecognizer,
gestureRecognizer.state == .ended {
if showStepIndicator {
stepListIndicatorView.isHidden = !stepListIndicatorView.isHidden
}

stepListIndicatorView.isHidden = !stepListIndicatorView.isHidden
delegate?.didSwipeInstructionsBanner(self, swipeDirection: .down)
}
}

@objc func tappedInstructionsBanner(_ sender: Any) {
guard showStepIndicator else { return }
if let delegate = delegate {
if showStepIndicator {
stepListIndicatorView.isHidden = !stepListIndicatorView.isHidden
}
stepListIndicatorView.isHidden = !stepListIndicatorView.isHidden
delegate.didTapInstructionsBanner(self)
}
}
Expand Down
16 changes: 15 additions & 1 deletion Sources/MapboxNavigation/TopBannerViewController.swift
Expand Up @@ -347,6 +347,18 @@ extension TopBannerViewController: NavigationComponent {
public func navigationService(_ service: NavigationService, didUpdate progress: RouteProgress, with location: CLLocation, rawLocation: CLLocation) {
routeProgress = progress
instructionsBannerView.updateDistance(for: progress.currentLegProgress.currentStepProgress)

if progress.remainingSteps.count < 2 {
instructionsBannerView.showStepIndicator = false

if let steps = stepsViewController {
isDisplayingSteps = false
steps.dismiss()
stepsViewController = nil
}
} else {
instructionsBannerView.showStepIndicator = true
}
}

public func navigationService(_ service: NavigationService, didPassVisualInstructionPoint instruction: VisualInstructionBanner, routeProgress: RouteProgress) {
Expand Down Expand Up @@ -428,7 +440,9 @@ extension TopBannerViewController: StepsViewControllerDelegate {

public func didDismissStepsViewController(_ viewController: StepsViewController) {
dismissStepsTable()
instructionsBannerView.showStepIndicator = true
if let stepCount = routeProgress?.remainingSteps.count, stepCount > 1 {
instructionsBannerView.showStepIndicator = true
}
}
}

Expand Down

0 comments on commit 14d96e9

Please sign in to comment.