@iternio/react-native-auto-play 0.0.8 → 0.0.10
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/VirtualRenderer.kt +1 -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 +20 -12
- 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 +37 -32
- 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 +2 -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/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 +16 -3
- package/nitrogen/generated/android/c++/JHybridMapTemplateSpec.hpp +1 -1
- package/nitrogen/generated/android/c++/JHybridSearchTemplateSpec.cpp +16 -3
- package/nitrogen/generated/android/c++/JHybridSearchTemplateSpec.hpp +1 -1
- 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/ios/ReactNativeAutoPlay-Swift-Cxx-Bridge.hpp +9 -9
- 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 +4 -1
- 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 +13 -4
- package/nitrogen/generated/ios/swift/HybridSearchTemplateSpec.swift +2 -1
- package/nitrogen/generated/ios/swift/HybridSearchTemplateSpec_cxx.swift +13 -4
- 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 +2 -1
- package/nitrogen/generated/shared/c++/HybridSearchTemplateSpec.hpp +2 -1
- 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 +2 -2
- package/src/templates/SearchTemplate.ts +1 -1
- package/src/templates/Template.ts +1 -1
|
@@ -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,11 @@ 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
|
+
DispatchQueue.main.async {
|
|
186
|
+
self.invalidate()
|
|
187
|
+
}
|
|
192
188
|
}
|
|
193
189
|
|
|
194
190
|
// MARK: gestures
|
|
@@ -215,7 +211,7 @@ class MapTemplate: NSObject, AutoPlayTemplate, AutoPlayHeaderProviding,
|
|
|
215
211
|
if template.isPanningInterfaceVisible {
|
|
216
212
|
return
|
|
217
213
|
}
|
|
218
|
-
|
|
214
|
+
|
|
219
215
|
if scale == 1 && velocity == 1 {
|
|
220
216
|
config.onDoubleClick?(Point(x: center.x, y: center.y))
|
|
221
217
|
return
|
|
@@ -243,7 +239,8 @@ class MapTemplate: NSObject, AutoPlayTemplate, AutoPlayHeaderProviding,
|
|
|
243
239
|
) {
|
|
244
240
|
let panButtonScrollPercentage = config.panButtonScrollPercentage ?? 0.15
|
|
245
241
|
let scrollDistanceX = screenDimensions.width * panButtonScrollPercentage
|
|
246
|
-
let scrollDistanceY =
|
|
242
|
+
let scrollDistanceY =
|
|
243
|
+
screenDimensions.height * panButtonScrollPercentage
|
|
247
244
|
|
|
248
245
|
var translation = CGPoint.zero
|
|
249
246
|
|
|
@@ -442,9 +439,24 @@ class MapTemplate: NSObject, AutoPlayTemplate, AutoPlayHeaderProviding,
|
|
|
442
439
|
onBackPressed: @escaping () -> Void,
|
|
443
440
|
mapButtons: [NitroMapButton]
|
|
444
441
|
) -> TripSelectorCallback {
|
|
442
|
+
tripSelectorVisible = true
|
|
445
443
|
self.onTripSelected = onTripSelected
|
|
446
444
|
self.onTripStarted = onTripStarted
|
|
447
445
|
|
|
446
|
+
DispatchQueue.main.async {
|
|
447
|
+
self.template.backButton = CPBarButton(title: "") { _ in
|
|
448
|
+
self.hideTripSelector()
|
|
449
|
+
|
|
450
|
+
onBackPressed()
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
self.template.leadingNavigationBarButtons = []
|
|
454
|
+
self.template.trailingNavigationBarButtons = []
|
|
455
|
+
self.template.mapButtons = self.parseMapButtons(
|
|
456
|
+
mapButtons: mapButtons
|
|
457
|
+
)
|
|
458
|
+
}
|
|
459
|
+
|
|
448
460
|
let textConfiguration = Parser.parseTripPreviewTextConfig(
|
|
449
461
|
textConfig: textConfig
|
|
450
462
|
)
|
|
@@ -454,23 +466,12 @@ class MapTemplate: NSObject, AutoPlayTemplate, AutoPlayHeaderProviding,
|
|
|
454
466
|
tripPreviews.first(where: { $0.id == tripId })
|
|
455
467
|
}
|
|
456
468
|
|
|
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
469
|
template.showTripPreviews(
|
|
467
470
|
tripPreviews,
|
|
468
471
|
selectedTrip: selectedTrip,
|
|
469
472
|
textConfiguration: textConfiguration
|
|
470
473
|
)
|
|
471
474
|
|
|
472
|
-
tripSelectorVisible = true
|
|
473
|
-
|
|
474
475
|
tripPreviews.forEach { trip in
|
|
475
476
|
guard
|
|
476
477
|
let travelEstimates = trip.routeChoices.first?
|
|
@@ -500,6 +501,10 @@ class MapTemplate: NSObject, AutoPlayTemplate, AutoPlayHeaderProviding,
|
|
|
500
501
|
tripSelectorVisible = false
|
|
501
502
|
onTripSelected = nil
|
|
502
503
|
onTripStarted = nil
|
|
504
|
+
|
|
505
|
+
DispatchQueue.main.async {
|
|
506
|
+
self.invalidate()
|
|
507
|
+
}
|
|
503
508
|
}
|
|
504
509
|
|
|
505
510
|
func mapTemplate(
|
|
@@ -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
|
|
@@ -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
|
}
|
|
@@ -212,9 +212,9 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
|
212
212
|
}
|
|
213
213
|
}();
|
|
214
214
|
}
|
|
215
|
-
void JHybridAutoPlaySpec::setTemplateHeaderActions(const std::string& templateId, const std::optional<std::vector<NitroAction>>& headerActions) {
|
|
216
|
-
static const auto method = javaClassStatic()->getMethod<
|
|
217
|
-
method(_javaPart, jni::make_jstring(templateId), headerActions.has_value() ? [&]() {
|
|
215
|
+
std::shared_ptr<Promise<void>> JHybridAutoPlaySpec::setTemplateHeaderActions(const std::string& templateId, const std::optional<std::vector<NitroAction>>& headerActions) {
|
|
216
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* templateId */, jni::alias_ref<jni::JArrayClass<JNitroAction>> /* headerActions */)>("setTemplateHeaderActions");
|
|
217
|
+
auto __result = method(_javaPart, jni::make_jstring(templateId), headerActions.has_value() ? [&]() {
|
|
218
218
|
size_t __size = headerActions.value().size();
|
|
219
219
|
jni::local_ref<jni::JArrayClass<JNitroAction>> __array = jni::JArrayClass<JNitroAction>::newArray(__size);
|
|
220
220
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
@@ -224,6 +224,17 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
|
224
224
|
}
|
|
225
225
|
return __array;
|
|
226
226
|
}() : nullptr);
|
|
227
|
+
return [&]() {
|
|
228
|
+
auto __promise = Promise<void>::create();
|
|
229
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
|
|
230
|
+
__promise->resolve();
|
|
231
|
+
});
|
|
232
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
233
|
+
jni::JniException __jniError(__throwable);
|
|
234
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
235
|
+
});
|
|
236
|
+
return __promise;
|
|
237
|
+
}();
|
|
227
238
|
}
|
|
228
239
|
bool JHybridAutoPlaySpec::isConnected() {
|
|
229
240
|
static const auto method = javaClassStatic()->getMethod<jboolean()>("isConnected");
|
|
@@ -62,7 +62,7 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
|
62
62
|
std::shared_ptr<Promise<void>> popToRootTemplate(std::optional<bool> animate) override;
|
|
63
63
|
std::shared_ptr<Promise<void>> popToTemplate(const std::string& templateId, std::optional<bool> animate) override;
|
|
64
64
|
std::function<void()> addSafeAreaInsetsListener(const std::string& moduleName, const std::function<void(const SafeAreaInsets& /* insets */)>& callback) override;
|
|
65
|
-
void setTemplateHeaderActions(const std::string& templateId, const std::optional<std::vector<NitroAction>>& headerActions) override;
|
|
65
|
+
std::shared_ptr<Promise<void>> setTemplateHeaderActions(const std::string& templateId, const std::optional<std::vector<NitroAction>>& headerActions) override;
|
|
66
66
|
bool isConnected() override;
|
|
67
67
|
|
|
68
68
|
private:
|
|
@@ -38,6 +38,8 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroMapBut
|
|
|
38
38
|
// Forward declaration of `NitroMapButtonType` to properly resolve imports.
|
|
39
39
|
namespace margelo::nitro::swe::iternio::reactnativeautoplay { enum class NitroMapButtonType; }
|
|
40
40
|
|
|
41
|
+
#include <NitroModules/Promise.hpp>
|
|
42
|
+
#include <NitroModules/JPromise.hpp>
|
|
41
43
|
#include "GridTemplateConfig.hpp"
|
|
42
44
|
#include "JGridTemplateConfig.hpp"
|
|
43
45
|
#include <string>
|
|
@@ -115,9 +117,9 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
|
115
117
|
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JGridTemplateConfig> /* config */)>("createGridTemplate");
|
|
116
118
|
method(_javaPart, JGridTemplateConfig::fromCpp(config));
|
|
117
119
|
}
|
|
118
|
-
void JHybridGridTemplateSpec::updateGridTemplateButtons(const std::string& templateId, const std::vector<NitroGridButton>& buttons) {
|
|
119
|
-
static const auto method = javaClassStatic()->getMethod<
|
|
120
|
-
method(_javaPart, jni::make_jstring(templateId), [&]() {
|
|
120
|
+
std::shared_ptr<Promise<void>> JHybridGridTemplateSpec::updateGridTemplateButtons(const std::string& templateId, const std::vector<NitroGridButton>& buttons) {
|
|
121
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* templateId */, jni::alias_ref<jni::JArrayClass<JNitroGridButton>> /* buttons */)>("updateGridTemplateButtons");
|
|
122
|
+
auto __result = method(_javaPart, jni::make_jstring(templateId), [&]() {
|
|
121
123
|
size_t __size = buttons.size();
|
|
122
124
|
jni::local_ref<jni::JArrayClass<JNitroGridButton>> __array = jni::JArrayClass<JNitroGridButton>::newArray(__size);
|
|
123
125
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
@@ -127,6 +129,17 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
|
127
129
|
}
|
|
128
130
|
return __array;
|
|
129
131
|
}());
|
|
132
|
+
return [&]() {
|
|
133
|
+
auto __promise = Promise<void>::create();
|
|
134
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
|
|
135
|
+
__promise->resolve();
|
|
136
|
+
});
|
|
137
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
138
|
+
jni::JniException __jniError(__throwable);
|
|
139
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
140
|
+
});
|
|
141
|
+
return __promise;
|
|
142
|
+
}();
|
|
130
143
|
}
|
|
131
144
|
|
|
132
145
|
} // namespace margelo::nitro::swe::iternio::reactnativeautoplay
|
|
@@ -55,7 +55,7 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
|
55
55
|
public:
|
|
56
56
|
// Methods
|
|
57
57
|
void createGridTemplate(const GridTemplateConfig& config) override;
|
|
58
|
-
void updateGridTemplateButtons(const std::string& templateId, const std::vector<NitroGridButton>& buttons) override;
|
|
58
|
+
std::shared_ptr<Promise<void>> updateGridTemplateButtons(const std::string& templateId, const std::vector<NitroGridButton>& buttons) override;
|
|
59
59
|
|
|
60
60
|
private:
|
|
61
61
|
friend HybridBase;
|