@iternio/react-native-auto-play 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/hybrid/HybridAutoPlay.swift +2 -2
- package/ios/scenes/HeadUnitSceneDelegate.swift +14 -5
- package/ios/scenes/SceneStore.swift +2 -2
- package/ios/templates/AutoPlayTemplate.swift +5 -1
- package/ios/templates/GridTemplate.swift +7 -5
- package/ios/templates/InformationTemplate.swift +4 -4
- package/ios/templates/ListTemplate.swift +8 -4
- package/ios/templates/MapTemplate.swift +28 -9
- package/ios/templates/SearchTemplate.swift +6 -2
- package/package.json +1 -1
|
@@ -270,7 +270,7 @@ class HybridAutoPlay: HybridAutoPlaySpec {
|
|
|
270
270
|
templateId: templateId
|
|
271
271
|
)
|
|
272
272
|
|
|
273
|
-
guard
|
|
273
|
+
guard let template = template as? AutoPlayHeaderProviding
|
|
274
274
|
else {
|
|
275
275
|
throw AutoPlayError.invalidTemplateType(
|
|
276
276
|
"\(templateId) does not support header actions"
|
|
@@ -278,7 +278,7 @@ class HybridAutoPlay: HybridAutoPlaySpec {
|
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
template.barButtons = headerActions
|
|
281
|
-
|
|
281
|
+
template.invalidate()
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
284
|
}
|
|
@@ -54,18 +54,27 @@ class HeadUnitSceneDelegate: AutoPlayScene, CPTemplateApplicationSceneDelegate {
|
|
|
54
54
|
|
|
55
55
|
func templateApplicationScene(
|
|
56
56
|
_ templateApplicationScene: CPTemplateApplicationScene,
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
didDisconnect interfaceController: CPInterfaceController,
|
|
58
|
+
from window: CPWindow
|
|
59
59
|
) {
|
|
60
|
-
HybridAutoPlay.emit(event: .diddisconnect)
|
|
61
|
-
|
|
62
60
|
if let mapTemplate = try? templateStore.getTemplate(
|
|
63
61
|
templateId: SceneStore.rootModuleName
|
|
64
62
|
) as? MapTemplate {
|
|
65
63
|
mapTemplate.stopNavigation()
|
|
66
64
|
}
|
|
67
|
-
|
|
65
|
+
|
|
68
66
|
disconnect()
|
|
67
|
+
|
|
68
|
+
HybridAutoPlay.emit(event: .diddisconnect)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
func templateApplicationScene(
|
|
72
|
+
_ templateApplicationScene: CPTemplateApplicationScene,
|
|
73
|
+
didDisconnectInterfaceController interfaceController:
|
|
74
|
+
CPInterfaceController
|
|
75
|
+
) {
|
|
76
|
+
disconnect()
|
|
77
|
+
HybridAutoPlay.emit(event: .diddisconnect)
|
|
69
78
|
}
|
|
70
79
|
|
|
71
80
|
func sceneWillResignActive(_ scene: UIScene) {
|
|
@@ -84,7 +84,7 @@ class SceneStore {
|
|
|
84
84
|
return store[SceneStore.rootModuleName]
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
static func getRootTraitCollection() -> UITraitCollection {
|
|
88
|
-
return store[SceneStore.rootModuleName]
|
|
87
|
+
static func getRootTraitCollection() -> UITraitCollection? {
|
|
88
|
+
return store[SceneStore.rootModuleName]?.traitCollection
|
|
89
89
|
}
|
|
90
90
|
}
|
|
@@ -42,10 +42,14 @@ class AutoPlayHeaderProviding: AutoPlayTemplate {
|
|
|
42
42
|
func setBarButtons(template: CPTemplate, barButtons: [NitroAction]?) {
|
|
43
43
|
guard let template = template as? CPBarButtonProviding else { return }
|
|
44
44
|
|
|
45
|
+
guard let traitCollection = SceneStore.getRootTraitCollection() else {
|
|
46
|
+
return
|
|
47
|
+
}
|
|
48
|
+
|
|
45
49
|
if let headerActions = barButtons {
|
|
46
50
|
let parsedActions = Parser.parseHeaderActions(
|
|
47
51
|
headerActions: headerActions,
|
|
48
|
-
traitCollection:
|
|
52
|
+
traitCollection: traitCollection
|
|
49
53
|
)
|
|
50
54
|
|
|
51
55
|
template.backButton = parsedActions.backButton
|
|
@@ -24,17 +24,17 @@ class GridTemplate: AutoPlayHeaderProviding {
|
|
|
24
24
|
init(config: GridTemplateConfig) {
|
|
25
25
|
self.config = config
|
|
26
26
|
buttons = config.buttons
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
template = CPGridTemplate(
|
|
29
29
|
title: Parser.parseText(text: config.title),
|
|
30
30
|
gridButtons: GridTemplate.parseButtons(buttons: buttons),
|
|
31
31
|
id: config.id
|
|
32
32
|
)
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
super.init()
|
|
35
|
-
|
|
35
|
+
|
|
36
36
|
barButtons = config.headerActions
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
static func parseButtons(buttons: [NitroGridButton]) -> [CPGridButton] {
|
|
@@ -47,7 +47,9 @@ class GridTemplate: AutoPlayHeaderProviding {
|
|
|
47
47
|
gridButtonHeight = 44
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
let traitCollection = SceneStore.getRootTraitCollection()
|
|
50
|
+
guard let traitCollection = SceneStore.getRootTraitCollection() else {
|
|
51
|
+
return []
|
|
52
|
+
}
|
|
51
53
|
|
|
52
54
|
return buttons.compactMap { button in
|
|
53
55
|
var image: UIImage?
|
|
@@ -23,7 +23,7 @@ class InformationTemplate: AutoPlayHeaderProviding {
|
|
|
23
23
|
|
|
24
24
|
init(config: InformationTemplateConfig) {
|
|
25
25
|
self.config = config
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
section = config.section
|
|
28
28
|
|
|
29
29
|
template = CPInformationTemplate(
|
|
@@ -33,9 +33,9 @@ class InformationTemplate: AutoPlayHeaderProviding {
|
|
|
33
33
|
actions: Parser.parseInformationActions(actions: config.actions),
|
|
34
34
|
id: config.id
|
|
35
35
|
)
|
|
36
|
-
|
|
37
|
-
super.init()
|
|
38
|
-
|
|
36
|
+
|
|
37
|
+
super.init()
|
|
38
|
+
|
|
39
39
|
barButtons = config.headerActions
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -23,7 +23,7 @@ class ListTemplate: AutoPlayHeaderProviding {
|
|
|
23
23
|
|
|
24
24
|
init(config: ListTemplateConfig) {
|
|
25
25
|
self.config = config
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
sections = config.sections
|
|
28
28
|
|
|
29
29
|
template = CPListTemplate(
|
|
@@ -32,9 +32,9 @@ class ListTemplate: AutoPlayHeaderProviding {
|
|
|
32
32
|
assistantCellConfiguration: nil,
|
|
33
33
|
id: config.id
|
|
34
34
|
)
|
|
35
|
-
|
|
35
|
+
|
|
36
36
|
super.init()
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
barButtons = config.headerActions
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -42,11 +42,15 @@ class ListTemplate: AutoPlayHeaderProviding {
|
|
|
42
42
|
override func _invalidate() {
|
|
43
43
|
setBarButtons(template: template, barButtons: barButtons)
|
|
44
44
|
|
|
45
|
+
guard let traitCollection = SceneStore.getRootTraitCollection() else {
|
|
46
|
+
return
|
|
47
|
+
}
|
|
48
|
+
|
|
45
49
|
template.updateSections(
|
|
46
50
|
Parser.parseSections(
|
|
47
51
|
sections: sections,
|
|
48
52
|
updateSection: self.updateSection(section:sectionIndex:),
|
|
49
|
-
traitCollection:
|
|
53
|
+
traitCollection: traitCollection
|
|
50
54
|
)
|
|
51
55
|
)
|
|
52
56
|
}
|
|
@@ -45,10 +45,10 @@ class MapTemplate: AutoPlayHeaderProviding,
|
|
|
45
45
|
|
|
46
46
|
init(config: MapTemplateConfig) {
|
|
47
47
|
self.config = config
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
mapButtons = config.mapButtons
|
|
50
50
|
visibleTravelEstimate = config.visibleTravelEstimate
|
|
51
|
-
|
|
51
|
+
|
|
52
52
|
template = CPMapTemplate(id: config.id)
|
|
53
53
|
|
|
54
54
|
if let initialProperties = SceneStore.getRootScene()?.initialProperties,
|
|
@@ -81,12 +81,16 @@ class MapTemplate: AutoPlayHeaderProviding,
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
func parseMapButtons(mapButtons: [NitroMapButton]) -> [CPMapButton] {
|
|
84
|
+
guard let traitCollection = SceneStore.getRootTraitCollection() else {
|
|
85
|
+
return []
|
|
86
|
+
}
|
|
87
|
+
|
|
84
88
|
return mapButtons.map { button in
|
|
85
89
|
if let glyphImage = button.image.glyphImage,
|
|
86
90
|
let icon = SymbolFont.imageFromNitroImage(
|
|
87
91
|
image: glyphImage,
|
|
88
92
|
size: CPButtonMaximumImageSize.height,
|
|
89
|
-
traitCollection:
|
|
93
|
+
traitCollection: traitCollection
|
|
90
94
|
)
|
|
91
95
|
{
|
|
92
96
|
return CPMapButton(image: icon) { _ in
|
|
@@ -100,7 +104,7 @@ class MapTemplate: AutoPlayHeaderProviding,
|
|
|
100
104
|
if let assetImage = button.image.assetImage,
|
|
101
105
|
let icon = Parser.parseAssetImage(
|
|
102
106
|
assetImage: assetImage,
|
|
103
|
-
traitCollection:
|
|
107
|
+
traitCollection: traitCollection
|
|
104
108
|
)
|
|
105
109
|
{
|
|
106
110
|
return CPMapButton(image: icon) { _ in
|
|
@@ -180,7 +184,10 @@ class MapTemplate: AutoPlayHeaderProviding,
|
|
|
180
184
|
|
|
181
185
|
@MainActor
|
|
182
186
|
override func traitCollectionDidChange() {
|
|
183
|
-
let traitCollection = SceneStore.getRootTraitCollection()
|
|
187
|
+
guard let traitCollection = SceneStore.getRootTraitCollection() else {
|
|
188
|
+
return
|
|
189
|
+
}
|
|
190
|
+
|
|
184
191
|
let isDark = traitCollection.userInterfaceStyle == .dark
|
|
185
192
|
|
|
186
193
|
config.onAppearanceDidChange?(
|
|
@@ -354,6 +361,10 @@ class MapTemplate: AutoPlayHeaderProviding,
|
|
|
354
361
|
return
|
|
355
362
|
}
|
|
356
363
|
|
|
364
|
+
guard let traitCollection = SceneStore.getRootTraitCollection() else {
|
|
365
|
+
return
|
|
366
|
+
}
|
|
367
|
+
|
|
357
368
|
guard let title = Parser.parseText(text: alertConfig.title) else { return }
|
|
358
369
|
let subtitle = alertConfig.subtitle.flatMap { subtitle in
|
|
359
370
|
[Parser.parseText(text: subtitle)].compactMap { $0 }
|
|
@@ -361,7 +372,7 @@ class MapTemplate: AutoPlayHeaderProviding,
|
|
|
361
372
|
|
|
362
373
|
let image = Parser.parseNitroImage(
|
|
363
374
|
image: alertConfig.image,
|
|
364
|
-
traitCollection:
|
|
375
|
+
traitCollection: traitCollection
|
|
365
376
|
)
|
|
366
377
|
|
|
367
378
|
let style = Parser.parseActionAlertStyle(
|
|
@@ -599,6 +610,10 @@ class MapTemplate: AutoPlayHeaderProviding,
|
|
|
599
610
|
func updateManeuvers(messageManeuver: NitroMessageManeuver) {
|
|
600
611
|
guard let navigationSession = navigationSession else { return }
|
|
601
612
|
|
|
613
|
+
guard let traitCollection = SceneStore.getRootTraitCollection() else {
|
|
614
|
+
return
|
|
615
|
+
}
|
|
616
|
+
|
|
602
617
|
let color = messageManeuver.cardBackgroundColor
|
|
603
618
|
let cardBackgroundColor = Parser.parseColor(color: color)
|
|
604
619
|
|
|
@@ -615,7 +630,7 @@ class MapTemplate: AutoPlayHeaderProviding,
|
|
|
615
630
|
|
|
616
631
|
if let symbolImage = Parser.parseNitroImage(
|
|
617
632
|
image: messageManeuver.image,
|
|
618
|
-
traitCollection:
|
|
633
|
+
traitCollection: traitCollection
|
|
619
634
|
) {
|
|
620
635
|
maneuver.symbolImage = symbolImage
|
|
621
636
|
}
|
|
@@ -635,6 +650,10 @@ class MapTemplate: AutoPlayHeaderProviding,
|
|
|
635
650
|
return
|
|
636
651
|
}
|
|
637
652
|
|
|
653
|
+
guard let traitCollection = SceneStore.getRootTraitCollection() else {
|
|
654
|
+
return
|
|
655
|
+
}
|
|
656
|
+
|
|
638
657
|
if #unavailable(iOS 15.4),
|
|
639
658
|
let color = maneuvers.first?.cardBackgroundColor
|
|
640
659
|
{
|
|
@@ -674,7 +693,7 @@ class MapTemplate: AutoPlayHeaderProviding,
|
|
|
674
693
|
|
|
675
694
|
let maneuver = Parser.parseManeuver(
|
|
676
695
|
nitroManeuver: nitroManeuver,
|
|
677
|
-
traitCollection:
|
|
696
|
+
traitCollection: traitCollection
|
|
678
697
|
)
|
|
679
698
|
upcomingManeuvers.append(maneuver)
|
|
680
699
|
}
|
|
@@ -686,7 +705,7 @@ class MapTemplate: AutoPlayHeaderProviding,
|
|
|
686
705
|
// CarPlay has a limitation of 120x18 for the symbolImage on secondaryManeuver that shows lanes only
|
|
687
706
|
let secondarySymbolImage = Parser.imageFromLanes(
|
|
688
707
|
laneImages: laneImages.prefix(Int(120 / 18)),
|
|
689
|
-
traitCollection:
|
|
708
|
+
traitCollection: traitCollection
|
|
690
709
|
)
|
|
691
710
|
|
|
692
711
|
let secondaryManeuver = CPManeuver(
|
|
@@ -28,7 +28,7 @@ class SearchTemplate: AutoPlayTemplate, CPSearchTemplateDelegate {
|
|
|
28
28
|
init(config: SearchTemplateConfig) {
|
|
29
29
|
self.config = config
|
|
30
30
|
results = config.results
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
template = CPSearchTemplate(id: config.id)
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -49,9 +49,13 @@ class SearchTemplate: AutoPlayTemplate, CPSearchTemplateDelegate {
|
|
|
49
49
|
return
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
guard let traitCollection = SceneStore.getRootTraitCollection() else {
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
|
|
52
56
|
let listItems = Parser.parseSearchResults(
|
|
53
57
|
section: results,
|
|
54
|
-
traitCollection:
|
|
58
|
+
traitCollection: traitCollection
|
|
55
59
|
)
|
|
56
60
|
completionHandler(listItems)
|
|
57
61
|
|