@@ -258,8 +258,8 @@ open class DayStyle: Style {
258258 NextInstructionLabel . appearance ( for: phoneTraitCollection, whenContainedInInstancesOf: [ NextBannerView . self] ) . textColorHighlighted = #colorLiteral( red: 1.0 , green: 1.0 , blue: 1.0 , alpha: 1.0 )
259259 NextInstructionLabel . appearance ( for: phoneTraitCollection, whenContainedInInstancesOf: [ NextBannerView . self] ) . normalFont = UIFont . systemFont ( ofSize: 14.0 ) . adjustedFont
260260
261- LaneView . appearance ( for: phoneTraitCollection) . primaryColor = . defaultLaneArrowPrimaryCarPlay
262- LaneView . appearance ( for: phoneTraitCollection) . secondaryColor = . defaultLaneArrowSecondaryCarPlay
261+ LaneView . appearance ( for: phoneTraitCollection) . primaryColor = . defaultLaneArrowPrimary
262+ LaneView . appearance ( for: phoneTraitCollection) . secondaryColor = . defaultLaneArrowSecondary
263263 LaneView . appearance ( for: phoneTraitCollection) . primaryColorHighlighted = . defaultLaneArrowPrimaryHighlighted
264264 LaneView . appearance ( for: phoneTraitCollection) . secondaryColorHighlighted = . defaultLaneArrowSecondaryHighlighted
265265 LaneView . appearance ( for: phoneTraitCollection, whenContainedInInstancesOf: [ LanesView . self] ) . primaryColor = . defaultLaneArrowPrimary
@@ -355,12 +355,6 @@ open class DayStyle: Style {
355355 SpeedLimitView . appearance ( for: carPlayTraitCollection) . textColor = #colorLiteral( red: 0 , green: 0 , blue: 0 , alpha: 1 )
356356 SpeedLimitView . appearance ( for: carPlayTraitCollection) . regulatoryBorderColor = #colorLiteral( red: 0.800 , green: 0 , blue: 0 , alpha: 1 )
357357
358- LaneView . appearance ( for: carPlayTraitCollection) . primaryColor = . defaultLaneArrowPrimaryCarPlay
359- LaneView . appearance ( for: carPlayTraitCollection) . secondaryColor = . defaultLaneArrowSecondaryCarPlay
360-
361- LaneView . appearance ( for: carPlayTraitCollection) . primaryColorHighlighted = . defaultLaneArrowPrimaryHighlighted
362- LaneView . appearance ( for: carPlayTraitCollection) . secondaryColorHighlighted = . defaultLaneArrowSecondaryHighlighted
363-
364358 ManeuverView . appearance ( for: carPlayTraitCollection) . backgroundColor = . clear
365359 ManeuverView . appearance ( for: carPlayTraitCollection) . primaryColorHighlighted = . defaultTurnArrowPrimaryHighlighted
366360 ManeuverView . appearance ( for: carPlayTraitCollection) . secondaryColorHighlighted = . defaultTurnArrowSecondaryHighlighted
@@ -369,34 +363,27 @@ open class DayStyle: Style {
369363 // `UITraitCollection`, which contains both `UIUserInterfaceIdiom` and `UIUserInterfaceStyle`.
370364 // If not, `UITraitCollection` will only contain `UIUserInterfaceIdiom`.
371365 if #available( iOS 12 . 0 , * ) {
372- let carPlayTraitCollection = UITraitCollection ( userInterfaceIdiom: . carPlay)
373-
374366 let carPlayLightTraitCollection = UITraitCollection ( traitsFrom: [
375367 carPlayTraitCollection,
376368 UITraitCollection ( userInterfaceStyle: . light)
377369 ] )
378- setCarPlayInstructionsStyling ( for: carPlayLightTraitCollection)
370+ applyCarPlayStyling ( for: carPlayLightTraitCollection)
379371
380372 let carPlayDarkTraitCollection = UITraitCollection ( traitsFrom: [
381373 carPlayTraitCollection,
382374 UITraitCollection ( userInterfaceStyle: . dark)
383375 ] )
384- setCarPlayInstructionsStyling ( for: carPlayDarkTraitCollection)
376+ applyCarPlayStyling ( for: carPlayDarkTraitCollection)
385377 } else {
386- setDefaultCarPlayInstructionsStyling ( )
378+ applyDefaultCarPlayStyling ( )
387379 }
388380 default :
389381 break
390382 }
391383 }
392384
393385 @available ( iOS 12 . 0 , * )
394- func setCarPlayInstructionsStyling( for traitCollection: UITraitCollection ? ) {
395- guard let traitCollection = traitCollection,
396- traitCollection. userInterfaceIdiom == . carPlay else { return }
397-
398- let carPlayTraitCollection = UITraitCollection ( userInterfaceIdiom: . carPlay)
399-
386+ func applyCarPlayStyling( for traitCollection: UITraitCollection ) {
400387 // On CarPlay, `ExitView` and `GenericRouteShield` styling depends on `UIUserInterfaceStyle`,
401388 // which was set on CarPlay external screen.
402389 // In case if it was set to `UIUserInterfaceStyle.light` white color will be used, otherwise
@@ -405,51 +392,55 @@ open class DayStyle: Style {
405392 // property of which returns incorrect value), this property has to be taken from callbacks
406393 // similar to: `UITraitEnvironment.traitCollectionDidChange(_:)`, or by creating `UITraitCollection`
407394 // directly.
395+ let defaultInstructionColor : UIColor
396+
397+ let defaultLaneViewPrimaryColor : UIColor
398+ let defaultLaneViewSecondaryColor : UIColor
399+
400+ let defaultLaneArrowPrimaryHighlightedColor : UIColor
401+ let defaultLaneArrowSecondaryHighlightedColor : UIColor
402+
408403 switch traitCollection. userInterfaceStyle {
409- case . dark :
410- let defaultColor = UIColor . white
404+ case . light , . unspecified :
405+ defaultInstructionColor = UIColor . black
411406
412- let carPlayDarkTraitCollection = UITraitCollection ( traitsFrom: [
413- carPlayTraitCollection,
414- UITraitCollection ( userInterfaceStyle: . dark)
415- ] )
407+ defaultLaneViewPrimaryColor = . defaultLaneArrowPrimary
408+ defaultLaneViewSecondaryColor = . defaultLaneArrowSecondary
416409
417- ExitView . appearance ( for: carPlayDarkTraitCollection) . backgroundColor = . clear
418- ExitView . appearance ( for: carPlayDarkTraitCollection) . borderWidth = 1.0
419- ExitView . appearance ( for: carPlayDarkTraitCollection) . cornerRadius = 5.0
420- ExitView . appearance ( for: carPlayDarkTraitCollection) . foregroundColor = defaultColor
421- ExitView . appearance ( for: carPlayDarkTraitCollection) . borderColor = defaultColor
422-
423- GenericRouteShield . appearance ( for: carPlayDarkTraitCollection) . backgroundColor = . clear
424- GenericRouteShield . appearance ( for: carPlayDarkTraitCollection) . borderWidth = 1.0
425- GenericRouteShield . appearance ( for: carPlayDarkTraitCollection) . cornerRadius = 5.0
426- GenericRouteShield . appearance ( for: carPlayDarkTraitCollection) . foregroundColor = defaultColor
427- GenericRouteShield . appearance ( for: carPlayDarkTraitCollection) . borderColor = defaultColor
428- case . light, . unspecified:
429- let defaultColor = UIColor . black
410+ defaultLaneArrowPrimaryHighlightedColor = . defaultLaneArrowPrimaryHighlighted
411+ defaultLaneArrowSecondaryHighlightedColor = . defaultLaneArrowSecondaryHighlighted
412+ case . dark:
413+ defaultInstructionColor = UIColor . white
430414
431- let carPlayLightTraitCollection = UITraitCollection ( traitsFrom: [
432- carPlayTraitCollection,
433- UITraitCollection ( userInterfaceStyle: . light)
434- ] )
415+ defaultLaneViewPrimaryColor = #colorLiteral( red: 1 , green: 1 , blue: 1 , alpha: 1 )
416+ defaultLaneViewSecondaryColor = #colorLiteral( red: 1 , green: 1 , blue: 1 , alpha: 0.3 )
435417
436- ExitView . appearance ( for: carPlayLightTraitCollection) . backgroundColor = . clear
437- ExitView . appearance ( for: carPlayLightTraitCollection) . borderWidth = 1.0
438- ExitView . appearance ( for: carPlayLightTraitCollection) . cornerRadius = 5.0
439- ExitView . appearance ( for: carPlayLightTraitCollection) . foregroundColor = defaultColor
440- ExitView . appearance ( for: carPlayLightTraitCollection) . borderColor = defaultColor
441-
442- GenericRouteShield . appearance ( for: carPlayLightTraitCollection) . backgroundColor = . clear
443- GenericRouteShield . appearance ( for: carPlayLightTraitCollection) . borderWidth = 1.0
444- GenericRouteShield . appearance ( for: carPlayLightTraitCollection) . cornerRadius = 5.0
445- GenericRouteShield . appearance ( for: carPlayLightTraitCollection) . foregroundColor = defaultColor
446- GenericRouteShield . appearance ( for: carPlayLightTraitCollection) . borderColor = defaultColor
418+ defaultLaneArrowPrimaryHighlightedColor = . defaultLaneArrowPrimaryHighlighted
419+ defaultLaneArrowSecondaryHighlightedColor = . defaultLaneArrowSecondaryHighlighted
447420 @unknown default :
448421 fatalError ( " Unknown userInterfaceStyle. " )
449422 }
423+
424+ ExitView . appearance ( for: traitCollection) . backgroundColor = . clear
425+ ExitView . appearance ( for: traitCollection) . borderWidth = 1.0
426+ ExitView . appearance ( for: traitCollection) . cornerRadius = 5.0
427+ ExitView . appearance ( for: traitCollection) . foregroundColor = defaultInstructionColor
428+ ExitView . appearance ( for: traitCollection) . borderColor = defaultInstructionColor
429+
430+ GenericRouteShield . appearance ( for: traitCollection) . backgroundColor = . clear
431+ GenericRouteShield . appearance ( for: traitCollection) . borderWidth = 1.0
432+ GenericRouteShield . appearance ( for: traitCollection) . cornerRadius = 5.0
433+ GenericRouteShield . appearance ( for: traitCollection) . foregroundColor = defaultInstructionColor
434+ GenericRouteShield . appearance ( for: traitCollection) . borderColor = defaultInstructionColor
435+
436+ LaneView . appearance ( for: traitCollection) . primaryColor = defaultLaneViewPrimaryColor
437+ LaneView . appearance ( for: traitCollection) . secondaryColor = defaultLaneViewSecondaryColor
438+
439+ LaneView . appearance ( for: traitCollection) . primaryColorHighlighted = defaultLaneArrowPrimaryHighlightedColor
440+ LaneView . appearance ( for: traitCollection) . secondaryColorHighlighted = defaultLaneArrowSecondaryHighlightedColor
450441 }
451442
452- func setDefaultCarPlayInstructionsStyling ( ) {
443+ func applyDefaultCarPlayStyling ( ) {
453444 let defaultColor = UIColor . black
454445 let carPlayTraitCollection = UITraitCollection ( userInterfaceIdiom: . carPlay)
455446
@@ -458,5 +449,11 @@ open class DayStyle: Style {
458449
459450 GenericRouteShield . appearance ( for: carPlayTraitCollection) . foregroundColor = defaultColor
460451 GenericRouteShield . appearance ( for: carPlayTraitCollection) . borderColor = defaultColor
452+
453+ LaneView . appearance ( for: carPlayTraitCollection) . primaryColor = . defaultLaneArrowPrimary
454+ LaneView . appearance ( for: carPlayTraitCollection) . secondaryColor = . defaultLaneArrowSecondary
455+
456+ LaneView . appearance ( for: carPlayTraitCollection) . primaryColorHighlighted = . defaultLaneArrowPrimaryHighlighted
457+ LaneView . appearance ( for: carPlayTraitCollection) . secondaryColorHighlighted = . defaultLaneArrowSecondaryHighlighted
461458 }
462459}
0 commit comments