Skip to content

Commit a140d09

Browse files
authored
Allow the detailed feedback style change. (#3954)
1 parent 4cf848e commit a140d09

File tree

6 files changed

+67
-29
lines changed

6 files changed

+67
-29
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
* Fixed an issue when alternative route lines overlapped the main route line during navigation. ([#3947](https://github.com/mapbox/mapbox-navigation-ios/pull/3947))
5151
* Fixed an issue when rerouting to the route which does not originate on current user location, route line and camera jumped to route origin. ([#3943](https://github.com/mapbox/mapbox-navigation-ios/pull/3943))
5252
* All logs that Navigation SDK produces are now sent to the `MapboxCommon` framework. You can intercept these logs in your own code using `LogConfiguration.registerLogWriterBackend(forLogWriter:)` method from `MapboxCommon` framework. ([#3944](https://github.com/mapbox/mapbox-navigation-ios/pull/3944))
53+
* Fixed an issue where popped window doesn't get updated in appearance when style changes on phone. ([#3954](https://github.com/mapbox/mapbox-navigation-ios/pull/3954))
54+
* Fixed an issue where detailed feedback items don't change color in different style. ([#3954](https://github.com/mapbox/mapbox-navigation-ios/pull/3954))
5355

5456
## v2.5.1
5557

Sources/MapboxNavigation/DayStyle.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ open class DayStyle: Style {
245245
FeedbackStyleView.appearance(whenContainedInInstancesOf: [FeedbackViewController.self]).backgroundColor = .white
246246
FeedbackCollectionView.appearance().backgroundColor = .white
247247
FeedbackCollectionView.appearance().cellColor = .black
248+
FeedbackSubtypeCollectionViewCell.appearance().normalCircleColor = .white
249+
FeedbackSubtypeCollectionViewCell.appearance().normalCircleOutlineColor = .darkText
250+
FeedbackSubtypeCollectionViewCell.appearance().selectedCircleColor = .systemBlue
248251
InstructionLabel.appearance().roadShieldBlackColor = .roadShieldBlackColor
249252
InstructionLabel.appearance().roadShieldBlueColor = .roadShieldBlueColor
250253
InstructionLabel.appearance().roadShieldGreenColor = .roadShieldGreenColor

Sources/MapboxNavigation/Feedback/FeedbackSubtypeCollectionViewCell.swift

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,44 @@ class FeedbackSubtypeCollectionViewCell: UICollectionViewCell {
2020
title.font = Constants.titleFont
2121
return title
2222
}()
23+
24+
@objc dynamic var showSelectedColor: Bool = false {
25+
didSet {
26+
if showSelectedColor {
27+
circleColor = selectedCircleColor
28+
circleOutlineColor = selectedCircleColor
29+
} else {
30+
circleColor = normalCircleColor
31+
circleOutlineColor = normalCircleOutlineColor
32+
}
33+
}
34+
}
35+
36+
@objc dynamic var selectedCircleColor: UIColor = .lightGray {
37+
didSet {
38+
if showSelectedColor {
39+
circleColor = selectedCircleColor
40+
circleOutlineColor = selectedCircleColor
41+
}
42+
}
43+
}
44+
45+
@objc dynamic var normalCircleColor: UIColor = .black {
46+
didSet {
47+
if !showSelectedColor {
48+
circleColor = normalCircleColor
49+
}
50+
}
51+
}
2352

53+
@objc dynamic var normalCircleOutlineColor: UIColor = .black {
54+
didSet {
55+
if !showSelectedColor {
56+
circleOutlineColor = normalCircleOutlineColor
57+
}
58+
}
59+
}
60+
2461
public var circleColor: UIColor = .black {
2562
didSet {
2663
circleView.backgroundColor = circleColor
@@ -110,7 +147,7 @@ class FeedbackSubtypeCollectionViewCell: UICollectionViewCell {
110147

111148
if #available(iOS 12.0, *),
112149
previousTraitCollection?.userInterfaceStyle != traitCollection.userInterfaceStyle {
113-
circleView.layer.borderColor = circleOutlineColor.cgColor
150+
circleOutlineColor = showSelectedColor ? normalCircleColor : selectedCircleColor
114151
}
115152
}
116153
}

Sources/MapboxNavigation/Feedback/FeedbackSubtypeViewController.swift

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ class FeedbackSubtypeViewController: FeedbackViewController {
55

66
var currentFeedbackType: FeedbackItemType?
77

8-
private let reportButtonContainer = UIView()
8+
private let reportButtonContainer = FeedbackStyleView()
99
private let reportButtonSeparator = UIView()
1010
private let reportButton = UIButton()
1111

1212
private var selectedItems = [FeedbackItem]()
13+
private var selectedPath = Set<IndexPath>()
1314

1415
/**
1516
Initialize a new FeedbackSubtypeViewController from a `NavigationEventsManager`.
@@ -77,40 +78,33 @@ class FeedbackSubtypeViewController: FeedbackViewController {
7778
}
7879
}
7980

81+
cell.showSelectedColor = selectedPath.contains(indexPath)
8082
return cell
8183
}
8284

8385
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
84-
85-
let cell = collectionView.cellForItem(at: indexPath) as! FeedbackSubtypeCollectionViewCell
86-
if #available(iOS 13.0, *) {
87-
cell.circleColor = .systemBlue
88-
} else {
89-
cell.circleColor = .lightGray
90-
}
91-
cell.circleOutlineColor = cell.circleColor
92-
93-
let item = sections[indexPath.row]
94-
selectedItems.append(item)
95-
96-
updateButtonTitle()
86+
guard let cell = collectionView.cellForItem(at: indexPath) as? FeedbackSubtypeCollectionViewCell else { return }
87+
toggleSelected(cell: cell, at: indexPath)
9788
}
9889

9990
func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) {
100-
let cell = collectionView.cellForItem(at: indexPath) as! FeedbackSubtypeCollectionViewCell
101-
if #available(iOS 13.0, *) {
102-
cell.circleColor = .systemBackground
103-
cell.circleOutlineColor = .label
91+
guard let cell = collectionView.cellForItem(at: indexPath) as? FeedbackSubtypeCollectionViewCell else { return }
92+
toggleSelected(cell: cell, at: indexPath)
93+
}
94+
95+
private func toggleSelected(cell: FeedbackSubtypeCollectionViewCell, at indexPath: IndexPath) {
96+
guard let item = sections[safe: indexPath.row] else { return }
97+
if selectedPath.contains(indexPath) {
98+
selectedItems.removeAll { existingItem -> Bool in
99+
return existingItem.type == item.type
100+
}
101+
selectedPath.remove(indexPath)
102+
cell.showSelectedColor = false
104103
} else {
105-
cell.circleColor = .white
106-
cell.circleOutlineColor = .darkText
104+
selectedItems.append(item)
105+
selectedPath.insert(indexPath)
106+
cell.showSelectedColor = true
107107
}
108-
109-
let item = sections[indexPath.row]
110-
selectedItems.removeAll { existingItem -> Bool in
111-
return existingItem.type == item.type
112-
}
113-
114108
updateButtonTitle()
115109
}
116110

@@ -169,7 +163,7 @@ class FeedbackSubtypeViewController: FeedbackViewController {
169163

170164
let reportButtonContainerLeading = reportButtonContainer.leadingAnchor.constraint(equalTo: view.leadingAnchor)
171165
let reportButtonContainerTrailing = reportButtonContainer.trailingAnchor.constraint(equalTo: view.trailingAnchor)
172-
let reportButtonContainerBottom = reportButtonContainer.bottomAnchor.constraint(equalTo: view.safeBottomAnchor)
166+
let reportButtonContainerBottom = reportButtonContainer.bottomAnchor.constraint(equalTo: view.bottomAnchor)
173167
let reportButtonContainerHeight = reportButtonContainer.heightAnchor.constraint(equalToConstant: 96)
174168

175169
let reportButtonSeparatorLeading = reportButtonSeparator.leadingAnchor.constraint(equalTo: reportButtonContainer.leadingAnchor)

Sources/MapboxNavigation/NightStyle.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ open class NightStyle: DayStyle {
113113
FeedbackStyleView.appearance(whenContainedInInstancesOf: [FeedbackViewController.self]).backgroundColor = .black
114114
FeedbackCollectionView.appearance().backgroundColor = .black
115115
FeedbackCollectionView.appearance().cellColor = .white
116+
FeedbackSubtypeCollectionViewCell.appearance().normalCircleColor = .black
117+
FeedbackSubtypeCollectionViewCell.appearance().normalCircleOutlineColor = .lightText
116118

117119
WayNameView.appearance().borderColor = #colorLiteral(red: 0.2802129388, green: 0.3988235593, blue: 0.5260632038, alpha: 1)
118120
WayNameLabel.appearance().roadShieldBlackColor = #colorLiteral(red: 0.08, green: 0.09, blue: 0.12, alpha: 1)

Sources/MapboxNavigation/StyleManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ open class StyleManager {
215215
if #available(iOS 13.0, *) {
216216
UIApplication.shared.connectedScenes.forEach {
217217
if let windowScene = $0 as? UIWindowScene,
218-
traitCollection?.userInterfaceIdiom == .phone {
218+
windowScene.traitCollection.userInterfaceIdiom == .phone {
219219
refreshAppearance(for: windowScene.windows)
220220
} else if let templateApplicationScene = $0 as? CPTemplateApplicationScene,
221221
traitCollection?.userInterfaceIdiom == .carPlay {

0 commit comments

Comments
 (0)