Skip to content

Commit 01d73ba

Browse files
authored
Use legacy fallback icon for U.S. state road shields first. (#3870)
1 parent e7eabfc commit 01d73ba

File tree

3 files changed

+25
-23
lines changed

3 files changed

+25
-23
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* Fixed an issue where shields disappeared after the application returns to the foreground. ([#3840](https://github.com/mapbox/mapbox-navigation-ios/pull/3840))
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))
23+
* 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))
2324

2425
### CarPlay
2526

Sources/MapboxNavigation/InstructionPresenter.swift

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -176,31 +176,36 @@ class InstructionPresenter {
176176
dataSource: DataSource,
177177
onImageDownload: @escaping CompletionHandler) -> NSAttributedString? {
178178
if let shield = representation.shield {
179-
if shield.name == "us-state",
180-
let legacyAttributedString = legacyAttributedString(for: representation, in: repository, dataSource: dataSource) {
181-
return legacyAttributedString
182-
} else if let shieldAttributedString = shieldAttributedString(for: representation, in: repository, dataSource: dataSource) {
179+
// For US state road, use the legacy shield first, then fall back to use the generic shield icon.
180+
// The shield name for US state road is `circle-white` in Streets source v8 style.
181+
// For non US state road, use the generic shield icon first, then fall back to use the legacy shield.
182+
if shield.name == "circle-white" {
183+
if let legacyIcon = repository.legacyCache.image(forKey: representation.legacyCacheKey) {
184+
return legacyAttributedString(for: legacyIcon, dataSource: dataSource)
185+
} else if representation.imageBaseURL != nil {
186+
spriteRepository.updateRepresentation(for: representation, completion: onImageDownload)
187+
return nil
188+
}
189+
}
190+
if let shieldAttributedString = shieldAttributedString(for: representation, in: repository, dataSource: dataSource) {
183191
return shieldAttributedString
184192
}
185193
}
186194

187-
if let legacyAttributedString = legacyAttributedString(for: representation, in: repository, dataSource: dataSource) {
188-
return legacyAttributedString
195+
if let legacyIcon = repository.legacyCache.image(forKey: representation.legacyCacheKey) {
196+
return legacyAttributedString(for: legacyIcon, dataSource: dataSource)
189197
}
190198

191199
// Return nothing in the meantime, triggering downstream behavior (generic shield or text).
192200
spriteRepository.updateRepresentation(for: representation, completion: onImageDownload)
193201
return nil
194202
}
195203

196-
private func legacyAttributedString(for representation: VisualInstruction.Component.ImageRepresentation,
197-
in repository: SpriteRepository,
198-
dataSource: DataSource) -> NSAttributedString? {
199-
guard let cachedImage = repository.legacyCache.image(forKey: representation.legacyCacheKey) else { return nil }
200-
204+
private func legacyAttributedString(for legacyIcon: UIImage,
205+
dataSource: DataSource) -> NSAttributedString {
201206
let attachment = ShieldAttachment()
202207
attachment.font = dataSource.font
203-
attachment.image = cachedImage
208+
attachment.image = legacyIcon
204209
return NSAttributedString(attachment: attachment)
205210
}
206211

Sources/MapboxNavigation/WayNameView.swift

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,14 @@ open class WayNameLabel: StylableLabel {
4747
// If there's no valid shield image, display the road name only.
4848
private func setUpWith(roadName: String) {
4949
if let shield = representation?.shield {
50-
// For `us-state` shield, use the legacy shield first, then fall back to use the generic shield icon.
51-
// For non `us-state` shield, use the generic shield icon first, then fall back to use the legacy shield.
52-
if shield.name == "us-state",
53-
setAttributedText(roadName: roadName, cacheKey: representation?.legacyCacheKey) {
54-
return
55-
} else if setAttributedText(roadName: roadName, shield: shield) {
56-
return
57-
}
58-
}
59-
if setAttributedText(roadName: roadName, cacheKey: representation?.legacyCacheKey) {
60-
return
50+
// For US state road, use the legacy shield first, then fall back to use the generic shield icon.
51+
// The shield name for US state road is `circle-white` in Streets source v8 style.
52+
// For non US state road, use the generic shield icon first, then fall back to use the legacy shield.
53+
if shield.name == "circle-white",
54+
setAttributedText(roadName: roadName, cacheKey: representation?.legacyCacheKey) { return }
55+
if setAttributedText(roadName: roadName, shield: shield) { return }
6156
}
57+
if setAttributedText(roadName: roadName, cacheKey: representation?.legacyCacheKey) { return }
6258

6359
text = roadName
6460
}

0 commit comments

Comments
 (0)