Skip to content

Commit 025309a

Browse files
Fix bug where transparent LanesView displays on update when StepsTable is displayed (#3805)
* Show lanesview based on isDisplayingSteps. * Fix draw method not being called. * Handle showing LanesView in TopBannerViewController, remove changes to LanesView. * Show secondary children using currentInstruction. * Update only lanesview when steps arent displayed. * Reverted changes to LanesView.swift. * Never hide lanesView. * Make sure you can see lanesview after previewing. * Add changelog entry.
1 parent 01d73ba commit 025309a

File tree

2 files changed

+41
-17
lines changed

2 files changed

+41
-17
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
* Fixed an issue where `EndOfRouteCommentView` is using dark style when only light style is allowed. ([#3845](https://github.com/mapbox/mapbox-navigation-ios/pull/3845))
2222
* Fixed an issue where exit views and generic shields in top banner don't get updated when style changes in active navigation. ([#3864](https://github.com/mapbox/mapbox-navigation-ios/pull/3864))
2323
* Fixed an issue where the current road name label used a generic white circle instead of the correct shield to represent a state route in the United States. ([#3870](https://github.com/mapbox/mapbox-navigation-ios/pull/3870))
24+
* Fixed an issue where there was a transparent gap caused by a `LanesView` update when `StepsTable` is displayed during a maneuver update. `LanesView` now stays visible when `StepsTable` is displayed. ([#3805](https://github.com/mapbox/mapbox-navigation-ios/pull/3805))
2425

2526
### CarPlay
2627

Sources/MapboxNavigation/TopBannerViewController.swift

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ open class TopBannerViewController: UIViewController {
1919

2020
var routeProgress: RouteProgress?
2121

22+
var currentInstruction: VisualInstructionBanner?
23+
2224
lazy var informationStackBottomPinConstraint: NSLayoutConstraint = view.bottomAnchor.constraint(equalTo: informationStackView.bottomAnchor)
2325

2426
lazy var informationStackView = UIStackView(orientation: .vertical, autoLayout: true)
@@ -54,10 +56,10 @@ open class TopBannerViewController: UIViewController {
5456
private let instructionsBannerHeight: CGFloat = 100.0
5557

5658
private var informationChildren: [UIView] {
57-
return [instructionsBannerView] + secondaryChildren
59+
return [instructionsBannerView] + secondaryChildren + [lanesView]
5860
}
5961
private var secondaryChildren: [UIView] {
60-
return [lanesView, nextBannerView, statusView, junctionView]
62+
return [nextBannerView, statusView, junctionView]
6163
}
6264

6365
required public init?(coder aDecoder: NSCoder) {
@@ -107,39 +109,58 @@ open class TopBannerViewController: UIViewController {
107109

108110
private func setupInformationStackView() {
109111
addInstructionsBanner()
110-
informationStackView.addArrangedSubviews(secondaryChildren)
112+
let subviews = [lanesView] + secondaryChildren
113+
informationStackView.addArrangedSubviews(subviews)
111114
for child in informationChildren {
112115
child.leadingAnchor.constraint(equalTo: informationStackView.leadingAnchor).isActive = true
113116
child.trailingAnchor.constraint(equalTo: informationStackView.trailingAnchor).isActive = true
114117
}
115118
}
116119

117120

118-
private func showSecondaryChildren(completion: CompletionHandler? = nil) {
121+
private func showSecondaryChildren(including secondaryView: UIView? = nil, completion: CompletionHandler? = nil) {
119122
statusView.isHidden = !statusView.isCurrentlyVisible
120-
junctionView.isHidden = !junctionView.isCurrentlyVisible
121-
lanesView.isHidden = !lanesView.isCurrentlyVisible
122-
nextBannerView.isHidden = !nextBannerView.isCurrentlyVisible
123123

124-
UIView.animate(withDuration: 0.20, delay: 0.0, options: [.curveEaseOut], animations: { [weak self] in
125-
guard let children = self?.informationChildren else {
126-
return
124+
if let tertiary = currentInstruction?.tertiaryInstruction {
125+
lanesView.isHidden = !lanesView.isCurrentlyVisible
126+
lanesView.update(for: currentInstruction)
127+
if !tertiary.laneComponents.isEmpty {
128+
nextBannerView.isHidden = !nextBannerView.isCurrentlyVisible
127129
}
130+
}
131+
132+
if let _ = currentInstruction?.quaternaryInstruction {
133+
junctionView.isHidden = !junctionView.isCurrentlyVisible
134+
}
135+
136+
var notHiddenChildren = [instructionsBannerView] + secondaryChildren.filter {
137+
$0.isHidden == false
138+
}
139+
140+
if let secondaryView = secondaryView {
141+
notHiddenChildren += [secondaryView]
142+
}
143+
144+
UIView.animate(withDuration: 0.20, delay: 0.0, options: [.curveEaseOut], animations: {
128145

129-
for child in children {
146+
for child in notHiddenChildren {
130147
child.alpha = 1.0
131148
}
132149
}, completion: { _ in
133150
completion?()
134151
})
135152
}
136153

137-
private func hideSecondaryChildren(completion: CompletionHandler? = nil) {
154+
private func hideSecondaryChildren(including secondaryView: UIView? = nil, completion: CompletionHandler? = nil) {
138155
UIView.animate(withDuration: 0.20, delay: 0.0, options: [.curveEaseIn], animations: { [weak self] in
139-
guard let children = self?.secondaryChildren else {
156+
guard var children = self?.secondaryChildren else {
140157
return
141158
}
142159

160+
if let secondaryView = secondaryView {
161+
children += [secondaryView]
162+
}
163+
143164
for child in children {
144165
child.alpha = 0.0
145166
}
@@ -196,7 +217,7 @@ open class TopBannerViewController: UIViewController {
196217
instructionsView.update(for: instructions)
197218
previewBannerView = instructionsView
198219

199-
hideSecondaryChildren(completion: completion)
220+
hideSecondaryChildren(including: lanesView, completion: completion)
200221
}
201222

202223
public func stopPreviewing(showingSecondaryChildren: Bool = true) {
@@ -213,7 +234,7 @@ open class TopBannerViewController: UIViewController {
213234
previewBannerView = nil
214235

215236
if showingSecondaryChildren {
216-
showSecondaryChildren()
237+
showSecondaryChildren(including: lanesView)
217238
}
218239
}
219240

@@ -271,7 +292,8 @@ open class TopBannerViewController: UIViewController {
271292
var constraints = pinningConstraints + hideConstraints + self.stepsContainerConstraints
272293

273294
if let bannerHostHeight = self.view.superview?.superview?.frame.height {
274-
let inset = self.instructionsBannerHeight + self.view.safeArea.top
295+
let lanesViewHeight: CGFloat = 40
296+
let inset = self.instructionsBannerHeight + lanesViewHeight + self.view.safeArea.top
275297
stepsHeightPresizingConstraint = (child.view.heightAnchor.constraint(equalToConstant: bannerHostHeight - inset))
276298
constraints.append(stepsHeightPresizingConstraint!)
277299
}
@@ -362,10 +384,11 @@ extension TopBannerViewController: NavigationComponent {
362384
}
363385

364386
public func navigationService(_ service: NavigationService, didPassVisualInstructionPoint instruction: VisualInstructionBanner, routeProgress: RouteProgress) {
387+
currentInstruction = instruction
365388
instructionsBannerView.update(for: instruction)
366-
lanesView.update(for: instruction)
367389
nextBannerView.navigationService(service, didPassVisualInstructionPoint: instruction, routeProgress: routeProgress)
368390
junctionView.update(for: instruction, service: service)
391+
lanesView.update(for: instruction)
369392
}
370393

371394
public func navigationService(_ service: NavigationService, willRerouteFrom location: CLLocation) {

0 commit comments

Comments
 (0)