@iternio/react-native-auto-play 0.0.9 → 0.0.11
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/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAutoPlay.kt +10 -9
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridGridTemplate.kt +6 -3
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridInformationTemplate.kt +7 -5
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridListTemplate.kt +6 -3
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridMapTemplate.kt +6 -3
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridSearchTemplate.kt +6 -3
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/template/MapTemplate.kt +10 -6
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/template/Parser.kt +3 -0
- package/ios/hybrid/HybridAutoPlay.swift +48 -16
- package/ios/hybrid/HybridGridTemplate.swift +17 -10
- package/ios/hybrid/HybridInformationTemplate.swift +18 -10
- package/ios/hybrid/HybridListTemplate.swift +18 -10
- package/ios/hybrid/HybridMapTemplate.swift +26 -11
- package/ios/hybrid/HybridMessageTemplate.swift +4 -7
- package/ios/hybrid/HybridSearchTemplate.swift +20 -10
- package/ios/scenes/AutoPlayInterfaceController.swift +11 -14
- package/ios/scenes/AutoPlayScene.swift +1 -1
- package/ios/scenes/HeadUnitSceneDelegate.swift +5 -4
- package/ios/templates/AutoPlayTemplate.swift +3 -2
- package/ios/templates/GridTemplate.swift +1 -2
- package/ios/templates/InformationTemplate.swift +1 -2
- package/ios/templates/ListTemplate.swift +3 -2
- package/ios/templates/MapTemplate.swift +39 -33
- package/ios/templates/SearchTemplate.swift +11 -7
- package/ios/templates/TemplateStore.swift +8 -8
- package/ios/utils/RootModule.swift +13 -40
- package/lib/specs/AutoPlay.nitro.d.ts +1 -1
- package/lib/specs/GridTemplate.nitro.d.ts +1 -1
- package/lib/specs/InformationTemplate.nitro.d.ts +1 -1
- package/lib/specs/ListTemplate.nitro.d.ts +1 -1
- package/lib/specs/MapTemplate.nitro.d.ts +1 -1
- package/lib/specs/SearchTemplate.nitro.d.ts +1 -1
- package/lib/templates/GridTemplate.d.ts +1 -1
- package/lib/templates/GridTemplate.js +1 -1
- package/lib/templates/InformationTemplate.d.ts +1 -1
- package/lib/templates/InformationTemplate.js +1 -1
- package/lib/templates/ListTemplate.d.ts +1 -1
- package/lib/templates/ListTemplate.js +1 -1
- package/lib/templates/MapTemplate.d.ts +2 -2
- package/lib/templates/MapTemplate.js +6 -2
- package/lib/templates/SearchTemplate.d.ts +1 -1
- package/lib/templates/SearchTemplate.js +1 -1
- package/lib/templates/Template.d.ts +1 -1
- package/lib/templates/Template.js +1 -1
- package/lib/types/Maneuver.d.ts +5 -2
- package/lib/utils/NitroManeuver.d.ts +4 -1
- package/nitrogen/generated/android/c++/JHybridAutoPlaySpec.cpp +14 -3
- package/nitrogen/generated/android/c++/JHybridAutoPlaySpec.hpp +1 -1
- package/nitrogen/generated/android/c++/JHybridGridTemplateSpec.cpp +16 -3
- package/nitrogen/generated/android/c++/JHybridGridTemplateSpec.hpp +1 -1
- package/nitrogen/generated/android/c++/JHybridInformationTemplateSpec.cpp +16 -3
- package/nitrogen/generated/android/c++/JHybridInformationTemplateSpec.hpp +1 -1
- package/nitrogen/generated/android/c++/JHybridListTemplateSpec.cpp +16 -3
- package/nitrogen/generated/android/c++/JHybridListTemplateSpec.hpp +1 -1
- package/nitrogen/generated/android/c++/JHybridMapTemplateSpec.cpp +21 -4
- package/nitrogen/generated/android/c++/JHybridMapTemplateSpec.hpp +2 -2
- package/nitrogen/generated/android/c++/JHybridSearchTemplateSpec.cpp +16 -3
- package/nitrogen/generated/android/c++/JHybridSearchTemplateSpec.hpp +1 -1
- package/nitrogen/generated/android/c++/JNitroLoadingManeuver.hpp +57 -0
- package/nitrogen/generated/android/c++/JNitroManeuver.cpp +6 -2
- package/nitrogen/generated/android/c++/JNitroManeuver.hpp +19 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAutoPlaySpec.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridGridTemplateSpec.kt +2 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridInformationTemplateSpec.kt +2 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridListTemplateSpec.kt +2 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridMapTemplateSpec.kt +2 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridSearchTemplateSpec.kt +2 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroLoadingManeuver.kt +38 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroManeuver.kt +15 -2
- package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Bridge.hpp +28 -19
- package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Umbrella.hpp +3 -0
- package/nitrogen/generated/ios/c++/HybridAutoPlaySpecSwift.hpp +3 -1
- package/nitrogen/generated/ios/c++/HybridGridTemplateSpecSwift.hpp +4 -1
- package/nitrogen/generated/ios/c++/HybridInformationTemplateSpecSwift.hpp +4 -1
- package/nitrogen/generated/ios/c++/HybridListTemplateSpecSwift.hpp +4 -1
- package/nitrogen/generated/ios/c++/HybridMapTemplateSpecSwift.hpp +8 -2
- package/nitrogen/generated/ios/c++/HybridSearchTemplateSpecSwift.hpp +4 -1
- package/nitrogen/generated/ios/swift/HybridAutoPlaySpec.swift +1 -1
- package/nitrogen/generated/ios/swift/HybridAutoPlaySpec_cxx.swift +12 -4
- package/nitrogen/generated/ios/swift/HybridGridTemplateSpec.swift +2 -1
- package/nitrogen/generated/ios/swift/HybridGridTemplateSpec_cxx.swift +13 -4
- package/nitrogen/generated/ios/swift/HybridInformationTemplateSpec.swift +2 -1
- package/nitrogen/generated/ios/swift/HybridInformationTemplateSpec_cxx.swift +13 -4
- package/nitrogen/generated/ios/swift/HybridListTemplateSpec.swift +2 -1
- package/nitrogen/generated/ios/swift/HybridListTemplateSpec_cxx.swift +13 -4
- package/nitrogen/generated/ios/swift/HybridMapTemplateSpec.swift +2 -1
- package/nitrogen/generated/ios/swift/HybridMapTemplateSpec_cxx.swift +17 -5
- package/nitrogen/generated/ios/swift/HybridSearchTemplateSpec.swift +2 -1
- package/nitrogen/generated/ios/swift/HybridSearchTemplateSpec_cxx.swift +13 -4
- package/nitrogen/generated/ios/swift/NitroLoadingManeuver.swift +35 -0
- package/nitrogen/generated/ios/swift/NitroManeuver.swift +2 -1
- package/nitrogen/generated/shared/c++/HybridAutoPlaySpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridGridTemplateSpec.hpp +2 -1
- package/nitrogen/generated/shared/c++/HybridInformationTemplateSpec.hpp +2 -1
- package/nitrogen/generated/shared/c++/HybridListTemplateSpec.hpp +2 -1
- package/nitrogen/generated/shared/c++/HybridMapTemplateSpec.hpp +6 -2
- package/nitrogen/generated/shared/c++/HybridSearchTemplateSpec.hpp +2 -1
- package/nitrogen/generated/shared/c++/NitroLoadingManeuver.hpp +75 -0
- package/package.json +1 -1
- package/src/specs/AutoPlay.nitro.ts +1 -1
- package/src/specs/GridTemplate.nitro.ts +1 -1
- package/src/specs/InformationTemplate.nitro.ts +1 -1
- package/src/specs/ListTemplate.nitro.ts +1 -1
- package/src/specs/MapTemplate.nitro.ts +1 -1
- package/src/specs/SearchTemplate.nitro.ts +4 -1
- package/src/templates/GridTemplate.ts +1 -1
- package/src/templates/InformationTemplate.ts +1 -1
- package/src/templates/ListTemplate.ts +1 -1
- package/src/templates/MapTemplate.ts +7 -2
- package/src/templates/SearchTemplate.ts +1 -1
- package/src/templates/Template.ts +1 -1
- package/src/types/Maneuver.ts +8 -1
- package/src/utils/NitroManeuver.ts +8 -1
|
@@ -20,8 +20,7 @@ class HeadUnitSceneDelegate: AutoPlayScene, CPTemplateApplicationSceneDelegate {
|
|
|
20
20
|
) {
|
|
21
21
|
self.window = window
|
|
22
22
|
self.interfaceController = AutoPlayInterfaceController(
|
|
23
|
-
interfaceController: interfaceController
|
|
24
|
-
templateStore: self.templateStore
|
|
23
|
+
interfaceController: interfaceController
|
|
25
24
|
)
|
|
26
25
|
|
|
27
26
|
let props: [String: Any] = [
|
|
@@ -45,8 +44,10 @@ class HeadUnitSceneDelegate: AutoPlayScene, CPTemplateApplicationSceneDelegate {
|
|
|
45
44
|
) {
|
|
46
45
|
HybridAutoPlay.emit(event: .diddisconnect)
|
|
47
46
|
disconnect()
|
|
48
|
-
|
|
49
|
-
let mapTemplate =
|
|
47
|
+
|
|
48
|
+
let mapTemplate =
|
|
49
|
+
TemplateStore.getTemplate(templateId: SceneStore.rootModuleName)
|
|
50
|
+
as? MapTemplate
|
|
50
51
|
mapTemplate?.stopNavigation()
|
|
51
52
|
}
|
|
52
53
|
|
|
@@ -10,7 +10,7 @@ import CarPlay
|
|
|
10
10
|
protocol AutoPlayTemplate {
|
|
11
11
|
var autoDismissMs: Double? { get }
|
|
12
12
|
|
|
13
|
-
func invalidate()
|
|
13
|
+
@MainActor func invalidate()
|
|
14
14
|
func onWillAppear(animated: Bool)
|
|
15
15
|
func onDidAppear(animated: Bool)
|
|
16
16
|
func onWillDisappear(animated: Bool)
|
|
@@ -27,9 +27,10 @@ extension AutoPlayTemplate {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
protocol AutoPlayHeaderProviding {
|
|
30
|
-
var barButtons: [NitroAction]? { get set }
|
|
30
|
+
@MainActor var barButtons: [NitroAction]? { get set }
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
@MainActor
|
|
33
34
|
func setBarButtons(template: CPTemplate, barButtons: [NitroAction]?) {
|
|
34
35
|
guard let template = template as? CPBarButtonProviding else { return }
|
|
35
36
|
|
|
@@ -37,8 +37,6 @@ class GridTemplate: AutoPlayTemplate, AutoPlayHeaderProviding {
|
|
|
37
37
|
gridButtons: GridTemplate.parseButtons(buttons: config.buttons),
|
|
38
38
|
id: config.id
|
|
39
39
|
)
|
|
40
|
-
|
|
41
|
-
setBarButtons(template: template, barButtons: barButtons)
|
|
42
40
|
}
|
|
43
41
|
|
|
44
42
|
static func parseButtons(buttons: [NitroGridButton]) -> [CPGridButton] {
|
|
@@ -104,6 +102,7 @@ class GridTemplate: AutoPlayTemplate, AutoPlayHeaderProviding {
|
|
|
104
102
|
config.onPopped?()
|
|
105
103
|
}
|
|
106
104
|
|
|
105
|
+
@MainActor
|
|
107
106
|
func updateButtons(buttons: [NitroGridButton]) {
|
|
108
107
|
config.buttons = buttons
|
|
109
108
|
invalidate()
|
|
@@ -39,8 +39,6 @@ class InformationTemplate: AutoPlayTemplate, AutoPlayHeaderProviding {
|
|
|
39
39
|
actions: Parser.parseInformationActions(actions: config.actions),
|
|
40
40
|
id: config.id
|
|
41
41
|
)
|
|
42
|
-
|
|
43
|
-
setBarButtons(template: template, barButtons: barButtons)
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
func invalidate() {
|
|
@@ -68,6 +66,7 @@ class InformationTemplate: AutoPlayTemplate, AutoPlayHeaderProviding {
|
|
|
68
66
|
config.onPopped?()
|
|
69
67
|
}
|
|
70
68
|
|
|
69
|
+
@MainActor
|
|
71
70
|
func updateSection(section: NitroSection) {
|
|
72
71
|
config.section = section
|
|
73
72
|
invalidate()
|
|
@@ -38,10 +38,9 @@ class ListTemplate: AutoPlayTemplate, AutoPlayHeaderProviding {
|
|
|
38
38
|
assistantCellConfiguration: nil,
|
|
39
39
|
id: config.id
|
|
40
40
|
)
|
|
41
|
-
|
|
42
|
-
invalidate()
|
|
43
41
|
}
|
|
44
42
|
|
|
43
|
+
@MainActor
|
|
45
44
|
func invalidate() {
|
|
46
45
|
setBarButtons(template: template, barButtons: barButtons)
|
|
47
46
|
|
|
@@ -74,11 +73,13 @@ class ListTemplate: AutoPlayTemplate, AutoPlayHeaderProviding {
|
|
|
74
73
|
config.onPopped?()
|
|
75
74
|
}
|
|
76
75
|
|
|
76
|
+
@MainActor
|
|
77
77
|
private func updateSection(section: NitroSection, sectionIndex: Int) {
|
|
78
78
|
config.sections?[sectionIndex] = section
|
|
79
79
|
invalidate()
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
@MainActor
|
|
82
83
|
func updateSections(sections: [NitroSection]?) {
|
|
83
84
|
config.sections = sections
|
|
84
85
|
invalidate()
|
|
@@ -25,7 +25,7 @@ class MapTemplate: NSObject, AutoPlayTemplate, AutoPlayHeaderProviding,
|
|
|
25
25
|
}
|
|
26
26
|
set {
|
|
27
27
|
config.headerActions = newValue
|
|
28
|
-
|
|
28
|
+
invalidate()
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -42,14 +42,7 @@ class MapTemplate: NSObject, AutoPlayTemplate, AutoPlayHeaderProviding,
|
|
|
42
42
|
var navigationSession: CPNavigationSession?
|
|
43
43
|
var navigationAlert: NavigationAlertWrapper?
|
|
44
44
|
|
|
45
|
-
var tripSelectorVisible = false
|
|
46
|
-
didSet {
|
|
47
|
-
if !tripSelectorVisible && oldValue {
|
|
48
|
-
// this makes sure the latest config updates are applied when the trip selector is gone again
|
|
49
|
-
invalidate()
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
45
|
+
var tripSelectorVisible = false
|
|
53
46
|
|
|
54
47
|
init(config: MapTemplateConfig) {
|
|
55
48
|
self.config = config
|
|
@@ -71,7 +64,6 @@ class MapTemplate: NSObject, AutoPlayTemplate, AutoPlayHeaderProviding,
|
|
|
71
64
|
super.init()
|
|
72
65
|
|
|
73
66
|
template.mapDelegate = self
|
|
74
|
-
invalidate()
|
|
75
67
|
}
|
|
76
68
|
|
|
77
69
|
func onPanButtonPress() {
|
|
@@ -125,12 +117,13 @@ class MapTemplate: NSObject, AutoPlayTemplate, AutoPlayHeaderProviding,
|
|
|
125
117
|
|
|
126
118
|
}
|
|
127
119
|
|
|
120
|
+
@MainActor
|
|
128
121
|
func invalidate() {
|
|
129
122
|
if tripSelectorVisible {
|
|
130
123
|
// ignore invalidate calls to not break the trip selectors back button
|
|
131
124
|
return
|
|
132
125
|
}
|
|
133
|
-
|
|
126
|
+
|
|
134
127
|
if template.isPanningInterfaceVisible {
|
|
135
128
|
// while panning interface is shown we only provide a back button on the header
|
|
136
129
|
// and all map buttons except the pan button
|
|
@@ -141,13 +134,14 @@ class MapTemplate: NSObject, AutoPlayTemplate, AutoPlayHeaderProviding,
|
|
|
141
134
|
template.backButton = CPBarButton(title: "") { _ in
|
|
142
135
|
self.template.dismissPanningInterface(animated: true)
|
|
143
136
|
}
|
|
144
|
-
|
|
145
|
-
let mapButtons =
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
137
|
+
|
|
138
|
+
let mapButtons =
|
|
139
|
+
config.mapButtons?.filter { button in
|
|
140
|
+
button.type != .pan
|
|
141
|
+
} ?? []
|
|
142
|
+
|
|
149
143
|
template.mapButtons = parseMapButtons(mapButtons: mapButtons)
|
|
150
|
-
|
|
144
|
+
|
|
151
145
|
return
|
|
152
146
|
}
|
|
153
147
|
|
|
@@ -186,9 +180,9 @@ class MapTemplate: NSObject, AutoPlayTemplate, AutoPlayHeaderProviding,
|
|
|
186
180
|
isDark ? .dark : .light
|
|
187
181
|
)
|
|
188
182
|
|
|
189
|
-
invalidate()
|
|
190
|
-
|
|
191
183
|
template.tripEstimateStyle = isDark ? .dark : .light
|
|
184
|
+
|
|
185
|
+
invalidate()
|
|
192
186
|
}
|
|
193
187
|
|
|
194
188
|
// MARK: gestures
|
|
@@ -215,7 +209,7 @@ class MapTemplate: NSObject, AutoPlayTemplate, AutoPlayHeaderProviding,
|
|
|
215
209
|
if template.isPanningInterfaceVisible {
|
|
216
210
|
return
|
|
217
211
|
}
|
|
218
|
-
|
|
212
|
+
|
|
219
213
|
if scale == 1 && velocity == 1 {
|
|
220
214
|
config.onDoubleClick?(Point(x: center.x, y: center.y))
|
|
221
215
|
return
|
|
@@ -243,7 +237,8 @@ class MapTemplate: NSObject, AutoPlayTemplate, AutoPlayHeaderProviding,
|
|
|
243
237
|
) {
|
|
244
238
|
let panButtonScrollPercentage = config.panButtonScrollPercentage ?? 0.15
|
|
245
239
|
let scrollDistanceX = screenDimensions.width * panButtonScrollPercentage
|
|
246
|
-
let scrollDistanceY =
|
|
240
|
+
let scrollDistanceY =
|
|
241
|
+
screenDimensions.height * panButtonScrollPercentage
|
|
247
242
|
|
|
248
243
|
var translation = CGPoint.zero
|
|
249
244
|
|
|
@@ -442,9 +437,24 @@ class MapTemplate: NSObject, AutoPlayTemplate, AutoPlayHeaderProviding,
|
|
|
442
437
|
onBackPressed: @escaping () -> Void,
|
|
443
438
|
mapButtons: [NitroMapButton]
|
|
444
439
|
) -> TripSelectorCallback {
|
|
440
|
+
tripSelectorVisible = true
|
|
445
441
|
self.onTripSelected = onTripSelected
|
|
446
442
|
self.onTripStarted = onTripStarted
|
|
447
443
|
|
|
444
|
+
DispatchQueue.main.async {
|
|
445
|
+
self.template.backButton = CPBarButton(title: "") { _ in
|
|
446
|
+
self.hideTripSelector()
|
|
447
|
+
|
|
448
|
+
onBackPressed()
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
self.template.leadingNavigationBarButtons = []
|
|
452
|
+
self.template.trailingNavigationBarButtons = []
|
|
453
|
+
self.template.mapButtons = self.parseMapButtons(
|
|
454
|
+
mapButtons: mapButtons
|
|
455
|
+
)
|
|
456
|
+
}
|
|
457
|
+
|
|
448
458
|
let textConfiguration = Parser.parseTripPreviewTextConfig(
|
|
449
459
|
textConfig: textConfig
|
|
450
460
|
)
|
|
@@ -454,23 +464,12 @@ class MapTemplate: NSObject, AutoPlayTemplate, AutoPlayHeaderProviding,
|
|
|
454
464
|
tripPreviews.first(where: { $0.id == tripId })
|
|
455
465
|
}
|
|
456
466
|
|
|
457
|
-
template.backButton = CPBarButton(title: "") { _ in
|
|
458
|
-
self.hideTripSelector()
|
|
459
|
-
|
|
460
|
-
onBackPressed()
|
|
461
|
-
}
|
|
462
|
-
template.leadingNavigationBarButtons = []
|
|
463
|
-
template.trailingNavigationBarButtons = []
|
|
464
|
-
template.mapButtons = parseMapButtons(mapButtons: mapButtons)
|
|
465
|
-
|
|
466
467
|
template.showTripPreviews(
|
|
467
468
|
tripPreviews,
|
|
468
469
|
selectedTrip: selectedTrip,
|
|
469
470
|
textConfiguration: textConfiguration
|
|
470
471
|
)
|
|
471
472
|
|
|
472
|
-
tripSelectorVisible = true
|
|
473
|
-
|
|
474
473
|
tripPreviews.forEach { trip in
|
|
475
474
|
guard
|
|
476
475
|
let travelEstimates = trip.routeChoices.first?
|
|
@@ -500,6 +499,8 @@ class MapTemplate: NSObject, AutoPlayTemplate, AutoPlayHeaderProviding,
|
|
|
500
499
|
tripSelectorVisible = false
|
|
501
500
|
onTripSelected = nil
|
|
502
501
|
onTripStarted = nil
|
|
502
|
+
|
|
503
|
+
invalidate()
|
|
503
504
|
}
|
|
504
505
|
|
|
505
506
|
func mapTemplate(
|
|
@@ -611,11 +612,16 @@ class MapTemplate: NSObject, AutoPlayTemplate, AutoPlayHeaderProviding,
|
|
|
611
612
|
func updateManeuvers(maneuvers: [NitroRoutingManeuver]) {
|
|
612
613
|
guard let navigationSession = navigationSession else { return }
|
|
613
614
|
|
|
615
|
+
if maneuvers.isEmpty {
|
|
616
|
+
navigationSession.upcomingManeuvers = []
|
|
617
|
+
return
|
|
618
|
+
}
|
|
619
|
+
|
|
614
620
|
if #unavailable(iOS 15.4),
|
|
615
621
|
let color = maneuvers.first?.cardBackgroundColor
|
|
616
622
|
{
|
|
617
623
|
// before iOS 15.4 the color had to be set on the template
|
|
618
|
-
// later on the
|
|
624
|
+
// later on the maneuver which Parser.parseManeuver does
|
|
619
625
|
template.guidanceBackgroundColor = Parser.parseColor(color: color)
|
|
620
626
|
}
|
|
621
627
|
|
|
@@ -10,7 +10,7 @@ import CarPlay
|
|
|
10
10
|
class SearchTemplate: NSObject, AutoPlayTemplate, CPSearchTemplateDelegate {
|
|
11
11
|
var template: CPSearchTemplate
|
|
12
12
|
var config: SearchTemplateConfig
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
var autoDismissMs: Double? {
|
|
15
15
|
return config.autoDismissMs
|
|
16
16
|
}
|
|
@@ -34,6 +34,7 @@ class SearchTemplate: NSObject, AutoPlayTemplate, CPSearchTemplateDelegate {
|
|
|
34
34
|
invalidate()
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
@MainActor
|
|
37
38
|
func invalidate() {
|
|
38
39
|
// if we have pushed a list template update it
|
|
39
40
|
if let listTemplate = pushedListTemplate {
|
|
@@ -139,16 +140,19 @@ class SearchTemplate: NSObject, AutoPlayTemplate, CPSearchTemplateDelegate {
|
|
|
139
140
|
// execute callback after creating the template to avoid race condition in updateSearchResults
|
|
140
141
|
config.onSearchTextSubmitted(searchText)
|
|
141
142
|
|
|
143
|
+
TemplateStore.addTemplate(
|
|
144
|
+
template: listTemplate,
|
|
145
|
+
templateId: listConfig.id
|
|
146
|
+
)
|
|
147
|
+
|
|
142
148
|
// Push the template
|
|
143
149
|
Task { @MainActor in
|
|
144
150
|
do {
|
|
145
|
-
try await RootModule.
|
|
146
|
-
scene,
|
|
151
|
+
try await RootModule.withInterfaceController {
|
|
147
152
|
interfaceController in
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
)
|
|
153
|
+
|
|
154
|
+
listTemplate.invalidate()
|
|
155
|
+
|
|
152
156
|
let _ = try await interfaceController.pushTemplate(
|
|
153
157
|
listTemplate.template,
|
|
154
158
|
animated: true
|
|
@@ -7,27 +7,27 @@
|
|
|
7
7
|
import CarPlay
|
|
8
8
|
|
|
9
9
|
class TemplateStore {
|
|
10
|
-
private var store: [String: AutoPlayTemplate] = [:]
|
|
10
|
+
private static var store: [String: AutoPlayTemplate] = [:]
|
|
11
11
|
|
|
12
|
-
func getCPTemplate(templateId key: String) -> CPTemplate? {
|
|
12
|
+
static func getCPTemplate(templateId key: String) -> CPTemplate? {
|
|
13
13
|
return store[key]?.getTemplate()
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
func getTemplate(templateId: String) -> AutoPlayTemplate? {
|
|
16
|
+
static func getTemplate(templateId: String) -> AutoPlayTemplate? {
|
|
17
17
|
return store[templateId]
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
func addTemplate(template: AutoPlayTemplate, templateId: String) {
|
|
20
|
+
static func addTemplate(template: AutoPlayTemplate, templateId: String) {
|
|
21
21
|
store[templateId] = template
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
func removeTemplate(templateId: String) {
|
|
24
|
+
static func removeTemplate(templateId: String) {
|
|
25
25
|
store[templateId]?.onPopped()
|
|
26
26
|
|
|
27
27
|
store.removeValue(forKey: templateId)
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
func removeTemplates(templateIds: [String]) {
|
|
30
|
+
static func removeTemplates(templateIds: [String]) {
|
|
31
31
|
templateIds.forEach { templateId in
|
|
32
32
|
store[templateId]?.onPopped()
|
|
33
33
|
}
|
|
@@ -35,11 +35,11 @@ class TemplateStore {
|
|
|
35
35
|
store = store.filter { !templateIds.contains($0.key) }
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
func purge() {
|
|
38
|
+
static func purge() {
|
|
39
39
|
store = store.filter { !($0.value.getTemplate() is CPSearchTemplate) }
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
func traitCollectionDidChange() {
|
|
42
|
+
static func traitCollectionDidChange() {
|
|
43
43
|
store.values.forEach { template in template.traitCollectionDidChange() }
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -28,23 +28,21 @@ class RootModule {
|
|
|
28
28
|
templateId: String,
|
|
29
29
|
perform action: @escaping (T) throws -> Void
|
|
30
30
|
) throws {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
guard let template = template as? T else {
|
|
41
|
-
throw AutoPlayError.invalidTemplateType(
|
|
42
|
-
"\(template) is not a \(T.self) template"
|
|
43
|
-
)
|
|
44
|
-
}
|
|
31
|
+
guard
|
|
32
|
+
let template = TemplateStore.getTemplate(
|
|
33
|
+
templateId: templateId
|
|
34
|
+
)
|
|
35
|
+
else {
|
|
36
|
+
throw AutoPlayError.templateNotFound(templateId)
|
|
37
|
+
}
|
|
45
38
|
|
|
46
|
-
|
|
39
|
+
guard let template = template as? T else {
|
|
40
|
+
throw AutoPlayError.invalidTemplateType(
|
|
41
|
+
"\(template) is not a \(T.self) template"
|
|
42
|
+
)
|
|
47
43
|
}
|
|
44
|
+
|
|
45
|
+
try action(template)
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
static func withTemplate<T: CPTemplate>(
|
|
@@ -63,7 +61,6 @@ class RootModule {
|
|
|
63
61
|
}
|
|
64
62
|
}
|
|
65
63
|
|
|
66
|
-
@MainActor
|
|
67
64
|
static func withScene<T>(
|
|
68
65
|
perform action:
|
|
69
66
|
@escaping (AutoPlayScene) async throws -> T
|
|
@@ -107,28 +104,4 @@ class RootModule {
|
|
|
107
104
|
try await action(interfaceController)
|
|
108
105
|
}
|
|
109
106
|
}
|
|
110
|
-
|
|
111
|
-
@MainActor
|
|
112
|
-
static func withSceneTemplateAndInterfaceController<T>(
|
|
113
|
-
templateId: String,
|
|
114
|
-
perform action:
|
|
115
|
-
@escaping (CPTemplate, AutoPlayScene, AutoPlayInterfaceController)
|
|
116
|
-
async throws -> T
|
|
117
|
-
) async throws -> T {
|
|
118
|
-
return try await withSceneAndInterfaceController {
|
|
119
|
-
scene,
|
|
120
|
-
interfaceController in
|
|
121
|
-
|
|
122
|
-
guard
|
|
123
|
-
let template = scene.templateStore.getCPTemplate(
|
|
124
|
-
templateId: templateId
|
|
125
|
-
)
|
|
126
|
-
else {
|
|
127
|
-
throw AutoPlayError.templateNotFound(
|
|
128
|
-
"operation failed, \(templateId) template not found"
|
|
129
|
-
)
|
|
130
|
-
}
|
|
131
|
-
return try await action(template, scene, interfaceController)
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
107
|
}
|
|
@@ -55,7 +55,7 @@ export interface AutoPlay extends HybridObject<{
|
|
|
55
55
|
/**
|
|
56
56
|
* update a templates headerActions
|
|
57
57
|
*/
|
|
58
|
-
setTemplateHeaderActions(templateId: string, headerActions?: Array<NitroAction>): void
|
|
58
|
+
setTemplateHeaderActions(templateId: string, headerActions?: Array<NitroAction>): Promise<void>;
|
|
59
59
|
/**
|
|
60
60
|
* Check if AutoPlay is connected.
|
|
61
61
|
* @returns true if AutoPlay is connected, false otherwise.
|
|
@@ -9,6 +9,6 @@ export interface GridTemplate extends HybridObject<{
|
|
|
9
9
|
ios: 'swift';
|
|
10
10
|
}> {
|
|
11
11
|
createGridTemplate(config: GridTemplateConfig): void;
|
|
12
|
-
updateGridTemplateButtons(templateId: string, buttons: Array<NitroGridButton>): void
|
|
12
|
+
updateGridTemplateButtons(templateId: string, buttons: Array<NitroGridButton>): Promise<void>;
|
|
13
13
|
}
|
|
14
14
|
export {};
|
|
@@ -8,6 +8,6 @@ export interface InformationTemplate extends HybridObject<{
|
|
|
8
8
|
ios: 'swift';
|
|
9
9
|
}> {
|
|
10
10
|
createInformationTemplate(config: InformationTemplateConfig): void;
|
|
11
|
-
updateInformationTemplateSections(templateId: string, section: NitroInformationTemplateConfig['section']): void
|
|
11
|
+
updateInformationTemplateSections(templateId: string, section: NitroInformationTemplateConfig['section']): Promise<void>;
|
|
12
12
|
}
|
|
13
13
|
export {};
|
|
@@ -8,6 +8,6 @@ export interface ListTemplate extends HybridObject<{
|
|
|
8
8
|
ios: 'swift';
|
|
9
9
|
}> {
|
|
10
10
|
createListTemplate(config: ListTemplateConfig): void;
|
|
11
|
-
updateListTemplateSections(templateId: string, sections: NitroListTemplateConfig['sections']): void
|
|
11
|
+
updateListTemplateSections(templateId: string, sections: NitroListTemplateConfig['sections']): Promise<void>;
|
|
12
12
|
}
|
|
13
13
|
export {};
|
|
@@ -18,7 +18,7 @@ export interface MapTemplate extends HybridObject<{
|
|
|
18
18
|
dismissNavigationAlert(templateId: string, navigationAlertId: number): void;
|
|
19
19
|
showTripSelector(templateId: string, trips: Array<TripsConfig>, selectedTripId: string | undefined, textConfig: TripPreviewTextConfiguration, onTripSelected: (tripId: string, routeId: string) => void, onTripStarted: (tripId: string, routeId: string) => void, onBackPressed: () => void, mapButtons: Array<NitroMapButton>): TripSelectorCallback;
|
|
20
20
|
hideTripSelector(templateId: string): void;
|
|
21
|
-
setTemplateMapButtons(templateId: string, buttons?: Array<NitroMapButton>): void
|
|
21
|
+
setTemplateMapButtons(templateId: string, buttons?: Array<NitroMapButton>): Promise<void>;
|
|
22
22
|
updateVisibleTravelEstimate(templateId: string, visibleTravelEstimate: VisibleTravelEstimate): void;
|
|
23
23
|
updateTravelEstimates(templateId: string, steps: Array<TripPoint>): void;
|
|
24
24
|
updateManeuvers(templateId: string, maneuvers: NitroManeuver): void;
|
|
@@ -8,6 +8,6 @@ export interface SearchTemplate extends HybridObject<{
|
|
|
8
8
|
ios: 'swift';
|
|
9
9
|
}> {
|
|
10
10
|
createSearchTemplate(config: SearchTemplateConfig): void;
|
|
11
|
-
updateSearchResults(templateId: string, results: NitroSearchTemplateConfig['results']): void
|
|
11
|
+
updateSearchResults(templateId: string, results: NitroSearchTemplateConfig['results']): Promise<void>;
|
|
12
12
|
}
|
|
13
13
|
export {};
|
|
@@ -24,5 +24,5 @@ export type GridTemplateConfig = Omit<NitroGridTemplateConfig, 'headerActions' |
|
|
|
24
24
|
export declare class GridTemplate extends Template<GridTemplateConfig, HeaderActions<GridTemplate>> {
|
|
25
25
|
private template;
|
|
26
26
|
constructor(config: GridTemplateConfig);
|
|
27
|
-
updateGrid(buttons: Array<GridButton<GridTemplate>>): void
|
|
27
|
+
updateGrid(buttons: Array<GridButton<GridTemplate>>): Promise<void>;
|
|
28
28
|
}
|
|
@@ -24,6 +24,6 @@ export class GridTemplate extends Template {
|
|
|
24
24
|
HybridGridTemplate.createGridTemplate(nitroConfig);
|
|
25
25
|
}
|
|
26
26
|
updateGrid(buttons) {
|
|
27
|
-
HybridGridTemplate.updateGridTemplateButtons(this.id, NitroGridUtil.convert(this.template, buttons));
|
|
27
|
+
return HybridGridTemplate.updateGridTemplateButtons(this.id, NitroGridUtil.convert(this.template, buttons));
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -47,6 +47,6 @@ export type InformationTemplateConfig = Omit<NitroInformationTemplateConfig, 'he
|
|
|
47
47
|
export declare class InformationTemplate extends Template<InformationTemplateConfig, HeaderActions<InformationTemplate>> {
|
|
48
48
|
private template;
|
|
49
49
|
constructor(config: InformationTemplateConfig);
|
|
50
|
-
updateItems(items?: InformationItems): void
|
|
50
|
+
updateItems(items?: InformationItems): Promise<void>;
|
|
51
51
|
private getSection;
|
|
52
52
|
}
|
|
@@ -34,7 +34,7 @@ export class InformationTemplate extends Template {
|
|
|
34
34
|
}
|
|
35
35
|
updateItems(items) {
|
|
36
36
|
const section = this.getSection(items);
|
|
37
|
-
HybridInformationTemplate.updateInformationTemplateSections(this.id, NitroSectionUtil.convert(this.template, section)?.at(0) ?? { items: [], type: 'default' });
|
|
37
|
+
return HybridInformationTemplate.updateInformationTemplateSections(this.id, NitroSectionUtil.convert(this.template, section)?.at(0) ?? { items: [], type: 'default' });
|
|
38
38
|
}
|
|
39
39
|
getSection(items) {
|
|
40
40
|
return {
|
|
@@ -72,6 +72,6 @@ export type ListTemplateConfig = Omit<NitroListTemplateConfig, 'headerActions' |
|
|
|
72
72
|
export declare class ListTemplate extends Template<ListTemplateConfig, HeaderActions<ListTemplate>> {
|
|
73
73
|
private template;
|
|
74
74
|
constructor(config: ListTemplateConfig);
|
|
75
|
-
updateSections(sections?: Section<ListTemplate>): void
|
|
75
|
+
updateSections(sections?: Section<ListTemplate>): Promise<void>;
|
|
76
76
|
}
|
|
77
77
|
export {};
|
|
@@ -24,6 +24,6 @@ export class ListTemplate extends Template {
|
|
|
24
24
|
HybridListTemplate.createListTemplate(nitroConfig);
|
|
25
25
|
}
|
|
26
26
|
updateSections(sections) {
|
|
27
|
-
HybridListTemplate.updateListTemplateSections(this.id, NitroSectionUtil.convert(this.template, sections));
|
|
27
|
+
return HybridListTemplate.updateListTemplateSections(this.id, NitroSectionUtil.convert(this.template, sections));
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -101,8 +101,8 @@ export declare class MapTemplate extends Template<MapTemplateConfig, MapTemplate
|
|
|
101
101
|
id: string;
|
|
102
102
|
private template;
|
|
103
103
|
constructor(config: MapTemplateConfig);
|
|
104
|
-
setMapButtons(mapButtons: MapTemplateConfig['mapButtons']): void
|
|
105
|
-
setHeaderActions(headerActions: MapTemplateConfig['headerActions']): void
|
|
104
|
+
setMapButtons(mapButtons: MapTemplateConfig['mapButtons']): Promise<void>;
|
|
105
|
+
setHeaderActions(headerActions: MapTemplateConfig['headerActions']): Promise<void>;
|
|
106
106
|
/**
|
|
107
107
|
* brings up a navigation alert
|
|
108
108
|
* ⚠️ updating an existing alert is currently broken on Android Automotive, it brings up a new alert for each call
|
|
@@ -37,11 +37,11 @@ export class MapTemplate extends Template {
|
|
|
37
37
|
}
|
|
38
38
|
setMapButtons(mapButtons) {
|
|
39
39
|
const buttons = NitroMapButton.convert(this.template, mapButtons);
|
|
40
|
-
HybridMapTemplate.setTemplateMapButtons(this.id, buttons);
|
|
40
|
+
return HybridMapTemplate.setTemplateMapButtons(this.id, buttons);
|
|
41
41
|
}
|
|
42
42
|
setHeaderActions(headerActions) {
|
|
43
43
|
const nitroActions = NitroActionUtil.convert(this.template, headerActions);
|
|
44
|
-
HybridAutoPlay.setTemplateHeaderActions(this.id, nitroActions);
|
|
44
|
+
return HybridAutoPlay.setTemplateHeaderActions(this.id, nitroActions);
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
47
|
* brings up a navigation alert
|
|
@@ -105,6 +105,10 @@ export class MapTemplate extends Template {
|
|
|
105
105
|
HybridMapTemplate.updateManeuvers(this.id, nitroManeuvers);
|
|
106
106
|
return;
|
|
107
107
|
}
|
|
108
|
+
if (maneuvers.type === 'loading') {
|
|
109
|
+
HybridMapTemplate.updateManeuvers(this.id, { isLoading: true });
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
108
112
|
const messageManeuver = NitroManeuverUtil.convert(maneuvers);
|
|
109
113
|
HybridMapTemplate.updateManeuvers(this.id, messageManeuver);
|
|
110
114
|
}
|
|
@@ -51,5 +51,5 @@ export type SearchTemplateConfig = Omit<NitroSearchTemplateConfig, 'headerAction
|
|
|
51
51
|
export declare class SearchTemplate extends Template<SearchTemplateConfig, HeaderActions<SearchTemplate>> {
|
|
52
52
|
private template;
|
|
53
53
|
constructor(config: SearchTemplateConfig);
|
|
54
|
-
updateSearchResults(results?: SingleSection<SearchTemplate>): void
|
|
54
|
+
updateSearchResults(results?: SingleSection<SearchTemplate>): Promise<void>;
|
|
55
55
|
}
|
|
@@ -20,7 +20,7 @@ export class SearchTemplate extends Template {
|
|
|
20
20
|
HybridSearchTemplate.createSearchTemplate(nitroConfig);
|
|
21
21
|
}
|
|
22
22
|
updateSearchResults(results) {
|
|
23
|
-
HybridSearchTemplate.updateSearchResults(this.id, NitroSectionUtil.convert(this.template, results)?.at(0) ?? {
|
|
23
|
+
return HybridSearchTemplate.updateSearchResults(this.id, NitroSectionUtil.convert(this.template, results)?.at(0) ?? {
|
|
24
24
|
items: [],
|
|
25
25
|
type: 'default',
|
|
26
26
|
});
|
|
@@ -73,5 +73,5 @@ export declare class Template<TemplateConfigType, ActionsType> {
|
|
|
73
73
|
* remove all templates above this one from the stack
|
|
74
74
|
*/
|
|
75
75
|
popTo(): Promise<void>;
|
|
76
|
-
setHeaderActions<T>(headerActions?: ActionsType): void
|
|
76
|
+
setHeaderActions<T>(headerActions?: ActionsType): Promise<void>;
|
|
77
77
|
}
|
|
@@ -28,6 +28,6 @@ export class Template {
|
|
|
28
28
|
}
|
|
29
29
|
setHeaderActions(headerActions) {
|
|
30
30
|
const nitroActions = NitroActionUtil.convert(headerActions);
|
|
31
|
-
HybridAutoPlay.setTemplateHeaderActions(this.id, nitroActions);
|
|
31
|
+
return HybridAutoPlay.setTemplateHeaderActions(this.id, nitroActions);
|
|
32
32
|
}
|
|
33
33
|
}
|
package/lib/types/Maneuver.d.ts
CHANGED
|
@@ -196,7 +196,10 @@ export type MessageManeuver = {
|
|
|
196
196
|
cardBackgroundColor: ThemedColor | string;
|
|
197
197
|
type: 'message';
|
|
198
198
|
};
|
|
199
|
+
export type LoadingManeuver = {
|
|
200
|
+
type: 'loading';
|
|
201
|
+
};
|
|
199
202
|
export type AutoManeuver = (Array<RoutingManeuver> & {
|
|
200
|
-
length: 1 | 2;
|
|
201
|
-
}) | MessageManeuver;
|
|
203
|
+
length: 0 | 1 | 2;
|
|
204
|
+
}) | MessageManeuver | LoadingManeuver;
|
|
202
205
|
export {};
|
|
@@ -33,7 +33,10 @@ export interface NitroMessageManeuver {
|
|
|
33
33
|
image?: NitroImage;
|
|
34
34
|
cardBackgroundColor: NitroColor;
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
interface NitroLoadingManeuver {
|
|
37
|
+
isLoading: true;
|
|
38
|
+
}
|
|
39
|
+
export type NitroManeuver = Array<NitroRoutingManeuver> | NitroMessageManeuver | NitroLoadingManeuver;
|
|
37
40
|
declare function convert(autoManeuver: MessageManeuver): NitroMessageManeuver;
|
|
38
41
|
declare function convert(autoManeuver: RoutingManeuver): NitroRoutingManeuver;
|
|
39
42
|
export declare const NitroManeuverUtil: {
|