[ios] Added custom icons to routing options

Signed-off-by: Yannik Bloscheck <git@yannikbloscheck.com>
This commit is contained in:
Yannik Bloscheck
2025-10-19 11:06:01 +02:00
committed by Yannik Bloscheck
parent 8b4eab3444
commit 31dcb954b1
65 changed files with 2554 additions and 733 deletions

View File

@@ -12,17 +12,18 @@ final class SettingsTemplateBuilder {
private class func buildGridButtons() -> [CPGridButton] {
let options = RoutingOptions()
return [createUnpavedButton(options: options),
createTollButton(options: options),
createFerryButton(options: options),
return [createTollButton(options: options),
createUnpavedButton(options: options),
createPavedButton(options: options),
createMotorwayButton(options: options),
createFerryButton(options: options),
createStepsButton(options: options),
createSpeedcamButton()]
}
// MARK: - CPGridButton builders
private class func createTollButton(options: RoutingOptions) -> CPGridButton {
var tollIconName = "options.tolls"
var tollIconName = "tolls.circle"
if options.avoidToll { tollIconName += ".slash" }
let configuration = UIImage.SymbolConfiguration(textStyle: .title1)
var image = UIImage(named: tollIconName, in: nil, with: configuration)!
@@ -40,7 +41,7 @@ final class SettingsTemplateBuilder {
}
private class func createUnpavedButton(options: RoutingOptions) -> CPGridButton {
var unpavedIconName = "options.unpaved"
var unpavedIconName = "unpaved.circle"
if options.avoidDirty && !options.avoidPaved { unpavedIconName += ".slash" }
let configuration = UIImage.SymbolConfiguration(textStyle: .title1)
var image = UIImage(named: unpavedIconName, in: nil, with: configuration)!
@@ -62,7 +63,7 @@ final class SettingsTemplateBuilder {
}
private class func createPavedButton(options: RoutingOptions) -> CPGridButton {
var pavedIconName = "options.paved"
var pavedIconName = "paved.circle"
if options.avoidPaved && !options.avoidDirty { pavedIconName += ".slash" }
let configuration = UIImage.SymbolConfiguration(textStyle: .title1)
var image = UIImage(named: pavedIconName, in: nil, with: configuration)!
@@ -82,9 +83,27 @@ final class SettingsTemplateBuilder {
pavedButton.isEnabled = !options.avoidDirty
return pavedButton
}
private class func createMotorwayButton(options: RoutingOptions) -> CPGridButton {
var motorwayIconName = "motorways.circle"
if options.avoidMotorway { motorwayIconName += ".slash" }
let configuration = UIImage.SymbolConfiguration(textStyle: .title1)
var image = UIImage(named: motorwayIconName, in: nil, with: configuration)!
if #unavailable(iOS 26) {
image = image.withTintColor(.white, renderingMode: .alwaysTemplate)
image = UIImage(data: image.pngData()!)!.withRenderingMode(.alwaysTemplate)
}
let motorwayButton = CPGridButton(titleVariants: [L("avoid_motorways")], image: image) { _ in
options.avoidMotorway = !options.avoidMotorway
options.save()
CarPlayService.shared.updateRouteAfterChangingSettings()
CarPlayService.shared.popTemplate(animated: true)
}
return motorwayButton
}
private class func createFerryButton(options: RoutingOptions) -> CPGridButton {
var ferryIconName = "options.ferries"
var ferryIconName = "ferries.circle"
if options.avoidFerry { ferryIconName += ".slash" }
let configuration = UIImage.SymbolConfiguration(textStyle: .title1)
var image = UIImage(named: ferryIconName, in: nil, with: configuration)!
@@ -102,7 +121,7 @@ final class SettingsTemplateBuilder {
}
private class func createStepsButton(options: RoutingOptions) -> CPGridButton {
var stepsIconName = "options.steps"
var stepsIconName = "steps.circle"
if options.avoidSteps { stepsIconName += ".slash" }
let configuration = UIImage.SymbolConfiguration(textStyle: .title1)
var image = UIImage(named: stepsIconName, in: nil, with: configuration)!
@@ -120,7 +139,7 @@ final class SettingsTemplateBuilder {
}
private class func createSpeedcamButton() -> CPGridButton {
var speedcamIconName = "options.speedcamera"
var speedcamIconName = "speedcamera"
let isSpeedCamActivated = CarPlayService.shared.isSpeedCamActivated
if !isSpeedCamActivated { speedcamIconName += ".slash" }
let configuration = UIImage.SymbolConfiguration(textStyle: .title1)