@iternio/react-native-auto-play 0.5.14-beta.1 → 0.6.1
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/README.md +270 -36
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/AndroidAutoSession.kt +5 -0
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridMapTemplate.kt +9 -2
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/NativeBackdrop.kt +40 -0
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/VirtualRenderer.kt +52 -0
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/template/GridTemplate.kt +47 -13
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/template/Parser.kt +69 -15
- package/ios/Types.swift +3 -0
- package/ios/extensions/UIImage+Toggle.swift +5 -2
- package/ios/hybrid/HybridAutoPlay.swift +28 -16
- package/ios/hybrid/HybridMapTemplate.swift +22 -5
- package/ios/scenes/AutoPlayInterfaceController.swift +261 -72
- package/ios/templates/AutoPlayMapPanelDelegate.swift +190 -0
- package/ios/templates/AutoPlayTemplate.swift +24 -2
- package/ios/templates/GridTemplate.swift +57 -57
- package/ios/templates/InformationTemplate.swift +84 -9
- package/ios/templates/ListTemplate.swift +66 -11
- package/ios/templates/MapTemplate.swift +83 -68
- package/ios/templates/MessageTemplate.swift +72 -6
- package/ios/templates/Parser.swift +564 -69
- package/ios/templates/SearchTemplate.swift +1 -1
- package/ios/templates/TemplateStore.swift +5 -15
- package/ios/utils/SymbolFont.swift +13 -28
- package/jest.js +2 -0
- package/lib/Constants.d.ts +4 -0
- package/lib/Constants.js +6 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.web.d.ts +73 -0
- package/lib/index.web.js +72 -1
- package/lib/specs/MapTemplate.nitro.d.ts +3 -1
- package/lib/templates/GridTemplate.d.ts +23 -3
- package/lib/templates/GridTemplate.js +8 -0
- package/lib/templates/InformationTemplate.d.ts +38 -12
- package/lib/templates/ListTemplate.d.ts +16 -47
- package/lib/templates/MapTemplate.d.ts +26 -2
- package/lib/templates/MapTemplate.js +16 -2
- package/lib/templates/MessageTemplate.d.ts +52 -11
- package/lib/templates/MessageTemplate.js +1 -1
- package/lib/types/Image.d.ts +6 -1
- package/lib/utils/NitroColor.d.ts +1 -0
- package/lib/utils/NitroColor.js +8 -0
- package/lib/utils/NitroImage.js +1 -1
- package/lib/utils/NitroManeuver.js +1 -3
- package/lib/utils/NitroOptionsPanel.d.ts +103 -0
- package/lib/utils/NitroOptionsPanel.js +63 -0
- package/lib/utils/NitroSection.d.ts +89 -2
- package/lib/utils/NitroSection.js +49 -2
- package/lib-cjs/AutoPlayHeadlessJsTask.js +16 -0
- package/lib-cjs/Constants.js +9 -0
- package/lib-cjs/components/MapTemplateContext.js +10 -0
- package/lib-cjs/components/SafeAreaInsetsContext.js +21 -0
- package/lib-cjs/components/SafeAreaView.js +22 -0
- package/lib-cjs/components/WindowInformationWrapper.js +20 -0
- package/lib-cjs/hooks/useAndroidAutoTelemetry.js +115 -0
- package/lib-cjs/hooks/useFocusedEffect.js +35 -0
- package/lib-cjs/hooks/useMapTemplate.js +13 -0
- package/lib-cjs/hooks/useSafeAreaInsets.js +9 -0
- package/lib-cjs/hooks/useVoiceInput.js +42 -0
- package/lib-cjs/hybrid/HybridAndroidAutoTelemetry.js +4 -0
- package/lib-cjs/hybrid/HybridAndroidWindowInformation.js +4 -0
- package/lib-cjs/hybrid/HybridAutoPlay.js +5 -0
- package/lib-cjs/hybrid/HybridVoice.js +61 -0
- package/lib-cjs/index.js +76 -0
- package/lib-cjs/index.web.js +98 -0
- package/lib-cjs/scenes/AutoPlayCluster.js +140 -0
- package/lib-cjs/scenes/CarPlayDashboardScene.js +100 -0
- package/lib-cjs/specs/AndroidAutoTelemetry.nitro.js +2 -0
- package/lib-cjs/specs/AndroidAutomotive.nitro.js +16 -0
- package/lib-cjs/specs/AndroidWindowInformation.nitro.js +2 -0
- package/lib-cjs/specs/AutoPlay.nitro.js +2 -0
- package/lib-cjs/specs/CarPlayDashboard.nitro.js +2 -0
- package/lib-cjs/specs/Cluster.nitro.js +2 -0
- package/lib-cjs/specs/GridTemplate.nitro.js +2 -0
- package/lib-cjs/specs/InformationTemplate.nitro.js +2 -0
- package/lib-cjs/specs/ListTemplate.nitro.js +2 -0
- package/lib-cjs/specs/MapTemplate.nitro.js +2 -0
- package/lib-cjs/specs/MessageTemplate.nitro.js +2 -0
- package/lib-cjs/specs/SearchTemplate.nitro.js +2 -0
- package/lib-cjs/specs/SignInTemplate.nitro.js +2 -0
- package/lib-cjs/specs/Voice.nitro.js +2 -0
- package/lib-cjs/templates/GridTemplate.js +41 -0
- package/lib-cjs/templates/InformationTemplate.js +49 -0
- package/lib-cjs/templates/ListTemplate.js +33 -0
- package/lib-cjs/templates/MapTemplate.js +168 -0
- package/lib-cjs/templates/MessageTemplate.js +50 -0
- package/lib-cjs/templates/SearchTemplate.js +32 -0
- package/lib-cjs/templates/SignInTemplate.js +55 -0
- package/lib-cjs/templates/Template.js +40 -0
- package/lib-cjs/types/Button.js +12 -0
- package/lib-cjs/types/Event.js +2 -0
- package/lib-cjs/types/Image.js +2 -0
- package/lib-cjs/types/Maneuver.js +77 -0
- package/lib-cjs/types/RootComponent.js +2 -0
- package/lib-cjs/types/SignInMethod.js +22 -0
- package/lib-cjs/types/Telemetry.js +24 -0
- package/lib-cjs/types/Text.js +8 -0
- package/lib-cjs/types/Trip.js +2 -0
- package/lib-cjs/types/Voice.js +2 -0
- package/lib-cjs/utils/ErrorUtil.js +34 -0
- package/lib-cjs/utils/NitroAction.js +129 -0
- package/lib-cjs/utils/NitroAlert.js +19 -0
- package/lib-cjs/utils/NitroAttributedString.js +14 -0
- package/lib-cjs/utils/NitroColor.js +32 -0
- package/lib-cjs/utils/NitroGrid.js +12 -0
- package/lib-cjs/utils/NitroImage.js +97 -0
- package/lib-cjs/utils/NitroManeuver.js +79 -0
- package/lib-cjs/utils/NitroMapButton.js +33 -0
- package/lib-cjs/utils/NitroOptionsPanel.js +66 -0
- package/lib-cjs/utils/NitroSection.js +112 -0
- package/nitrogen/generated/android/ReactNativeAutoPlay+autolinking.cmake +1 -0
- package/nitrogen/generated/android/c++/JChargingConnector.hpp +79 -0
- package/nitrogen/generated/android/c++/JGridImageSize.hpp +64 -0
- package/nitrogen/generated/android/c++/JGridTemplateConfig.hpp +7 -1
- package/nitrogen/generated/android/c++/JHybridGridTemplateSpec.cpp +4 -0
- package/nitrogen/generated/android/c++/JHybridInformationTemplateSpec.cpp +12 -0
- package/nitrogen/generated/android/c++/JHybridListTemplateSpec.cpp +12 -0
- package/nitrogen/generated/android/c++/JHybridMapTemplateSpec.cpp +78 -3
- package/nitrogen/generated/android/c++/JHybridMapTemplateSpec.hpp +2 -1
- package/nitrogen/generated/android/c++/JHybridSearchTemplateSpec.cpp +12 -0
- package/nitrogen/generated/android/c++/JInformationTemplateConfig.hpp +6 -0
- package/nitrogen/generated/android/c++/JListImageType.hpp +67 -0
- package/nitrogen/generated/android/c++/JListTemplateConfig.hpp +6 -0
- package/nitrogen/generated/android/c++/JNitroChargerLocation.hpp +115 -0
- package/nitrogen/generated/android/c++/JNitroChargerOutlet.hpp +82 -0
- package/nitrogen/generated/android/c++/JNitroColor.hpp +8 -4
- package/nitrogen/generated/android/c++/JNitroOptionsPanelChargerSection.hpp +112 -0
- package/nitrogen/generated/android/c++/JNitroOptionsPanelConfig.hpp +157 -0
- package/nitrogen/generated/android/c++/JNitroOptionsPanelGridSection.hpp +102 -0
- package/nitrogen/generated/android/c++/JNitroOptionsPanelSection.cpp +30 -0
- package/nitrogen/generated/android/c++/JNitroOptionsPanelSection.hpp +129 -0
- package/nitrogen/generated/android/c++/JNitroRow.hpp +33 -3
- package/nitrogen/generated/android/c++/JNitroSection.hpp +6 -0
- package/nitrogen/generated/android/c++/JSearchTemplateConfig.hpp +6 -0
- package/nitrogen/generated/android/c++/JWaypointCoordinate.hpp +65 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/ChargingConnector.kt +30 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/GridImageSize.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/GridTemplateConfig.kt +9 -4
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridMapTemplateSpec.kt +5 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/ListImageType.kt +26 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroChargerLocation.kt +90 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroChargerOutlet.kt +70 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroColor.kt +9 -4
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroOptionsPanelChargerSection.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroOptionsPanelConfig.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroOptionsPanelGridSection.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroOptionsPanelSection.kt +75 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroRow.kt +36 -6
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/WaypointCoordinate.kt +61 -0
- package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Bridge.hpp +174 -0
- package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Umbrella.hpp +27 -0
- package/nitrogen/generated/ios/c++/HybridGridTemplateSpecSwift.hpp +3 -0
- package/nitrogen/generated/ios/c++/HybridInformationTemplateSpecSwift.hpp +9 -0
- package/nitrogen/generated/ios/c++/HybridListTemplateSpecSwift.hpp +9 -0
- package/nitrogen/generated/ios/c++/HybridMapTemplateSpecSwift.hpp +47 -1
- package/nitrogen/generated/ios/c++/HybridSearchTemplateSpecSwift.hpp +9 -0
- package/nitrogen/generated/ios/swift/ChargingConnector.swift +68 -0
- package/nitrogen/generated/ios/swift/GridImageSize.swift +48 -0
- package/nitrogen/generated/ios/swift/GridTemplateConfig.swift +12 -1
- package/nitrogen/generated/ios/swift/HybridMapTemplateSpec.swift +2 -1
- package/nitrogen/generated/ios/swift/HybridMapTemplateSpec_cxx.swift +31 -4
- package/nitrogen/generated/ios/swift/ListImageType.swift +52 -0
- package/nitrogen/generated/ios/swift/NitroChargerLocation.swift +161 -0
- package/nitrogen/generated/ios/swift/NitroChargerOutlet.swift +65 -0
- package/nitrogen/generated/ios/swift/NitroColor.swift +20 -2
- package/nitrogen/generated/ios/swift/NitroOptionsPanelChargerSection.swift +64 -0
- package/nitrogen/generated/ios/swift/NitroOptionsPanelConfig.swift +94 -0
- package/nitrogen/generated/ios/swift/NitroOptionsPanelGridSection.swift +53 -0
- package/nitrogen/generated/ios/swift/NitroOptionsPanelSection.swift +32 -0
- package/nitrogen/generated/ios/swift/NitroRow.swift +81 -1
- package/nitrogen/generated/ios/swift/WaypointCoordinate.swift +52 -0
- package/nitrogen/generated/shared/c++/ChargingConnector.hpp +104 -0
- package/nitrogen/generated/shared/c++/GridImageSize.hpp +84 -0
- package/nitrogen/generated/shared/c++/GridTemplateConfig.hpp +8 -1
- package/nitrogen/generated/shared/c++/HybridMapTemplateSpec.cpp +1 -0
- package/nitrogen/generated/shared/c++/HybridMapTemplateSpec.hpp +5 -1
- package/nitrogen/generated/shared/c++/ListImageType.hpp +88 -0
- package/nitrogen/generated/shared/c++/NitroChargerLocation.hpp +131 -0
- package/nitrogen/generated/shared/c++/NitroChargerOutlet.hpp +98 -0
- package/nitrogen/generated/shared/c++/NitroColor.hpp +7 -3
- package/nitrogen/generated/shared/c++/NitroOptionsPanelChargerSection.hpp +98 -0
- package/nitrogen/generated/shared/c++/NitroOptionsPanelConfig.hpp +107 -0
- package/nitrogen/generated/shared/c++/NitroOptionsPanelGridSection.hpp +91 -0
- package/nitrogen/generated/shared/c++/NitroRow.hpp +39 -2
- package/nitrogen/generated/shared/c++/WaypointCoordinate.hpp +91 -0
- package/package.json +7 -3
- package/src/Constants.ts +9 -0
- package/src/index.ts +1 -0
- package/src/index.web.ts +166 -0
- package/src/specs/MapTemplate.nitro.ts +3 -1
- package/src/templates/GridTemplate.ts +38 -3
- package/src/templates/InformationTemplate.ts +60 -29
- package/src/templates/ListTemplate.ts +27 -55
- package/src/templates/MapTemplate.ts +60 -2
- package/src/templates/MessageTemplate.ts +71 -24
- package/src/types/Image.ts +6 -1
- package/src/utils/NitroColor.ts +10 -1
- package/src/utils/NitroImage.ts +1 -5
- package/src/utils/NitroManeuver.ts +1 -4
- package/src/utils/NitroOptionsPanel.ts +218 -0
- package/src/utils/NitroSection.ts +160 -5
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AutoPlayCluster = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const react_native_1 = require("react-native");
|
|
9
|
+
const react_native_nitro_modules_1 = require("react-native-nitro-modules");
|
|
10
|
+
const SafeAreaInsetsContext_1 = require("../components/SafeAreaInsetsContext");
|
|
11
|
+
const WindowInformationWrapper_1 = require("../components/WindowInformationWrapper");
|
|
12
|
+
const NitroImage_1 = require("../utils/NitroImage");
|
|
13
|
+
const HybridCluster = react_native_nitro_modules_1.NitroModules.createHybridObject('Cluster');
|
|
14
|
+
class Cluster {
|
|
15
|
+
component = null;
|
|
16
|
+
attributedInactiveDescriptionVariants = [];
|
|
17
|
+
/**
|
|
18
|
+
* Holds all cluster scene/session IDs and if they have a window/surface connected
|
|
19
|
+
*/
|
|
20
|
+
clusters = {};
|
|
21
|
+
constructor() {
|
|
22
|
+
HybridCluster.addListener('didConnect', (clusterId) => {
|
|
23
|
+
if (this.clusters[clusterId] != null) {
|
|
24
|
+
// in case didConnectWithWindow fires before didConnect
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
this.clusters[clusterId] = false;
|
|
28
|
+
this.applyAttributedInactiveDescriptionVariants();
|
|
29
|
+
});
|
|
30
|
+
HybridCluster.addListener('didConnectWithWindow', (clusterId) => {
|
|
31
|
+
this.clusters[clusterId] = false;
|
|
32
|
+
this.registerComponent().catch((e) => {
|
|
33
|
+
console.error(e);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
HybridCluster.addListener('didDisconnectFromWindow', (clusterId) => {
|
|
37
|
+
if (this.clusters[clusterId] == null) {
|
|
38
|
+
// in case didDisconnect fires before didDisconnectFromWindow
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
this.clusters[clusterId] = false;
|
|
42
|
+
});
|
|
43
|
+
HybridCluster.addListener('didDisconnect', (clusterId) => {
|
|
44
|
+
delete this.clusters[clusterId];
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
async registerComponent() {
|
|
48
|
+
const { component } = this;
|
|
49
|
+
if (component == null) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const clusterIds = Object.entries(this.clusters)
|
|
53
|
+
.filter(([_, registered]) => !registered)
|
|
54
|
+
.map(([clusterId]) => clusterId);
|
|
55
|
+
for (const clusterId of clusterIds) {
|
|
56
|
+
react_native_1.AppRegistry.registerComponent(clusterId, () => (props) => react_1.default.createElement(SafeAreaInsetsContext_1.SafeAreaInsetsProvider, {
|
|
57
|
+
moduleName: clusterId,
|
|
58
|
+
// biome-ignore lint/correctness/noChildrenProp: there is no other way in a ts file
|
|
59
|
+
children: react_1.default.createElement(WindowInformationWrapper_1.WindowInformationWrapper, {
|
|
60
|
+
moduleName: clusterId,
|
|
61
|
+
component,
|
|
62
|
+
componentProps: props,
|
|
63
|
+
}),
|
|
64
|
+
}));
|
|
65
|
+
this.clusters[clusterId] = true;
|
|
66
|
+
await HybridCluster.initRootView(clusterId);
|
|
67
|
+
}
|
|
68
|
+
this.applyAttributedInactiveDescriptionVariants();
|
|
69
|
+
}
|
|
70
|
+
applyAttributedInactiveDescriptionVariants() {
|
|
71
|
+
if (react_native_1.Platform.OS !== 'ios') {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const variants = this.attributedInactiveDescriptionVariants.map((v) => ({
|
|
75
|
+
...v,
|
|
76
|
+
images: v.images?.map((i) => ({ ...i, image: NitroImage_1.NitroImageUtil.convert(i.image) })),
|
|
77
|
+
}));
|
|
78
|
+
for (const clusterId of Object.keys(this.clusters)) {
|
|
79
|
+
HybridCluster.setAttributedInactiveDescriptionVariants(clusterId, variants);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
setComponent(component) {
|
|
83
|
+
if (this.component != null) {
|
|
84
|
+
throw new Error('ClusterScene.setComponent can be called once only');
|
|
85
|
+
}
|
|
86
|
+
this.component = component;
|
|
87
|
+
return this.registerComponent();
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* sets the text that is shown while no navigation is ongoing
|
|
91
|
+
* applies specified strings to all connected cluster of content type "Instruction Card"
|
|
92
|
+
* @namespace iOS
|
|
93
|
+
*/
|
|
94
|
+
setAttributedInactiveDescriptionVariants(attributedInactiveDescriptionVariants) {
|
|
95
|
+
if (react_native_1.Platform.OS !== 'ios') {
|
|
96
|
+
console.warn(`ClusterScene.setAttributedInactiveDescriptionVariants not supported for ${react_native_1.Platform.OS}`);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
this.attributedInactiveDescriptionVariants = attributedInactiveDescriptionVariants;
|
|
100
|
+
this.applyAttributedInactiveDescriptionVariants();
|
|
101
|
+
}
|
|
102
|
+
addListenerColorScheme(callback) {
|
|
103
|
+
return HybridCluster.addListenerColorScheme(callback);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* add listener for cluster zoom buttons
|
|
107
|
+
* @namespace iOS
|
|
108
|
+
*/
|
|
109
|
+
addListenerZoom(callback) {
|
|
110
|
+
if (react_native_1.Platform.OS !== 'ios') {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
return HybridCluster.addListenerZoom(callback);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* add listener for compass enable/disable
|
|
117
|
+
* @namespace iOS
|
|
118
|
+
*/
|
|
119
|
+
addListenerCompass(callback) {
|
|
120
|
+
if (react_native_1.Platform.OS !== 'ios') {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
return HybridCluster.addListenerCompass(callback);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* add listener for speed limit enable/disable
|
|
127
|
+
* @namespace iOS
|
|
128
|
+
*/
|
|
129
|
+
addListenerSpeedLimit(callback) {
|
|
130
|
+
if (react_native_1.Platform.OS !== 'ios') {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
return HybridCluster.addListenerSpeedLimit(callback);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* @namespace Android
|
|
138
|
+
* @namespace iOS >= 15.4
|
|
139
|
+
*/
|
|
140
|
+
exports.AutoPlayCluster = new Cluster();
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CarPlayDashboard = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const react_native_1 = require("react-native");
|
|
9
|
+
const react_native_nitro_modules_1 = require("react-native-nitro-modules");
|
|
10
|
+
const SafeAreaInsetsContext_1 = require("../components/SafeAreaInsetsContext");
|
|
11
|
+
const HybridAutoPlay_1 = require("../hybrid/HybridAutoPlay");
|
|
12
|
+
const NitroImage_1 = require("../utils/NitroImage");
|
|
13
|
+
const HybridCarPlayDashboard = react_native_1.Platform.OS === 'ios'
|
|
14
|
+
? react_native_nitro_modules_1.NitroModules.createHybridObject('CarPlayDashboard')
|
|
15
|
+
: null;
|
|
16
|
+
class Dashboard {
|
|
17
|
+
component = null;
|
|
18
|
+
componentRegistered = false;
|
|
19
|
+
isConnected = false;
|
|
20
|
+
id = 'CarPlayDashboard';
|
|
21
|
+
constructor() {
|
|
22
|
+
if (HybridCarPlayDashboard == null) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
HybridCarPlayDashboard.addListener('didConnect', () => this.setIsConnected(true));
|
|
26
|
+
HybridCarPlayDashboard.addListener('didDisconnect', () => this.setIsConnected(false));
|
|
27
|
+
}
|
|
28
|
+
setIsConnected(isConnected) {
|
|
29
|
+
this.isConnected = isConnected;
|
|
30
|
+
this.registerComponent();
|
|
31
|
+
}
|
|
32
|
+
registerComponent() {
|
|
33
|
+
if (HybridCarPlayDashboard == null) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const { component, isConnected } = this;
|
|
37
|
+
if (component == null) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (!this.componentRegistered) {
|
|
41
|
+
react_native_1.AppRegistry.registerComponent(this.id, () => (props) => react_1.default.createElement(SafeAreaInsetsContext_1.SafeAreaInsetsProvider, {
|
|
42
|
+
moduleName: this.id,
|
|
43
|
+
// biome-ignore lint/correctness/noChildrenProp: there is no other way in a ts file
|
|
44
|
+
children: react_1.default.createElement(component, props),
|
|
45
|
+
}));
|
|
46
|
+
this.componentRegistered = true;
|
|
47
|
+
}
|
|
48
|
+
if (isConnected) {
|
|
49
|
+
HybridCarPlayDashboard.initRootView();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
setComponent(component) {
|
|
53
|
+
if (react_native_1.Platform.OS !== 'ios') {
|
|
54
|
+
console.warn(`CarPlayDashboard.setComponent is not supported on ${react_native_1.Platform.OS}`);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (this.component != null) {
|
|
58
|
+
throw new Error('CarPlayDashboard.setComponent can be called once only');
|
|
59
|
+
}
|
|
60
|
+
this.component = component;
|
|
61
|
+
this.registerComponent();
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* sets the dashboard shortcut buttons, make sure to supply at least one button as soon as possible,
|
|
65
|
+
* otherwise the dashboard will not show up!
|
|
66
|
+
* @namespace iOS
|
|
67
|
+
*/
|
|
68
|
+
setButtons(buttons) {
|
|
69
|
+
if (HybridCarPlayDashboard == null) {
|
|
70
|
+
console.warn(`CarPlayDashboard.setButtons is not supported on ${react_native_1.Platform.OS}`);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
HybridCarPlayDashboard.setButtons(buttons.map((button) => ({ ...button, image: NitroImage_1.NitroImageUtil.convert(button.image) })));
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* attach a listener for generic notifications like didConnect, didDisconnect, ...
|
|
77
|
+
* @namespace iOS
|
|
78
|
+
* @param eventType generic events
|
|
79
|
+
* @returns callback to remove the listener
|
|
80
|
+
*/
|
|
81
|
+
addListener(event, callback) {
|
|
82
|
+
if (HybridCarPlayDashboard == null) {
|
|
83
|
+
throw new Error(`CarPlayDashboard.addListener is not supported on ${react_native_1.Platform.OS}`);
|
|
84
|
+
}
|
|
85
|
+
return HybridCarPlayDashboard.addListener(event, callback);
|
|
86
|
+
}
|
|
87
|
+
addListenerRenderState(callback) {
|
|
88
|
+
if (HybridCarPlayDashboard == null) {
|
|
89
|
+
throw new Error(`CarPlayDashboard.addListener is not supported on ${react_native_1.Platform.OS}`);
|
|
90
|
+
}
|
|
91
|
+
return HybridAutoPlay_1.HybridAutoPlay.addListenerRenderState(this.id, callback);
|
|
92
|
+
}
|
|
93
|
+
addListenerColorScheme(callback) {
|
|
94
|
+
if (HybridCarPlayDashboard == null) {
|
|
95
|
+
throw new Error(`CarPlayDashboard.addListener is not supported on ${react_native_1.Platform.OS}`);
|
|
96
|
+
}
|
|
97
|
+
return HybridCarPlayDashboard.addListenerColorScheme(callback);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.CarPlayDashboard = new Dashboard();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CarUxRestrictions = void 0;
|
|
4
|
+
var CarUxRestrictions;
|
|
5
|
+
(function (CarUxRestrictions) {
|
|
6
|
+
CarUxRestrictions[CarUxRestrictions["UX_RESTRICTIONS_FULLY_RESTRICTED"] = 511] = "UX_RESTRICTIONS_FULLY_RESTRICTED";
|
|
7
|
+
CarUxRestrictions[CarUxRestrictions["UX_RESTRICTIONS_LIMIT_CONTENT"] = 32] = "UX_RESTRICTIONS_LIMIT_CONTENT";
|
|
8
|
+
CarUxRestrictions[CarUxRestrictions["UX_RESTRICTIONS_LIMIT_STRING_LENGTH"] = 4] = "UX_RESTRICTIONS_LIMIT_STRING_LENGTH";
|
|
9
|
+
CarUxRestrictions[CarUxRestrictions["UX_RESTRICTIONS_NO_DIALPAD"] = 1] = "UX_RESTRICTIONS_NO_DIALPAD";
|
|
10
|
+
CarUxRestrictions[CarUxRestrictions["UX_RESTRICTIONS_NO_FILTERING"] = 2] = "UX_RESTRICTIONS_NO_FILTERING";
|
|
11
|
+
CarUxRestrictions[CarUxRestrictions["UX_RESTRICTIONS_NO_KEYBOARD"] = 8] = "UX_RESTRICTIONS_NO_KEYBOARD";
|
|
12
|
+
CarUxRestrictions[CarUxRestrictions["UX_RESTRICTIONS_NO_SETUP"] = 64] = "UX_RESTRICTIONS_NO_SETUP";
|
|
13
|
+
CarUxRestrictions[CarUxRestrictions["UX_RESTRICTIONS_NO_TEXT_MESSAGE"] = 128] = "UX_RESTRICTIONS_NO_TEXT_MESSAGE";
|
|
14
|
+
CarUxRestrictions[CarUxRestrictions["UX_RESTRICTIONS_NO_VIDEO"] = 16] = "UX_RESTRICTIONS_NO_VIDEO";
|
|
15
|
+
CarUxRestrictions[CarUxRestrictions["UX_RESTRICTIONS_NO_VOICE_TRANSCRIPTION"] = 256] = "UX_RESTRICTIONS_NO_VOICE_TRANSCRIPTION";
|
|
16
|
+
})(CarUxRestrictions || (exports.CarUxRestrictions = CarUxRestrictions = {}));
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GridTemplate = void 0;
|
|
4
|
+
const react_native_1 = require("react-native");
|
|
5
|
+
const react_native_nitro_modules_1 = require("react-native-nitro-modules");
|
|
6
|
+
const NitroAction_1 = require("../utils/NitroAction");
|
|
7
|
+
const NitroGrid_1 = require("../utils/NitroGrid");
|
|
8
|
+
const NitroMapButton_1 = require("../utils/NitroMapButton");
|
|
9
|
+
const Template_1 = require("./Template");
|
|
10
|
+
const HybridGridTemplate = react_native_nitro_modules_1.NitroModules.createHybridObject('GridTemplate');
|
|
11
|
+
class GridTemplate extends Template_1.Template {
|
|
12
|
+
template = this;
|
|
13
|
+
constructor(config) {
|
|
14
|
+
super(config);
|
|
15
|
+
const { headerActions, buttons, mapConfig, ...rest } = config;
|
|
16
|
+
if (__DEV__ &&
|
|
17
|
+
react_native_1.Platform.OS === 'android' &&
|
|
18
|
+
mapConfig != null &&
|
|
19
|
+
rest.imageSize != null &&
|
|
20
|
+
rest.imageSize !== 'unset') {
|
|
21
|
+
console.warn('GridTemplate: imageSize is ignored on Android when mapConfig is set — MapWithContentTemplate does not support the sized grid content type');
|
|
22
|
+
}
|
|
23
|
+
const nitroConfig = {
|
|
24
|
+
...rest,
|
|
25
|
+
id: this.id,
|
|
26
|
+
headerActions: NitroAction_1.NitroActionUtil.convert(this.template, headerActions),
|
|
27
|
+
buttons: NitroGrid_1.NitroGridUtil.convert(this.template, buttons),
|
|
28
|
+
mapConfig: mapConfig
|
|
29
|
+
? {
|
|
30
|
+
mapButtons: NitroMapButton_1.NitroMapButton.convert(this.template, mapConfig.mapButtons),
|
|
31
|
+
headerActions: NitroAction_1.NitroActionUtil.convert(this.template, mapConfig.headerActions),
|
|
32
|
+
}
|
|
33
|
+
: undefined,
|
|
34
|
+
};
|
|
35
|
+
HybridGridTemplate.createGridTemplate(nitroConfig);
|
|
36
|
+
}
|
|
37
|
+
updateGrid(buttons) {
|
|
38
|
+
return HybridGridTemplate.updateGridTemplateButtons(this.id, NitroGrid_1.NitroGridUtil.convert(this.template, buttons));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.GridTemplate = GridTemplate;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InformationTemplate = void 0;
|
|
4
|
+
const react_native_1 = require("react-native");
|
|
5
|
+
const react_native_nitro_modules_1 = require("react-native-nitro-modules");
|
|
6
|
+
const NitroAction_1 = require("../utils/NitroAction");
|
|
7
|
+
const NitroMapButton_1 = require("../utils/NitroMapButton");
|
|
8
|
+
const NitroSection_1 = require("../utils/NitroSection");
|
|
9
|
+
const Template_1 = require("./Template");
|
|
10
|
+
const HybridInformationTemplate = react_native_nitro_modules_1.NitroModules.createHybridObject('InformationTemplate');
|
|
11
|
+
class InformationTemplate extends Template_1.Template {
|
|
12
|
+
template = this;
|
|
13
|
+
constructor(config) {
|
|
14
|
+
super(config);
|
|
15
|
+
const { headerActions, mapConfig, items, actions, ...rest } = config;
|
|
16
|
+
const platformActions = react_native_1.Platform.OS === 'android'
|
|
17
|
+
? NitroAction_1.NitroActionUtil.convert(this.template, actions?.android)
|
|
18
|
+
: NitroAction_1.NitroActionUtil.convert(this.template, actions?.ios);
|
|
19
|
+
const section = this.getSection(items);
|
|
20
|
+
const nitroConfig = {
|
|
21
|
+
...rest,
|
|
22
|
+
id: this.id,
|
|
23
|
+
headerActions: NitroAction_1.NitroActionUtil.convert(this.template, headerActions),
|
|
24
|
+
actions: platformActions,
|
|
25
|
+
section: NitroSection_1.NitroSectionUtil.convert(this.template, section)?.at(0) ?? {
|
|
26
|
+
items: [],
|
|
27
|
+
type: 'default',
|
|
28
|
+
},
|
|
29
|
+
mapConfig: mapConfig
|
|
30
|
+
? {
|
|
31
|
+
mapButtons: NitroMapButton_1.NitroMapButton.convert(this.template, mapConfig.mapButtons),
|
|
32
|
+
headerActions: NitroAction_1.NitroActionUtil.convert(this.template, mapConfig.headerActions),
|
|
33
|
+
}
|
|
34
|
+
: undefined,
|
|
35
|
+
};
|
|
36
|
+
HybridInformationTemplate.createInformationTemplate(nitroConfig);
|
|
37
|
+
}
|
|
38
|
+
updateItems(items) {
|
|
39
|
+
const section = this.getSection(items);
|
|
40
|
+
return HybridInformationTemplate.updateInformationTemplateSections(this.id, NitroSection_1.NitroSectionUtil.convert(this.template, section)?.at(0) ?? { items: [], type: 'default' });
|
|
41
|
+
}
|
|
42
|
+
getSection(items) {
|
|
43
|
+
return {
|
|
44
|
+
type: 'default',
|
|
45
|
+
items: items ?? [],
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.InformationTemplate = InformationTemplate;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ListTemplate = void 0;
|
|
4
|
+
const react_native_nitro_modules_1 = require("react-native-nitro-modules");
|
|
5
|
+
const NitroAction_1 = require("../utils/NitroAction");
|
|
6
|
+
const NitroMapButton_1 = require("../utils/NitroMapButton");
|
|
7
|
+
const NitroSection_1 = require("../utils/NitroSection");
|
|
8
|
+
const Template_1 = require("./Template");
|
|
9
|
+
const HybridListTemplate = react_native_nitro_modules_1.NitroModules.createHybridObject('ListTemplate');
|
|
10
|
+
class ListTemplate extends Template_1.Template {
|
|
11
|
+
template = this;
|
|
12
|
+
constructor(config) {
|
|
13
|
+
super(config);
|
|
14
|
+
const { headerActions, mapConfig, sections, ...rest } = config;
|
|
15
|
+
const nitroConfig = {
|
|
16
|
+
...rest,
|
|
17
|
+
id: this.id,
|
|
18
|
+
headerActions: NitroAction_1.NitroActionUtil.convert(this.template, headerActions),
|
|
19
|
+
sections: NitroSection_1.NitroSectionUtil.convert(this.template, sections),
|
|
20
|
+
mapConfig: mapConfig
|
|
21
|
+
? {
|
|
22
|
+
mapButtons: NitroMapButton_1.NitroMapButton.convert(this.template, mapConfig.mapButtons),
|
|
23
|
+
headerActions: NitroAction_1.NitroActionUtil.convert(this.template, mapConfig.headerActions),
|
|
24
|
+
}
|
|
25
|
+
: undefined,
|
|
26
|
+
};
|
|
27
|
+
HybridListTemplate.createListTemplate(nitroConfig);
|
|
28
|
+
}
|
|
29
|
+
updateSections(sections) {
|
|
30
|
+
return HybridListTemplate.updateListTemplateSections(this.id, NitroSection_1.NitroSectionUtil.convert(this.template, sections));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.ListTemplate = ListTemplate;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.MapTemplate = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const react_native_1 = require("react-native");
|
|
9
|
+
const react_native_nitro_modules_1 = require("react-native-nitro-modules");
|
|
10
|
+
const MapTemplateContext_1 = require("../components/MapTemplateContext");
|
|
11
|
+
const SafeAreaInsetsContext_1 = require("../components/SafeAreaInsetsContext");
|
|
12
|
+
const WindowInformationWrapper_1 = require("../components/WindowInformationWrapper");
|
|
13
|
+
const HybridAutoPlay_1 = require("../hybrid/HybridAutoPlay");
|
|
14
|
+
const NitroAction_1 = require("../utils/NitroAction");
|
|
15
|
+
const NitroAlert_1 = require("../utils/NitroAlert");
|
|
16
|
+
const NitroColor_1 = require("../utils/NitroColor");
|
|
17
|
+
const NitroManeuver_1 = require("../utils/NitroManeuver");
|
|
18
|
+
const NitroMapButton_1 = require("../utils/NitroMapButton");
|
|
19
|
+
const NitroOptionsPanel_1 = require("../utils/NitroOptionsPanel");
|
|
20
|
+
const Template_1 = require("./Template");
|
|
21
|
+
const HybridMapTemplate = react_native_nitro_modules_1.NitroModules.createHybridObject('MapTemplate');
|
|
22
|
+
class MapTemplate extends Template_1.Template {
|
|
23
|
+
id = 'AutoPlayRoot';
|
|
24
|
+
template = this;
|
|
25
|
+
constructor(config) {
|
|
26
|
+
super(config);
|
|
27
|
+
const { component, mapButtons, headerActions, onStopNavigation, onAutoDriveEnabled, defaultGuidanceBackgroundColor, optionsPanel, ...baseConfig } = config;
|
|
28
|
+
react_native_1.AppRegistry.registerComponent(this.id, () => (props) => react_1.default.createElement(MapTemplateContext_1.MapTemplateProvider, {
|
|
29
|
+
mapTemplate: this.template,
|
|
30
|
+
// biome-ignore lint/correctness/noChildrenProp: there is no other way in a ts file
|
|
31
|
+
children: react_1.default.createElement(SafeAreaInsetsContext_1.SafeAreaInsetsProvider, {
|
|
32
|
+
moduleName: this.id,
|
|
33
|
+
// biome-ignore lint/correctness/noChildrenProp: there is no other way in a ts file
|
|
34
|
+
children: react_1.default.createElement(WindowInformationWrapper_1.WindowInformationWrapper, {
|
|
35
|
+
moduleName: this.id,
|
|
36
|
+
component,
|
|
37
|
+
componentProps: props,
|
|
38
|
+
}),
|
|
39
|
+
}),
|
|
40
|
+
}));
|
|
41
|
+
const nitroConfig = {
|
|
42
|
+
...baseConfig,
|
|
43
|
+
id: this.id,
|
|
44
|
+
headerActions: NitroAction_1.NitroActionUtil.convert(this.template, headerActions),
|
|
45
|
+
mapButtons: NitroMapButton_1.NitroMapButton.convert(this.template, mapButtons),
|
|
46
|
+
onStopNavigation: () => onStopNavigation(this.template),
|
|
47
|
+
onAutoDriveEnabled: onAutoDriveEnabled ? () => onAutoDriveEnabled(this.template) : undefined,
|
|
48
|
+
defaultGuidanceBackgroundColor: defaultGuidanceBackgroundColor != null
|
|
49
|
+
? NitroColor_1.NitroColorUtil.convert(defaultGuidanceBackgroundColor)
|
|
50
|
+
: undefined,
|
|
51
|
+
};
|
|
52
|
+
HybridMapTemplate.createMapTemplate(nitroConfig);
|
|
53
|
+
// routed through updateOptionsPanel, not embedded in nitroConfig above — nitrogen can't generate
|
|
54
|
+
// a spec for a variant type nested that deep inside NitroMapTemplateConfig.
|
|
55
|
+
this.updateOptionsPanel(optionsPanel);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* @namespace iOS updates the panel shown when tapping the ellipsis button
|
|
59
|
+
* next to the travel estimates during navigation (iOS 27+).
|
|
60
|
+
*/
|
|
61
|
+
updateOptionsPanel(optionsPanel) {
|
|
62
|
+
if (react_native_1.Platform.OS !== 'ios') {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
return HybridMapTemplate.updateOptionsPanel(this.id, NitroOptionsPanel_1.NitroOptionsPanelUtil.convert(this.template, optionsPanel));
|
|
66
|
+
}
|
|
67
|
+
setMapButtons(mapButtons) {
|
|
68
|
+
const buttons = NitroMapButton_1.NitroMapButton.convert(this.template, mapButtons);
|
|
69
|
+
return HybridMapTemplate.setTemplateMapButtons(this.id, buttons);
|
|
70
|
+
}
|
|
71
|
+
setHeaderActions(headerActions) {
|
|
72
|
+
const nitroActions = NitroAction_1.NitroActionUtil.convert(this.template, headerActions);
|
|
73
|
+
return HybridAutoPlay_1.HybridAutoPlay.setTemplateHeaderActions(this.id, nitroActions);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* brings up a navigation alert
|
|
77
|
+
* ⚠️ updating an existing alert is currently broken on Android Automotive, it brings up a new alert for each call
|
|
78
|
+
* @returns a callback to dismiss or update the navigation alert
|
|
79
|
+
*/
|
|
80
|
+
showAlert(alert) {
|
|
81
|
+
return HybridMapTemplate.showNavigationAlert(this.id, NitroAlert_1.NitroAlertUtil.convert(alert));
|
|
82
|
+
}
|
|
83
|
+
updateAlert(alertId, title, subtitle) {
|
|
84
|
+
HybridMapTemplate.updateNavigationAlert(this.id, alertId, title, subtitle);
|
|
85
|
+
}
|
|
86
|
+
dismissAlert(alertId) {
|
|
87
|
+
HybridMapTemplate.dismissNavigationAlert(this.id, alertId);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* @namespace Android brings up a custom trip selector mimicking the CarPlay trip selector as close as possible
|
|
91
|
+
* @namespace iOS brings up the stock CarPlay trip selector
|
|
92
|
+
* @returns a callback to update the shown trip
|
|
93
|
+
*/
|
|
94
|
+
showTripSelector({ trips, selectedTripId, textConfig, onTripSelected, onTripStarted, onBackPressed, mapButtons, }) {
|
|
95
|
+
if (trips.length === 0 ||
|
|
96
|
+
trips.some((t) => t.routeChoices.length === 0 || t.routeChoices.some((r) => r.steps.length < 2))) {
|
|
97
|
+
throw new Error('Invalid trips passed, either no trips or some trips routeChoice or steps are empty');
|
|
98
|
+
}
|
|
99
|
+
if (__DEV__ &&
|
|
100
|
+
react_native_1.Platform.OS === 'android' &&
|
|
101
|
+
new Set(trips.flatMap((t) => t.routeChoices.flatMap((r) => r.steps.at(-1)?.name))).size > 1) {
|
|
102
|
+
console.warn('found non distinct destination names, while this is possible it might lead to exceeding the step count, check https://developer.android.com/design/ui/cars/guides/ux-requirements/plan-task-flows#steps-refreshes for details');
|
|
103
|
+
}
|
|
104
|
+
const buttons = NitroMapButton_1.NitroMapButton.convert(this.template, mapButtons);
|
|
105
|
+
return HybridMapTemplate.showTripSelector(this.id, trips, selectedTripId, textConfig, onTripSelected, onTripStarted, onBackPressed, buttons ?? []);
|
|
106
|
+
}
|
|
107
|
+
hideTripSelector() {
|
|
108
|
+
HybridMapTemplate.hideTripSelector(this.id);
|
|
109
|
+
}
|
|
110
|
+
updateVisibleTravelEstimate(visibleTravelEstimate) {
|
|
111
|
+
HybridMapTemplate.updateVisibleTravelEstimate(this.id, visibleTravelEstimate);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* updates travel estimates
|
|
115
|
+
* @param steps all future steps, do not put in origin or passed steps
|
|
116
|
+
*/
|
|
117
|
+
updateTravelEstimates(steps) {
|
|
118
|
+
HybridMapTemplate.updateTravelEstimates(this.id, steps);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* sets or updates maneuvers, make sure to call startNavigation first!
|
|
122
|
+
* @namespace Android sets all the supplied maneuvers whenever called
|
|
123
|
+
* @namespace iOS will update travelEstimates only when passing in maneuvers with the same id
|
|
124
|
+
*/
|
|
125
|
+
updateManeuvers(maneuvers) {
|
|
126
|
+
if (Array.isArray(maneuvers)) {
|
|
127
|
+
const nitroManeuvers = maneuvers.reduce((acc, maneuver) => {
|
|
128
|
+
if (maneuver == null) {
|
|
129
|
+
return acc;
|
|
130
|
+
}
|
|
131
|
+
acc.push(NitroManeuver_1.NitroManeuverUtil.convert(maneuver));
|
|
132
|
+
return acc;
|
|
133
|
+
}, []);
|
|
134
|
+
HybridMapTemplate.updateManeuvers(this.id, nitroManeuvers);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if (maneuvers.type === 'loading') {
|
|
138
|
+
HybridMapTemplate.updateManeuvers(this.id, {
|
|
139
|
+
isLoading: true,
|
|
140
|
+
cardBackgroundColor: NitroColor_1.NitroColorUtil.convert(maneuvers.cardBackgroundColor),
|
|
141
|
+
text: maneuvers.text != null ? maneuvers.text : undefined,
|
|
142
|
+
});
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const messageManeuver = NitroManeuver_1.NitroManeuverUtil.convert(maneuvers);
|
|
146
|
+
HybridMapTemplate.updateManeuvers(this.id, messageManeuver);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* either use showTripSelector to show a set of trips and let the user start the navigation session
|
|
150
|
+
* or use this to start a navigation session without asking the user
|
|
151
|
+
*/
|
|
152
|
+
startNavigation(trip) {
|
|
153
|
+
return HybridMapTemplate.startNavigation(this.id, trip);
|
|
154
|
+
}
|
|
155
|
+
stopNavigation() {
|
|
156
|
+
HybridMapTemplate.stopNavigation(this.id);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Sets the current maneuver state indicating progress within a maneuver.
|
|
160
|
+
* Transition through: continue → initial → prepare → execute → continue
|
|
161
|
+
* @namespace iOS sets CPManeuverState on the CPNavigationSession, used by instrument cluster and HUD
|
|
162
|
+
* @namespace Android no-op, Android Auto does not have an equivalent API
|
|
163
|
+
*/
|
|
164
|
+
setManeuverState(state) {
|
|
165
|
+
HybridMapTemplate.setManeuverState(this.id, state);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
exports.MapTemplate = MapTemplate;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.MessageTemplate = void 0;
|
|
7
|
+
const react_native_1 = require("react-native");
|
|
8
|
+
const react_native_nitro_modules_1 = require("react-native-nitro-modules");
|
|
9
|
+
const react_native_uuid_1 = __importDefault(require("react-native-uuid"));
|
|
10
|
+
const HybridAutoPlay_1 = require("../hybrid/HybridAutoPlay");
|
|
11
|
+
const NitroAction_1 = require("../utils/NitroAction");
|
|
12
|
+
const NitroImage_1 = require("../utils/NitroImage");
|
|
13
|
+
const NitroMapButton_1 = require("../utils/NitroMapButton");
|
|
14
|
+
const HybridMessageTemplate = react_native_nitro_modules_1.NitroModules.createHybridObject('MessageTemplate');
|
|
15
|
+
/**
|
|
16
|
+
* This template is always pushed on top and will stay on top until it is popped.
|
|
17
|
+
* Other templates being pushed will end up below this one on the stack.
|
|
18
|
+
* Pushing another MessageTemplate will pop the currently shown one.
|
|
19
|
+
*/
|
|
20
|
+
class MessageTemplate {
|
|
21
|
+
template = this;
|
|
22
|
+
id = react_native_uuid_1.default.v4();
|
|
23
|
+
constructor(config) {
|
|
24
|
+
const { headerActions, image, mapConfig, actions, ...rest } = config;
|
|
25
|
+
const platformActions = react_native_1.Platform.OS === 'android'
|
|
26
|
+
? NitroAction_1.NitroActionUtil.convert(this.template, actions?.android)
|
|
27
|
+
: NitroAction_1.NitroActionUtil.convert(this.template, actions?.ios);
|
|
28
|
+
const nitroConfig = {
|
|
29
|
+
...rest,
|
|
30
|
+
id: this.id,
|
|
31
|
+
headerActions: NitroAction_1.NitroActionUtil.convert(this.template, headerActions),
|
|
32
|
+
image: NitroImage_1.NitroImageUtil.convert(image),
|
|
33
|
+
actions: platformActions,
|
|
34
|
+
mapConfig: mapConfig
|
|
35
|
+
? {
|
|
36
|
+
mapButtons: NitroMapButton_1.NitroMapButton.convert(this.template, mapConfig.mapButtons),
|
|
37
|
+
headerActions: NitroAction_1.NitroActionUtil.convert(this.template, mapConfig.headerActions),
|
|
38
|
+
}
|
|
39
|
+
: undefined,
|
|
40
|
+
};
|
|
41
|
+
HybridMessageTemplate.createMessageTemplate(nitroConfig);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* push this template on the stack and show it to the user
|
|
45
|
+
*/
|
|
46
|
+
push() {
|
|
47
|
+
return HybridAutoPlay_1.HybridAutoPlay.pushTemplate(this.id);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.MessageTemplate = MessageTemplate;
|