@iternio/react-native-auto-play 0.0.9 → 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/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
package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAutoPlay.kt
CHANGED
|
@@ -72,12 +72,14 @@ class HybridAutoPlay : HybridAutoPlaySpec() {
|
|
|
72
72
|
|
|
73
73
|
override fun setTemplateHeaderActions(
|
|
74
74
|
templateId: String, headerActions: Array<NitroAction>?
|
|
75
|
-
) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
75
|
+
): Promise<Unit> {
|
|
76
|
+
return Promise.async {
|
|
77
|
+
val template =
|
|
78
|
+
AndroidAutoTemplate.getTemplate(templateId) ?: throw IllegalArgumentException(
|
|
79
|
+
"setTemplateHeaderActions failed, template $templateId not found"
|
|
80
|
+
)
|
|
81
|
+
template.setTemplateHeaderActions(headerActions)
|
|
82
|
+
}
|
|
81
83
|
}
|
|
82
84
|
|
|
83
85
|
override fun setRootTemplate(templateId: String): Promise<Unit> {
|
|
@@ -105,9 +107,8 @@ class HybridAutoPlay : HybridAutoPlaySpec() {
|
|
|
105
107
|
} else {
|
|
106
108
|
val screenManager = AndroidAutoScreen.getScreenManager()
|
|
107
109
|
?: throw IllegalArgumentException("setRootTemplate failed, screenManager not found")
|
|
108
|
-
val carContext =
|
|
109
|
-
|
|
110
|
-
?: throw IllegalArgumentException("setRootTemplate failed, carContext for $templateId template not found")
|
|
110
|
+
val carContext = AndroidAutoSession.getCarContext(AndroidAutoSession.ROOT_SESSION)
|
|
111
|
+
?: throw IllegalArgumentException("setRootTemplate failed, carContext for $templateId template not found")
|
|
111
112
|
|
|
112
113
|
val result = ThreadUtil.postOnUiAndAwait {
|
|
113
114
|
screenManager.popToRoot()
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package com.margelo.nitro.swe.iternio.reactnativeautoplay
|
|
2
2
|
|
|
3
|
+
import com.margelo.nitro.core.Promise
|
|
3
4
|
import com.margelo.nitro.swe.iternio.reactnativeautoplay.template.AndroidAutoTemplate
|
|
4
5
|
import com.margelo.nitro.swe.iternio.reactnativeautoplay.template.GridTemplate
|
|
5
6
|
|
|
@@ -14,8 +15,10 @@ class HybridGridTemplate : HybridGridTemplateSpec() {
|
|
|
14
15
|
|
|
15
16
|
override fun updateGridTemplateButtons(
|
|
16
17
|
templateId: String, buttons: Array<NitroGridButton>
|
|
17
|
-
) {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
): Promise<Unit> {
|
|
19
|
+
return Promise.async {
|
|
20
|
+
val template = AndroidAutoTemplate.getTemplate<GridTemplate>(templateId)
|
|
21
|
+
template.updateButtons(buttons)
|
|
22
|
+
}
|
|
20
23
|
}
|
|
21
24
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package com.margelo.nitro.swe.iternio.reactnativeautoplay
|
|
2
2
|
|
|
3
|
+
import com.margelo.nitro.core.Promise
|
|
3
4
|
import com.margelo.nitro.swe.iternio.reactnativeautoplay.template.AndroidAutoTemplate
|
|
4
5
|
import com.margelo.nitro.swe.iternio.reactnativeautoplay.template.InformationTemplate
|
|
5
6
|
|
|
@@ -13,10 +14,11 @@ class HybridInformationTemplate : HybridInformationTemplateSpec() {
|
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
override fun updateInformationTemplateSections(
|
|
16
|
-
templateId: String,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
templateId: String, section: NitroSection
|
|
18
|
+
): Promise<Unit> {
|
|
19
|
+
return Promise.async {
|
|
20
|
+
val template = AndroidAutoTemplate.getTemplate<InformationTemplate>(templateId)
|
|
21
|
+
template.updateSection(section)
|
|
22
|
+
}
|
|
21
23
|
}
|
|
22
24
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package com.margelo.nitro.swe.iternio.reactnativeautoplay
|
|
2
2
|
|
|
3
|
+
import com.margelo.nitro.core.Promise
|
|
3
4
|
import com.margelo.nitro.swe.iternio.reactnativeautoplay.template.AndroidAutoTemplate
|
|
4
5
|
import com.margelo.nitro.swe.iternio.reactnativeautoplay.template.ListTemplate
|
|
5
6
|
|
|
@@ -15,8 +16,10 @@ class HybridListTemplate : HybridListTemplateSpec() {
|
|
|
15
16
|
|
|
16
17
|
override fun updateListTemplateSections(
|
|
17
18
|
templateId: String, sections: Array<NitroSection>?
|
|
18
|
-
) {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
): Promise<Unit> {
|
|
20
|
+
return Promise.async {
|
|
21
|
+
val template = AndroidAutoTemplate.getTemplate<ListTemplate>(templateId)
|
|
22
|
+
template.updateSections(sections)
|
|
23
|
+
}
|
|
21
24
|
}
|
|
22
25
|
}
|
package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridMapTemplate.kt
CHANGED
|
@@ -2,6 +2,7 @@ package com.margelo.nitro.swe.iternio.reactnativeautoplay
|
|
|
2
2
|
|
|
3
3
|
import androidx.car.app.AppManager
|
|
4
4
|
import com.facebook.react.bridge.UiThreadUtil
|
|
5
|
+
import com.margelo.nitro.core.Promise
|
|
5
6
|
import com.margelo.nitro.swe.iternio.reactnativeautoplay.template.AndroidAutoTemplate
|
|
6
7
|
import com.margelo.nitro.swe.iternio.reactnativeautoplay.template.MapTemplate
|
|
7
8
|
import com.margelo.nitro.swe.iternio.reactnativeautoplay.template.RoutePreviewTemplate
|
|
@@ -120,9 +121,11 @@ class HybridMapTemplate : HybridMapTemplateSpec() {
|
|
|
120
121
|
|
|
121
122
|
override fun setTemplateMapButtons(
|
|
122
123
|
templateId: String, buttons: Array<NitroMapButton>?
|
|
123
|
-
) {
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
): Promise<Unit> {
|
|
125
|
+
return Promise.async {
|
|
126
|
+
val template = AndroidAutoTemplate.getTemplate<MapTemplate>(templateId)
|
|
127
|
+
template.setMapActions(buttons)
|
|
128
|
+
}
|
|
126
129
|
}
|
|
127
130
|
|
|
128
131
|
override fun updateVisibleTravelEstimate(
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package com.margelo.nitro.swe.iternio.reactnativeautoplay
|
|
2
2
|
|
|
3
|
+
import com.margelo.nitro.core.Promise
|
|
3
4
|
import com.margelo.nitro.swe.iternio.reactnativeautoplay.template.AndroidAutoTemplate
|
|
4
5
|
import com.margelo.nitro.swe.iternio.reactnativeautoplay.template.SearchTemplate
|
|
5
6
|
|
|
@@ -13,8 +14,10 @@ class HybridSearchTemplate : HybridSearchTemplateSpec() {
|
|
|
13
14
|
AndroidAutoTemplate.setTemplate(config.id, template)
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
override fun updateSearchResults(templateId: String, results: NitroSection) {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
override fun updateSearchResults(templateId: String, results: NitroSection): Promise<Unit> {
|
|
18
|
+
return Promise.async {
|
|
19
|
+
val template = AndroidAutoTemplate.getTemplate<SearchTemplate>(templateId)
|
|
20
|
+
template.updateSearchResults(results)
|
|
21
|
+
}
|
|
19
22
|
}
|
|
20
23
|
}
|
|
@@ -110,17 +110,29 @@ class HybridAutoPlay: HybridAutoPlaySpec {
|
|
|
110
110
|
// MARK: set/push/pop templates
|
|
111
111
|
func setRootTemplate(templateId: String) throws -> Promise<Void> {
|
|
112
112
|
return Promise.async {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
113
|
+
guard
|
|
114
|
+
let template = TemplateStore.getTemplate(
|
|
115
|
+
templateId: templateId
|
|
116
|
+
)
|
|
117
|
+
else {
|
|
118
|
+
throw AutoPlayError.templateNotFound(templateId)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
try await RootModule.withSceneAndInterfaceController {
|
|
122
|
+
scene,
|
|
123
|
+
interfaceController in
|
|
124
|
+
let carPlayTemplate = template.getTemplate()
|
|
125
|
+
|
|
126
|
+
if carPlayTemplate is CPMapTemplate {
|
|
117
127
|
await MainActor.run {
|
|
118
128
|
scene.initRootView()
|
|
119
129
|
}
|
|
120
130
|
}
|
|
121
131
|
|
|
132
|
+
await template.invalidate()
|
|
133
|
+
|
|
122
134
|
let _ = try await interfaceController.setRootTemplate(
|
|
123
|
-
|
|
135
|
+
carPlayTemplate,
|
|
124
136
|
animated: false
|
|
125
137
|
)
|
|
126
138
|
}
|
|
@@ -131,27 +143,39 @@ class HybridAutoPlay: HybridAutoPlaySpec {
|
|
|
131
143
|
-> NitroModules.Promise<Void>
|
|
132
144
|
{
|
|
133
145
|
return Promise.async {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
146
|
+
guard
|
|
147
|
+
let template = TemplateStore.getTemplate(
|
|
148
|
+
templateId: templateId
|
|
149
|
+
)
|
|
150
|
+
else {
|
|
151
|
+
throw AutoPlayError.templateNotFound(templateId)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
await template.invalidate()
|
|
155
|
+
|
|
156
|
+
return try await RootModule.withInterfaceController {
|
|
157
|
+
interfaceController in
|
|
158
|
+
|
|
159
|
+
let carPlayTemplate = template.getTemplate()
|
|
160
|
+
|
|
161
|
+
if carPlayTemplate is CPAlertTemplate {
|
|
138
162
|
let animated = try await
|
|
139
163
|
!interfaceController.dismissTemplate(
|
|
140
164
|
animated: false
|
|
141
165
|
)
|
|
142
166
|
|
|
143
167
|
let _ = try await interfaceController.presentTemplate(
|
|
144
|
-
|
|
168
|
+
carPlayTemplate,
|
|
145
169
|
animated: animated
|
|
146
170
|
)
|
|
147
171
|
} else {
|
|
148
172
|
let _ = try await interfaceController.pushTemplate(
|
|
149
|
-
|
|
173
|
+
carPlayTemplate,
|
|
150
174
|
animated: true
|
|
151
175
|
)
|
|
152
176
|
}
|
|
153
177
|
|
|
154
|
-
if let autoDismissMs =
|
|
178
|
+
if let autoDismissMs = TemplateStore.getTemplate(
|
|
155
179
|
templateId: templateId
|
|
156
180
|
)?.autoDismissMs {
|
|
157
181
|
Task { @MainActor in
|
|
@@ -240,10 +264,18 @@ class HybridAutoPlay: HybridAutoPlaySpec {
|
|
|
240
264
|
func setTemplateHeaderActions(
|
|
241
265
|
templateId: String,
|
|
242
266
|
headerActions: [NitroAction]?
|
|
243
|
-
) throws {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
267
|
+
) throws -> Promise<Void> {
|
|
268
|
+
return Promise.async {
|
|
269
|
+
try await MainActor.run {
|
|
270
|
+
guard
|
|
271
|
+
var template = TemplateStore.getTemplate(
|
|
272
|
+
templateId: templateId
|
|
273
|
+
) as? AutoPlayHeaderProviding
|
|
274
|
+
else {
|
|
275
|
+
throw AutoPlayError.invalidTemplateType(
|
|
276
|
+
"\(templateId) does not support header actions"
|
|
277
|
+
)
|
|
278
|
+
}
|
|
247
279
|
template.barButtons = headerActions
|
|
248
280
|
}
|
|
249
281
|
}
|
|
@@ -5,24 +5,31 @@
|
|
|
5
5
|
// Created by Manuel Auer on 15.10.25.
|
|
6
6
|
//
|
|
7
7
|
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
8
10
|
class HybridGridTemplate: HybridGridTemplateSpec {
|
|
9
11
|
func createGridTemplate(config: GridTemplateConfig) throws {
|
|
10
12
|
let template = GridTemplate(config: config)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
13
|
+
|
|
14
|
+
TemplateStore.addTemplate(
|
|
15
|
+
template: template,
|
|
16
|
+
templateId: config.id
|
|
17
|
+
)
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
func updateGridTemplateButtons(
|
|
20
21
|
templateId: String,
|
|
21
22
|
buttons: [NitroGridButton]
|
|
22
|
-
) throws {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
) throws -> Promise<Void> {
|
|
24
|
+
return Promise.async {
|
|
25
|
+
guard
|
|
26
|
+
let template = TemplateStore.getTemplate(templateId: templateId)
|
|
27
|
+
as? GridTemplate
|
|
28
|
+
else {
|
|
29
|
+
throw AutoPlayError.templateNotFound(templateId)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
await template.updateButtons(buttons: buttons)
|
|
26
33
|
}
|
|
27
34
|
}
|
|
28
35
|
}
|
|
@@ -5,25 +5,33 @@
|
|
|
5
5
|
// Created by Samuel Brucksch on 05.11.25.
|
|
6
6
|
//
|
|
7
7
|
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
8
10
|
class HybridInformationTemplate: HybridInformationTemplateSpec {
|
|
9
11
|
|
|
10
12
|
func createInformationTemplate(config: InformationTemplateConfig) throws {
|
|
11
13
|
let template = InformationTemplate(config: config)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
)
|
|
17
|
-
}
|
|
14
|
+
TemplateStore.addTemplate(
|
|
15
|
+
template: template,
|
|
16
|
+
templateId: config.id
|
|
17
|
+
)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
func updateInformationTemplateSections(
|
|
21
21
|
templateId: String,
|
|
22
22
|
section: NitroSection
|
|
23
|
-
) throws {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
) throws -> Promise<Void> {
|
|
24
|
+
return Promise.async {
|
|
25
|
+
guard
|
|
26
|
+
let template = TemplateStore.getTemplate(templateId: templateId)
|
|
27
|
+
as? InformationTemplate
|
|
28
|
+
else {
|
|
29
|
+
throw AutoPlayError.invalidTemplateType(
|
|
30
|
+
"\(templateId) is not an InformationTemplate"
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
await template.updateSection(section: section)
|
|
27
35
|
}
|
|
28
36
|
}
|
|
29
37
|
}
|
|
@@ -5,24 +5,32 @@
|
|
|
5
5
|
// Created by Manuel Auer on 15.10.25.
|
|
6
6
|
//
|
|
7
7
|
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
8
10
|
class HybridListTemplate: HybridListTemplateSpec {
|
|
9
11
|
func createListTemplate(config: ListTemplateConfig) throws {
|
|
10
12
|
let template = ListTemplate(config: config)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
)
|
|
16
|
-
}
|
|
13
|
+
TemplateStore.addTemplate(
|
|
14
|
+
template: template,
|
|
15
|
+
templateId: config.id
|
|
16
|
+
)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
func updateListTemplateSections(
|
|
20
20
|
templateId: String,
|
|
21
21
|
sections: [NitroSection]?
|
|
22
|
-
) throws {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
) throws -> Promise<Void> {
|
|
23
|
+
return Promise.async {
|
|
24
|
+
guard
|
|
25
|
+
let template = TemplateStore.getTemplate(templateId: templateId)
|
|
26
|
+
as? ListTemplate
|
|
27
|
+
else {
|
|
28
|
+
throw AutoPlayError.invalidTemplateType(
|
|
29
|
+
"\(templateId) is not a ListTemplate"
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
await template.updateSections(sections: sections)
|
|
26
34
|
}
|
|
27
35
|
}
|
|
28
36
|
}
|
|
@@ -6,26 +6,34 @@
|
|
|
6
6
|
//
|
|
7
7
|
|
|
8
8
|
import CarPlay
|
|
9
|
+
import NitroModules
|
|
9
10
|
|
|
10
11
|
class HybridMapTemplate: HybridMapTemplateSpec {
|
|
11
12
|
func createMapTemplate(config: MapTemplateConfig) throws {
|
|
12
13
|
let template = MapTemplate(config: config)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
)
|
|
18
|
-
}
|
|
14
|
+
TemplateStore.addTemplate(
|
|
15
|
+
template: template,
|
|
16
|
+
templateId: config.id
|
|
17
|
+
)
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
func setTemplateMapButtons(templateId: String, buttons: [NitroMapButton]?)
|
|
22
|
-
throws
|
|
21
|
+
throws -> Promise<Void>
|
|
23
22
|
{
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
return Promise.async {
|
|
24
|
+
guard
|
|
25
|
+
let template = TemplateStore.getTemplate(templateId: templateId)
|
|
26
|
+
as? MapTemplate
|
|
27
|
+
else {
|
|
28
|
+
throw AutoPlayError.invalidTemplateError(
|
|
29
|
+
"\(templateId) is not a MapTemplate"
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
await MainActor.run {
|
|
34
|
+
template.config.mapButtons = buttons
|
|
35
|
+
template.invalidate()
|
|
36
|
+
}
|
|
29
37
|
}
|
|
30
38
|
}
|
|
31
39
|
|
|
@@ -8,12 +8,9 @@
|
|
|
8
8
|
class HybridMessageTemplate: HybridMessageTemplateSpec {
|
|
9
9
|
func createMessageTemplate(config: MessageTemplateConfig) throws {
|
|
10
10
|
let template = MessageTemplate(config: config)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
templateId: config.id
|
|
16
|
-
)
|
|
17
|
-
}
|
|
11
|
+
TemplateStore.addTemplate(
|
|
12
|
+
template: template,
|
|
13
|
+
templateId: config.id
|
|
14
|
+
)
|
|
18
15
|
}
|
|
19
16
|
}
|
|
@@ -5,21 +5,31 @@
|
|
|
5
5
|
// Created by Samuel Brucksch on 28.10.25.
|
|
6
6
|
//
|
|
7
7
|
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
8
10
|
class HybridSearchTemplate: HybridSearchTemplateSpec {
|
|
9
11
|
func createSearchTemplate(config: SearchTemplateConfig) throws {
|
|
10
12
|
let template = SearchTemplate(config: config)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
)
|
|
16
|
-
}
|
|
13
|
+
TemplateStore.addTemplate(
|
|
14
|
+
template: template,
|
|
15
|
+
templateId: config.id
|
|
16
|
+
)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
func updateSearchResults(templateId: String, results: NitroSection) throws
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
func updateSearchResults(templateId: String, results: NitroSection) throws
|
|
20
|
+
-> Promise<Void>
|
|
21
|
+
{
|
|
22
|
+
return Promise.async {
|
|
23
|
+
guard
|
|
24
|
+
let template = TemplateStore.getTemplate(templateId: templateId)
|
|
25
|
+
as? SearchTemplate
|
|
26
|
+
else {
|
|
27
|
+
throw AutoPlayError.invalidTemplateType(
|
|
28
|
+
"\(templateId) is not a SearchTemplate"
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
await template.updateSearchResults(results: results)
|
|
23
33
|
}
|
|
24
34
|
}
|
|
25
35
|
}
|
|
@@ -10,14 +10,11 @@ import CarPlay
|
|
|
10
10
|
@MainActor
|
|
11
11
|
class AutoPlayInterfaceController: NSObject, CPInterfaceControllerDelegate {
|
|
12
12
|
let interfaceController: CPInterfaceController
|
|
13
|
-
let templateStore: TemplateStore
|
|
14
13
|
|
|
15
14
|
init(
|
|
16
|
-
interfaceController: CPInterfaceController
|
|
17
|
-
templateStore: TemplateStore
|
|
15
|
+
interfaceController: CPInterfaceController
|
|
18
16
|
) {
|
|
19
17
|
self.interfaceController = interfaceController
|
|
20
|
-
self.templateStore = templateStore
|
|
21
18
|
|
|
22
19
|
super.init()
|
|
23
20
|
|
|
@@ -47,7 +44,7 @@ class AutoPlayInterfaceController: NSObject, CPInterfaceControllerDelegate {
|
|
|
47
44
|
var rootTemplateId: String? {
|
|
48
45
|
return interfaceController.rootTemplate.id
|
|
49
46
|
}
|
|
50
|
-
|
|
47
|
+
|
|
51
48
|
func pushTemplate(
|
|
52
49
|
_ templateToPush: CPTemplate,
|
|
53
50
|
animated: Bool
|
|
@@ -77,7 +74,7 @@ class AutoPlayInterfaceController: NSObject, CPInterfaceControllerDelegate {
|
|
|
77
74
|
animated: animated
|
|
78
75
|
)
|
|
79
76
|
|
|
80
|
-
|
|
77
|
+
TemplateStore.removeTemplate(templateId: templateId)
|
|
81
78
|
|
|
82
79
|
return templateId
|
|
83
80
|
}
|
|
@@ -100,7 +97,7 @@ class AutoPlayInterfaceController: NSObject, CPInterfaceControllerDelegate {
|
|
|
100
97
|
animated: animated
|
|
101
98
|
)
|
|
102
99
|
|
|
103
|
-
|
|
100
|
+
TemplateStore.removeTemplates(templateIds: templateIds)
|
|
104
101
|
|
|
105
102
|
return templateIds
|
|
106
103
|
}
|
|
@@ -157,7 +154,7 @@ class AutoPlayInterfaceController: NSObject, CPInterfaceControllerDelegate {
|
|
|
157
154
|
try await interfaceController.dismissTemplate(
|
|
158
155
|
animated: animated
|
|
159
156
|
)
|
|
160
|
-
|
|
157
|
+
|
|
161
158
|
return true
|
|
162
159
|
}
|
|
163
160
|
|
|
@@ -168,7 +165,7 @@ class AutoPlayInterfaceController: NSObject, CPInterfaceControllerDelegate {
|
|
|
168
165
|
) {
|
|
169
166
|
let templateId = aTemplate.id
|
|
170
167
|
|
|
171
|
-
|
|
168
|
+
TemplateStore.getTemplate(templateId: templateId)?.onWillAppear(
|
|
172
169
|
animated: animated
|
|
173
170
|
)
|
|
174
171
|
}
|
|
@@ -181,10 +178,10 @@ class AutoPlayInterfaceController: NSObject, CPInterfaceControllerDelegate {
|
|
|
181
178
|
|
|
182
179
|
if rootTemplateId == templateId {
|
|
183
180
|
// this makes sure we purge outdated CPSearchTemplate since that one can be popped on with a CarPlay native button we can not intercept
|
|
184
|
-
|
|
181
|
+
TemplateStore.purge()
|
|
185
182
|
}
|
|
186
183
|
|
|
187
|
-
|
|
184
|
+
TemplateStore.getTemplate(templateId: templateId)?.onDidAppear(
|
|
188
185
|
animated: animated
|
|
189
186
|
)
|
|
190
187
|
}
|
|
@@ -195,7 +192,7 @@ class AutoPlayInterfaceController: NSObject, CPInterfaceControllerDelegate {
|
|
|
195
192
|
) {
|
|
196
193
|
let templateId = aTemplate.id
|
|
197
194
|
|
|
198
|
-
|
|
195
|
+
TemplateStore.getTemplate(templateId: templateId)?.onWillDisappear(
|
|
199
196
|
animated: animated
|
|
200
197
|
)
|
|
201
198
|
}
|
|
@@ -206,12 +203,12 @@ class AutoPlayInterfaceController: NSObject, CPInterfaceControllerDelegate {
|
|
|
206
203
|
) {
|
|
207
204
|
let templateId = aTemplate.id
|
|
208
205
|
|
|
209
|
-
|
|
206
|
+
TemplateStore.getTemplate(templateId: templateId)?.onDidDisappear(
|
|
210
207
|
animated: animated
|
|
211
208
|
)
|
|
212
209
|
|
|
213
210
|
if aTemplate is CPAlertTemplate {
|
|
214
|
-
|
|
211
|
+
TemplateStore.removeTemplate(templateId: templateId)
|
|
215
212
|
|
|
216
213
|
HybridAutoPlay.removeListeners(
|
|
217
214
|
templateId: templateId
|
|
@@ -106,7 +106,7 @@ class AutoPlayScene: UIResponder {
|
|
|
106
106
|
|
|
107
107
|
open func traitCollectionDidChange(traitCollection: UITraitCollection) {
|
|
108
108
|
self.traitCollection = traitCollection
|
|
109
|
-
|
|
109
|
+
TemplateStore.traitCollectionDidChange()
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
open func safeAreaInsetsDidChange(safeAreaInsets: UIEdgeInsets) {
|
|
@@ -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()
|