[ios] [carplay] fix bug when light estimates view appears on dark maps #6424

Merged
root merged 1 commit from ios/carplay-instructions-colors-fix into master 2023-10-30 12:54:42 +00:00
2 changed files with 14 additions and 14 deletions

View file

@ -37,13 +37,19 @@ final class CarPlayService: NSObject {
self.window = window
self.interfaceController = interfaceController
self.interfaceController?.delegate = self
sessionConfiguration = CPSessionConfiguration(delegate: self)
let configuration = CPSessionConfiguration(delegate: self)
sessionConfiguration = configuration
biodranik commented 2023-10-30 12:26:08 +00:00 (Migrated from github.com)
Review

Is this intermediate variable really necessary?

Is this intermediate variable really necessary?
Review

Nope. But it is clearer to use a switch-case for the enum contentStyle and avoid if-elses...

Probably this will be more clear:

sessionConfiguration = CPSessionConfiguration(delegate: self)
    // Try to use the CarPlay unit's interface style.
    if #available(iOS 13.0, *), let contentStyle = sessionConfiguration?.contentStyle  {
      switch contentStyle {
      case .light:

Nope. But it is clearer to use a switch-case for the enum `contentStyle` and avoid if-elses... Probably this will be more clear: ```swift sessionConfiguration = CPSessionConfiguration(delegate: self) // Try to use the CarPlay unit's interface style. if #available(iOS 13.0, *), let contentStyle = sessionConfiguration?.contentStyle { switch contentStyle { case .light: ```
biodranik commented 2023-10-30 12:54:25 +00:00 (Migrated from github.com)
Review

I see, these optionals sometimes make development more complex :) LGTM

I see, these optionals sometimes make development more complex :) LGTM
// Try to use the CarPlay unit's interface style.
if #available(iOS 13.0, *) {
if sessionConfiguration?.contentStyle == .light {
switch configuration.contentStyle {
case .light:
rootTemplateStyle = .light
window.overrideUserInterfaceStyle = .light
} else {
case .dark:
rootTemplateStyle = .dark
window.overrideUserInterfaceStyle = .dark
default:
rootTemplateStyle = window.overrideUserInterfaceStyle == .light ? .light : .dark
}
}
searchService = CarPlaySearchService()
@ -98,15 +104,9 @@ final class CarPlayService: NSObject {
return .unspecified
}
private var rootTemplateStyle: CPTripEstimateStyle {
get {
if #available(iOS 13.0, *) {
return sessionConfiguration?.contentStyle == .light ? .light : .dark
}
return .dark
}
set {
(interfaceController?.rootTemplate as? CPMapTemplate)?.tripEstimateStyle = newValue
private var rootTemplateStyle: CPTripEstimateStyle = .light {
didSet {
(interfaceController?.rootTemplate as? CPMapTemplate)?.tripEstimateStyle = rootTemplateStyle
}
}

View file

@ -409,11 +409,11 @@ using namespace osm_auth_ios;
- (void)application:(UIApplication *)application
didConnectCarInterfaceController:(CPInterfaceController *)interfaceController
toWindow:(CPWindow *)window API_AVAILABLE(ios(12.0)) {
[self.carplayService setupWithWindow:window interfaceController:interfaceController];
toWindow:(CPWindow *)window API_AVAILABLE(ios(12.0)) {
if (@available(iOS 13.0, *)) {
window.overrideUserInterfaceStyle = UIUserInterfaceStyleUnspecified;
}
[self.carplayService setupWithWindow:window interfaceController:interfaceController];
[self updateAppearanceFromWindow:self.window toWindow:window isCarplayActivated:YES];
}