@javascriptcommon/react-native-carplay 2.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +633 -0
- package/ios/RCTConvert+RNCarPlay.h +19 -0
- package/ios/RCTConvert+RNCarPlay.m +95 -0
- package/ios/RNCPStore.h +22 -0
- package/ios/RNCPStore.m +68 -0
- package/ios/RNCarPlay.h +32 -0
- package/ios/RNCarPlay.m +1755 -0
- package/ios/RNCarPlay.xcodeproj/project.pbxproj +300 -0
- package/lib/CarPlay.js +146 -0
- package/lib/index.js +63 -0
- package/lib/interfaces/Action.js +2 -0
- package/lib/interfaces/AlertAction.js +2 -0
- package/lib/interfaces/BarButton.js +2 -0
- package/lib/interfaces/CarColor.js +2 -0
- package/lib/interfaces/GridButton.js +2 -0
- package/lib/interfaces/Header.js +2 -0
- package/lib/interfaces/ListItem.js +2 -0
- package/lib/interfaces/ListItemUpdate.js +2 -0
- package/lib/interfaces/ListSection.js +2 -0
- package/lib/interfaces/Maneuver.js +2 -0
- package/lib/interfaces/MapButton.js +2 -0
- package/lib/interfaces/NavigationAlert.js +9 -0
- package/lib/interfaces/NavigationInfo.js +2 -0
- package/lib/interfaces/NavigationStep.js +2 -0
- package/lib/interfaces/Pane.js +2 -0
- package/lib/interfaces/PauseReason.js +11 -0
- package/lib/interfaces/Place.js +2 -0
- package/lib/interfaces/TextConfiguration.js +2 -0
- package/lib/interfaces/TimeRemainingColor.js +2 -0
- package/lib/interfaces/TravelEstimates.js +2 -0
- package/lib/interfaces/VoiceControlState.js +2 -0
- package/lib/navigation/NavigationSession.js +53 -0
- package/lib/navigation/Trip.js +19 -0
- package/lib/templates/ActionSheetTemplate.js +15 -0
- package/lib/templates/AlertTemplate.js +15 -0
- package/lib/templates/ContactTemplate.js +15 -0
- package/lib/templates/GridTemplate.js +16 -0
- package/lib/templates/InformationTemplate.js +24 -0
- package/lib/templates/ListTemplate.js +67 -0
- package/lib/templates/MapTemplate.js +115 -0
- package/lib/templates/NowPlayingTemplate.js +17 -0
- package/lib/templates/PointOfInterestTemplate.js +16 -0
- package/lib/templates/SearchTemplate.js +41 -0
- package/lib/templates/TabBarTemplate.js +26 -0
- package/lib/templates/Template.js +74 -0
- package/lib/templates/VoiceControlTemplate.js +19 -0
- package/lib/templates/android/AndroidNavigationBaseTemplate.js +29 -0
- package/lib/templates/android/MessageTemplate.js +10 -0
- package/lib/templates/android/NavigationTemplate.js +16 -0
- package/lib/templates/android/PaneTemplate.js +10 -0
- package/lib/templates/android/PlaceListMapTemplate.js +18 -0
- package/lib/templates/android/PlaceListNavigationTemplate.js +19 -0
- package/lib/templates/android/RoutePreviewNavigationTemplate.js +22 -0
- package/package.json +71 -0
- package/react-native-carplay.podspec +21 -0
- package/src/CarPlay.ts +286 -0
- package/src/index.ts +50 -0
- package/src/interfaces/Action.ts +15 -0
- package/src/interfaces/AlertAction.ts +5 -0
- package/src/interfaces/BarButton.ts +41 -0
- package/src/interfaces/CarColor.ts +1 -0
- package/src/interfaces/GridButton.ts +25 -0
- package/src/interfaces/Header.ts +16 -0
- package/src/interfaces/ListItem.ts +84 -0
- package/src/interfaces/ListItemUpdate.ts +14 -0
- package/src/interfaces/ListSection.ts +21 -0
- package/src/interfaces/Maneuver.ts +30 -0
- package/src/interfaces/MapButton.ts +27 -0
- package/src/interfaces/NavigationAlert.ts +46 -0
- package/src/interfaces/NavigationInfo.ts +19 -0
- package/src/interfaces/NavigationStep.ts +17 -0
- package/src/interfaces/Pane.ts +29 -0
- package/src/interfaces/PauseReason.ts +7 -0
- package/src/interfaces/Place.ts +12 -0
- package/src/interfaces/TextConfiguration.ts +5 -0
- package/src/interfaces/TimeRemainingColor.ts +1 -0
- package/src/interfaces/TravelEstimates.ts +39 -0
- package/src/interfaces/VoiceControlState.ts +8 -0
- package/src/navigation/NavigationSession.ts +57 -0
- package/src/navigation/Trip.ts +36 -0
- package/src/templates/ActionSheetTemplate.ts +21 -0
- package/src/templates/AlertTemplate.ts +20 -0
- package/src/templates/ContactTemplate.ts +45 -0
- package/src/templates/GridTemplate.ts +45 -0
- package/src/templates/InformationTemplate.ts +42 -0
- package/src/templates/ListTemplate.ts +167 -0
- package/src/templates/MapTemplate.ts +231 -0
- package/src/templates/NowPlayingTemplate.ts +31 -0
- package/src/templates/PointOfInterestTemplate.ts +40 -0
- package/src/templates/SearchTemplate.ts +70 -0
- package/src/templates/TabBarTemplate.ts +56 -0
- package/src/templates/Template.ts +164 -0
- package/src/templates/VoiceControlTemplate.ts +25 -0
- package/src/templates/android/AndroidNavigationBaseTemplate.ts +46 -0
- package/src/templates/android/MessageTemplate.ts +19 -0
- package/src/templates/android/NavigationTemplate.ts +50 -0
- package/src/templates/android/PaneTemplate.ts +16 -0
- package/src/templates/android/PlaceListMapTemplate.ts +64 -0
- package/src/templates/android/PlaceListNavigationTemplate.ts +57 -0
- package/src/templates/android/RoutePreviewNavigationTemplate.ts +66 -0
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@javascriptcommon/react-native-carplay",
|
|
3
|
+
"version": "2.3.11",
|
|
4
|
+
"description": "CarPlay for React Native",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"react-native": "src/index.ts",
|
|
7
|
+
"source": "src/index.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"src",
|
|
10
|
+
"lib",
|
|
11
|
+
"ios",
|
|
12
|
+
"react-native-carplay.podspec"
|
|
13
|
+
],
|
|
14
|
+
"podspecPath": "./react-native-carplay.podspec",
|
|
15
|
+
"scripts": {
|
|
16
|
+
"prepack": "yarn run build",
|
|
17
|
+
"lint": "eslint . --ext .ts,.tsx,.js,.jsx",
|
|
18
|
+
"typecheck": "tsc --noEmit",
|
|
19
|
+
"build": "tsc",
|
|
20
|
+
"fix-all-files": "eslint . --ext .ts,.tsx,.js,.jsx --fix"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/birkir/react-native-carplay.git"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"react",
|
|
28
|
+
"native",
|
|
29
|
+
"carplay",
|
|
30
|
+
"navigation",
|
|
31
|
+
"car",
|
|
32
|
+
"auto"
|
|
33
|
+
],
|
|
34
|
+
"author": "Birkir Gudjonsson <birkir.gudjonsson@gmail.com>",
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "https://github.com/birkir/react-native-carplay/issues"
|
|
38
|
+
},
|
|
39
|
+
"homepage": "https://github.com/birkir/react-native-carplay#readme",
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"react": "^17.0.2 || ^18.0.0",
|
|
42
|
+
"react-native": "^0.60.0"
|
|
43
|
+
},
|
|
44
|
+
"peerDependenciesMeta": {
|
|
45
|
+
"react": {
|
|
46
|
+
"optional": true
|
|
47
|
+
},
|
|
48
|
+
"react-native": {
|
|
49
|
+
"optional": true
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@react-native-community/eslint-config": "3.2.0",
|
|
54
|
+
"@tsconfig/react-native": "3.0.2",
|
|
55
|
+
"@types/node": "17.0.25",
|
|
56
|
+
"@types/react": "18.0.6",
|
|
57
|
+
"@types/react-native": "0.67.5",
|
|
58
|
+
"babel-jest": "^29.2.1",
|
|
59
|
+
"cross-env": "7.0.3",
|
|
60
|
+
"docusaurus-plugin-typedoc": "0.19.2",
|
|
61
|
+
"eslint": "^8.19.0",
|
|
62
|
+
"jest": "29.5.0",
|
|
63
|
+
"microbundle": "0.14.2",
|
|
64
|
+
"prettier": "2.6.2",
|
|
65
|
+
"rimraf": "3.0.2",
|
|
66
|
+
"typedoc": "0.24.7",
|
|
67
|
+
"typedoc-github-wiki-theme": "1.1.0",
|
|
68
|
+
"typedoc-plugin-markdown": "3.15.3",
|
|
69
|
+
"typescript": "5.0.4"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'react-native-carplay'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
|
|
10
|
+
s.homepage = package['repository']['url']
|
|
11
|
+
|
|
12
|
+
s.license = package['license']
|
|
13
|
+
s.authors = package['author']
|
|
14
|
+
s.ios.deployment_target = '12.0'
|
|
15
|
+
|
|
16
|
+
s.source = { :git => "https://github.com/Spicy-Sparks/react-native-carplay.git" }
|
|
17
|
+
|
|
18
|
+
s.source_files = "ios/*.{h,m}"
|
|
19
|
+
|
|
20
|
+
s.dependency 'React-Core'
|
|
21
|
+
end
|
package/src/CarPlay.ts
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { ImageSourcePropType, NativeEventEmitter, NativeModule, NativeModules, Platform } from 'react-native';
|
|
2
|
+
import { ActionSheetTemplate } from './templates/ActionSheetTemplate';
|
|
3
|
+
import { AlertTemplate } from './templates/AlertTemplate';
|
|
4
|
+
import { ContactTemplate } from './templates/ContactTemplate';
|
|
5
|
+
import { GridTemplate } from './templates/GridTemplate';
|
|
6
|
+
import { InformationTemplate } from './templates/InformationTemplate';
|
|
7
|
+
import { ListTemplate } from './templates/ListTemplate';
|
|
8
|
+
import { NavigationTemplate } from './templates/android/NavigationTemplate';
|
|
9
|
+
import { PlaceListMapTemplate } from './templates/android/PlaceListMapTemplate';
|
|
10
|
+
import { PlaceListNavigationTemplate } from './templates/android/PlaceListNavigationTemplate';
|
|
11
|
+
import { RoutePreviewNavigationTemplate } from './templates/android/RoutePreviewNavigationTemplate';
|
|
12
|
+
import { MapTemplate } from './templates/MapTemplate';
|
|
13
|
+
import { PointOfInterestTemplate } from './templates/PointOfInterestTemplate';
|
|
14
|
+
import { SearchTemplate } from './templates/SearchTemplate';
|
|
15
|
+
import { TabBarTemplate } from './templates/TabBarTemplate';
|
|
16
|
+
import { VoiceControlTemplate } from './templates/VoiceControlTemplate';
|
|
17
|
+
import { NowPlayingTemplate } from './templates/NowPlayingTemplate';
|
|
18
|
+
import { Maneuver } from './interfaces/Maneuver';
|
|
19
|
+
import { TravelEstimates } from './interfaces/TravelEstimates';
|
|
20
|
+
import { PauseReason } from './interfaces/PauseReason';
|
|
21
|
+
import { TripConfig } from './navigation/Trip';
|
|
22
|
+
import { TimeRemainingColor } from './interfaces/TimeRemainingColor';
|
|
23
|
+
import { TextConfiguration } from './interfaces/TextConfiguration';
|
|
24
|
+
import { Action } from './interfaces/Action';
|
|
25
|
+
import { MessageTemplate } from './templates/android/MessageTemplate';
|
|
26
|
+
import { PaneTemplate } from './templates/android/PaneTemplate';
|
|
27
|
+
|
|
28
|
+
export interface InternalCarPlay extends NativeModule {
|
|
29
|
+
checkForConnection(): void;
|
|
30
|
+
setRootTemplate(templateId: string, animated: boolean): void;
|
|
31
|
+
pushTemplate(templateId: string, animated: boolean): void;
|
|
32
|
+
popToTemplate(templateId: string, animated: boolean): void;
|
|
33
|
+
popToRootTemplate(animated: boolean): void;
|
|
34
|
+
popTemplate(animated: boolean): void;
|
|
35
|
+
presentTemplate(templateId: string, animated: boolean): void;
|
|
36
|
+
dismissTemplate(animated: boolean): void;
|
|
37
|
+
enableNowPlaying(enabled: boolean): void;
|
|
38
|
+
updateManeuversNavigationSession(id: string, x: Maneuver[]): void;
|
|
39
|
+
updateTravelEstimatesNavigationSession(
|
|
40
|
+
id: string,
|
|
41
|
+
index: number,
|
|
42
|
+
estimates: TravelEstimates,
|
|
43
|
+
): void;
|
|
44
|
+
cancelNavigationSession(id: string): void;
|
|
45
|
+
finishNavigationSession(id: string): void;
|
|
46
|
+
pauseNavigationSession(id: string, reason: PauseReason, description?: string): void;
|
|
47
|
+
createTrip(id: string, config: TripConfig): void;
|
|
48
|
+
updateInformationTemplateItems(id: string, config: unknown): void;
|
|
49
|
+
updateInformationTemplateActions(id: string, config: unknown): void;
|
|
50
|
+
createTemplate(id: string, config: unknown, callback?: unknown): void;
|
|
51
|
+
updateTemplate(id: string, config: unknown): void;
|
|
52
|
+
invalidate(id: string): void;
|
|
53
|
+
startNavigationSession(
|
|
54
|
+
id: string,
|
|
55
|
+
tripId: string,
|
|
56
|
+
): Promise<{
|
|
57
|
+
tripId: string;
|
|
58
|
+
navigationSessionId: string;
|
|
59
|
+
}>;
|
|
60
|
+
updateTravelEstimatesForTrip(
|
|
61
|
+
id: string,
|
|
62
|
+
tripId: string,
|
|
63
|
+
travelEstimates: TravelEstimates,
|
|
64
|
+
timeRemainingColor: TimeRemainingColor,
|
|
65
|
+
): void;
|
|
66
|
+
updateMapTemplateConfig(id: string, config: unknown): void;
|
|
67
|
+
updateMapTemplateMapButtons(id: string, config: unknown): void;
|
|
68
|
+
hideTripPreviews(id: string): void;
|
|
69
|
+
showTripPreviews(id: string, previews: string[], config: TextConfiguration): void;
|
|
70
|
+
showRouteChoicesPreviewForTrip(id: string, tripId: string, config: TextConfiguration): void;
|
|
71
|
+
presentNavigationAlert(id: string, config: unknown, animated: boolean): void;
|
|
72
|
+
dismissNavigationAlert(id: string, animated: boolean): void;
|
|
73
|
+
showPanningInterface(id: string, animated: boolean): void;
|
|
74
|
+
dismissPanningInterface(id: string, animated: boolean): void;
|
|
75
|
+
getMaximumListSectionCount(id: string): Promise<number>;
|
|
76
|
+
getMaximumListItemCount(id: string): Promise<number>;
|
|
77
|
+
getMaximumRowItemsCount(id: string): Promise<number>;
|
|
78
|
+
reactToSelectedResult(status: boolean): void;
|
|
79
|
+
updateListTemplateSections(id: string, config: unknown): void;
|
|
80
|
+
updateListTemplateItem(id: string, config: unknown): void;
|
|
81
|
+
updateListTemplateRowItems(id: string, config: unknown): void;
|
|
82
|
+
reactToUpdatedSearchText(items: unknown): void;
|
|
83
|
+
updateTabBarTemplates(id: string, config: unknown): void;
|
|
84
|
+
activateVoiceControlState(id: string, identifier: string): void;
|
|
85
|
+
// Android
|
|
86
|
+
reload(): void;
|
|
87
|
+
toast(message: string, duration: number): void;
|
|
88
|
+
alert(config: {
|
|
89
|
+
id: number;
|
|
90
|
+
title: string;
|
|
91
|
+
duration: number;
|
|
92
|
+
subtitle?: string;
|
|
93
|
+
icon?: ImageSourcePropType;
|
|
94
|
+
actions?: Action[];
|
|
95
|
+
}): void;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const { RNCarPlay } = NativeModules as { RNCarPlay: InternalCarPlay };
|
|
99
|
+
|
|
100
|
+
export type PushableTemplates =
|
|
101
|
+
| MapTemplate
|
|
102
|
+
| SearchTemplate
|
|
103
|
+
| GridTemplate
|
|
104
|
+
| PointOfInterestTemplate
|
|
105
|
+
| ListTemplate
|
|
106
|
+
| MessageTemplate
|
|
107
|
+
| PaneTemplate
|
|
108
|
+
| InformationTemplate
|
|
109
|
+
| ContactTemplate
|
|
110
|
+
| NowPlayingTemplate
|
|
111
|
+
| NavigationTemplate
|
|
112
|
+
| PlaceListMapTemplate
|
|
113
|
+
| PlaceListNavigationTemplate
|
|
114
|
+
| RoutePreviewNavigationTemplate;
|
|
115
|
+
|
|
116
|
+
export type PresentableTemplates = AlertTemplate | ActionSheetTemplate | VoiceControlTemplate;
|
|
117
|
+
|
|
118
|
+
export type WindowInformation = {
|
|
119
|
+
width: number;
|
|
120
|
+
height: number;
|
|
121
|
+
scale: number;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export type OnConnectCallback = (window: WindowInformation) => void;
|
|
125
|
+
export type OnDisconnectCallback = () => void;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* A controller that manages all user interface elements appearing on your map displayed on the CarPlay screen.
|
|
129
|
+
*/
|
|
130
|
+
export class CarPlayInterface {
|
|
131
|
+
/**
|
|
132
|
+
* React Native bridge to the CarPlay interface
|
|
133
|
+
*/
|
|
134
|
+
public bridge = RNCarPlay;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Boolean to denote if carplay is currently connected.
|
|
138
|
+
*/
|
|
139
|
+
public connected = false;
|
|
140
|
+
public window: WindowInformation | undefined;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* CarPlay Event Emitter
|
|
144
|
+
*/
|
|
145
|
+
public emitter = new NativeEventEmitter(RNCarPlay);
|
|
146
|
+
|
|
147
|
+
private onConnectCallbacks = new Set<OnConnectCallback>();
|
|
148
|
+
private onDisconnectCallbacks = new Set<OnDisconnectCallback>();
|
|
149
|
+
|
|
150
|
+
constructor() {
|
|
151
|
+
this.emitter.addListener('didConnect', (window: WindowInformation) => {
|
|
152
|
+
console.log('we are connected yes!');
|
|
153
|
+
this.connected = true;
|
|
154
|
+
this.window = window;
|
|
155
|
+
this.onConnectCallbacks.forEach(callback => {
|
|
156
|
+
callback(window);
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
this.emitter.addListener('didDisconnect', () => {
|
|
160
|
+
this.connected = false;
|
|
161
|
+
this.window = undefined;
|
|
162
|
+
this.onDisconnectCallbacks.forEach(callback => {
|
|
163
|
+
callback();
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
if (Platform.OS === 'android') {
|
|
167
|
+
this.emitter.addListener('didPressMenuItem', e => {
|
|
168
|
+
if (e?.title === 'Reload Android Auto') {
|
|
169
|
+
this.bridge.reload();
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// check if already connected this will fire any 'didConnect' events
|
|
175
|
+
// if a connected is already present.
|
|
176
|
+
this.bridge.checkForConnection();
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Fired when CarPlay is connected to the device.
|
|
181
|
+
*/
|
|
182
|
+
public registerOnConnect = (callback: OnConnectCallback) => {
|
|
183
|
+
this.onConnectCallbacks.add(callback);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
public unregisterOnConnect = (callback: OnConnectCallback) => {
|
|
187
|
+
this.onConnectCallbacks.delete(callback);
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Fired when CarPlay is disconnected from the device.
|
|
192
|
+
*/
|
|
193
|
+
public registerOnDisconnect = (callback: OnDisconnectCallback) => {
|
|
194
|
+
this.onDisconnectCallbacks.add(callback);
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
public unregisterOnDisconnect = (callback: OnDisconnectCallback) => {
|
|
198
|
+
this.onDisconnectCallbacks.delete(callback);
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Sets the root template, starting a new stack for the template navigation hierarchy.
|
|
203
|
+
* @param rootTemplate The root template. Replaces the current rootTemplate, if one exists.
|
|
204
|
+
* @param animated Set TRUE to animate the presentation of the root template; ignored if there isn't a current rootTemplate.
|
|
205
|
+
*/
|
|
206
|
+
public setRootTemplate(rootTemplate: PushableTemplates | TabBarTemplate, animated = true) {
|
|
207
|
+
return this.bridge.setRootTemplate(rootTemplate.id, animated);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Pushes a template onto the navigation stack and updates the display.
|
|
212
|
+
* @param templateToPush The template to push onto the navigation stack.
|
|
213
|
+
* @param animated Set TRUE to animate the presentation of the template.
|
|
214
|
+
*/
|
|
215
|
+
public pushTemplate(templateToPush: PushableTemplates, animated = true) {
|
|
216
|
+
return this.bridge.pushTemplate(templateToPush.id, animated);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Pops templates until the specified template is at the top of the navigation stack.
|
|
221
|
+
* @param targetTemplate The template that you want at the top of the stack. The template must be on the navigation stack before calling this method.
|
|
222
|
+
* @param animated A Boolean value that indicates whether the system animates the display of transitioning templates.
|
|
223
|
+
*/
|
|
224
|
+
public popToTemplate(targetTemplate: PushableTemplates, animated = true) {
|
|
225
|
+
return this.bridge.popToTemplate(targetTemplate.id, animated);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Pops all templates on the stack—except the root template—and updates the display.
|
|
230
|
+
* @param animated A Boolean value that indicates whether the system animates the display of transitioning templates.
|
|
231
|
+
*/
|
|
232
|
+
public popToRootTemplate(animated = true) {
|
|
233
|
+
return this.bridge.popToRootTemplate(animated);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Pops the top template from the navigation stack and updates the display.
|
|
238
|
+
* @param animated A Boolean value that indicates whether the system animates the display of transitioning templates.
|
|
239
|
+
*/
|
|
240
|
+
public popTemplate(animated = true) {
|
|
241
|
+
return this.bridge.popTemplate(animated);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* presents a presentable template, alert / action / voice
|
|
246
|
+
* @param templateToPresent The presentable template to present
|
|
247
|
+
* @param animated A Boolean value that indicates whether the system animates the display of transitioning templates.
|
|
248
|
+
*/
|
|
249
|
+
public presentTemplate(templateToPresent: PresentableTemplates, animated = true) {
|
|
250
|
+
return this.bridge.presentTemplate(templateToPresent.id, animated);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Dismisses the current presented template
|
|
255
|
+
* * @param animated A Boolean value that indicates whether the system animates the display of transitioning templates.
|
|
256
|
+
*/
|
|
257
|
+
public dismissTemplate(animated = true) {
|
|
258
|
+
return this.bridge.dismissTemplate(animated);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* The current root template in the template navigation hierarchy.
|
|
263
|
+
* @todo Not implemented yet
|
|
264
|
+
*/
|
|
265
|
+
public get rootTemplate(): Promise<string> {
|
|
266
|
+
return Promise.resolve('');
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* The top-most template in the navigation hierarchy stack.
|
|
271
|
+
* @todo Not implemented yet
|
|
272
|
+
*/
|
|
273
|
+
public get topTemplate(): Promise<string> {
|
|
274
|
+
return Promise.resolve('');
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Control now playing template state
|
|
279
|
+
* @param enable A Boolean value that indicates whether the system use now playing template.
|
|
280
|
+
*/
|
|
281
|
+
public enableNowPlaying(enable = true) {
|
|
282
|
+
return this.bridge.enableNowPlaying(enable);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export const CarPlay = new CarPlayInterface();
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Templates
|
|
2
|
+
export * from './templates/Template';
|
|
3
|
+
export * from './templates/ActionSheetTemplate';
|
|
4
|
+
export * from './templates/AlertTemplate';
|
|
5
|
+
export * from './templates/ContactTemplate';
|
|
6
|
+
export * from './templates/GridTemplate';
|
|
7
|
+
export * from './templates/InformationTemplate';
|
|
8
|
+
export * from './templates/ListTemplate';
|
|
9
|
+
export * from './templates/MapTemplate';
|
|
10
|
+
export * from './templates/NowPlayingTemplate';
|
|
11
|
+
export * from './templates/PointOfInterestTemplate';
|
|
12
|
+
export * from './templates/SearchTemplate';
|
|
13
|
+
export * from './templates/TabBarTemplate';
|
|
14
|
+
export * from './templates/VoiceControlTemplate';
|
|
15
|
+
|
|
16
|
+
// Android-only Templates
|
|
17
|
+
export * from './templates/android/MessageTemplate';
|
|
18
|
+
export * from './templates/android/NavigationTemplate';
|
|
19
|
+
export * from './templates/android/PaneTemplate';
|
|
20
|
+
export * from './templates/android/PlaceListMapTemplate';
|
|
21
|
+
export * from './templates/android/PlaceListNavigationTemplate';
|
|
22
|
+
export * from './templates/android/RoutePreviewNavigationTemplate';
|
|
23
|
+
|
|
24
|
+
// Others
|
|
25
|
+
export * from './CarPlay';
|
|
26
|
+
export * from './navigation/Trip';
|
|
27
|
+
export * from './navigation/NavigationSession';
|
|
28
|
+
|
|
29
|
+
// Types
|
|
30
|
+
export * from './interfaces/Action';
|
|
31
|
+
export * from './interfaces/AlertAction';
|
|
32
|
+
export * from './interfaces/BarButton';
|
|
33
|
+
export * from './interfaces/CarColor';
|
|
34
|
+
export * from './interfaces/GridButton';
|
|
35
|
+
export * from './interfaces/Header';
|
|
36
|
+
export * from './interfaces/ListItem';
|
|
37
|
+
export * from './interfaces/ListItemUpdate';
|
|
38
|
+
export * from './interfaces/ListSection';
|
|
39
|
+
export * from './interfaces/Maneuver';
|
|
40
|
+
export * from './interfaces/MapButton';
|
|
41
|
+
export * from './interfaces/NavigationAlert';
|
|
42
|
+
export * from './interfaces/NavigationInfo';
|
|
43
|
+
export * from './interfaces/NavigationStep';
|
|
44
|
+
export * from './interfaces/Pane';
|
|
45
|
+
export * from './interfaces/PauseReason';
|
|
46
|
+
export * from './interfaces/Place';
|
|
47
|
+
export * from './interfaces/TextConfiguration';
|
|
48
|
+
export * from './interfaces/TimeRemainingColor';
|
|
49
|
+
export * from './interfaces/TravelEstimates';
|
|
50
|
+
export * from './interfaces/VoiceControlState';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ColorValue } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export type ActionType = 'appIcon' | 'back' | 'pan' | 'custom';
|
|
4
|
+
|
|
5
|
+
export interface Action<T extends ActionType = ActionType> {
|
|
6
|
+
id?: string;
|
|
7
|
+
title?: string;
|
|
8
|
+
icon?: string;
|
|
9
|
+
backgroundColor?: ColorValue;
|
|
10
|
+
visibility?: 'default' | 'persistent' | 'primary';
|
|
11
|
+
enabled?: boolean;
|
|
12
|
+
type?: T;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type HeaderAction = Action<'appIcon' | 'back'>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ImageSourcePropType } from 'react-native';
|
|
2
|
+
|
|
3
|
+
interface BarButtonBase {
|
|
4
|
+
/**
|
|
5
|
+
* Button ID
|
|
6
|
+
*/
|
|
7
|
+
id: string;
|
|
8
|
+
/**
|
|
9
|
+
* A Boolean value that enables and disables the bar button.
|
|
10
|
+
*/
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface BarButtonText extends BarButtonBase {
|
|
15
|
+
/**
|
|
16
|
+
* A text style bar button.
|
|
17
|
+
*/
|
|
18
|
+
type: 'text';
|
|
19
|
+
/**
|
|
20
|
+
* The title displayed on the button.
|
|
21
|
+
*/
|
|
22
|
+
title: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface BarButtonImage extends BarButtonBase {
|
|
26
|
+
/**
|
|
27
|
+
* An image style bar button.
|
|
28
|
+
*/
|
|
29
|
+
type: 'image';
|
|
30
|
+
/**
|
|
31
|
+
* The image displayed on the button.
|
|
32
|
+
*
|
|
33
|
+
* If you provide an animated image, the button displays only the first image in the animation sequence.
|
|
34
|
+
*/
|
|
35
|
+
image: ImageSourcePropType;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A button in a navigation bar.
|
|
40
|
+
*/
|
|
41
|
+
export type BarButton = BarButtonImage | BarButtonText;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type CarColor = 'blue' | 'green' | 'primary' | 'red' | 'secondary' | 'yellow' | 'default';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ImageSourcePropType } from 'react-native';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A menu item button displayed on a grid template.
|
|
5
|
+
*/
|
|
6
|
+
export interface GridButton {
|
|
7
|
+
/**
|
|
8
|
+
* Button ID
|
|
9
|
+
*/
|
|
10
|
+
id: string;
|
|
11
|
+
/**
|
|
12
|
+
* An array of title variants for the button.
|
|
13
|
+
*
|
|
14
|
+
* When the system displays the button, it selects the title that best fits the available screen space, so arrange the titles from most to least preferred when creating a grid button. Also, localize each title for display to the user, and be sure to include at least one title in the array.
|
|
15
|
+
*/
|
|
16
|
+
titleVariants: string[];
|
|
17
|
+
/**
|
|
18
|
+
* The image displayed on the button.
|
|
19
|
+
*
|
|
20
|
+
* When creating a grid button, don't provide an animated image. If you do, the button uses the first image in the animation sequence.
|
|
21
|
+
*/
|
|
22
|
+
image: ImageSourcePropType;
|
|
23
|
+
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Action, HeaderAction } from './Action';
|
|
2
|
+
|
|
3
|
+
export interface Header {
|
|
4
|
+
title: string;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* By default, a header will not have a start action.
|
|
8
|
+
* Requirements Only one of APP_ICON or BACK is supported as a start header Action.
|
|
9
|
+
*/
|
|
10
|
+
startAction?: Action<'appIcon' | 'back'>;
|
|
11
|
+
/**
|
|
12
|
+
* By default, a template will not have end header actions.
|
|
13
|
+
* Requirements Up to 2 actions (which are APP_ICON, BACK or TYPE_CUSTOM with an icon) at the end of the header.
|
|
14
|
+
*/
|
|
15
|
+
endActions?: [HeaderAction] | [HeaderAction, HeaderAction];
|
|
16
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { ImageSourcePropType } from 'react-native';
|
|
2
|
+
import { Action } from './Action';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A list item that appears in a list template.
|
|
6
|
+
*/
|
|
7
|
+
export interface ListItem {
|
|
8
|
+
/**
|
|
9
|
+
* References the item by id
|
|
10
|
+
*/
|
|
11
|
+
id?: string;
|
|
12
|
+
/**
|
|
13
|
+
* The primary text displayed in the list item cell.
|
|
14
|
+
*/
|
|
15
|
+
text: string;
|
|
16
|
+
/**
|
|
17
|
+
* Extra text displayed below the primary text in the list item cell.
|
|
18
|
+
*/
|
|
19
|
+
detailText?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Image from file system displayed on the leading edge of the list item cell.
|
|
22
|
+
*/
|
|
23
|
+
image?: ImageSourcePropType;
|
|
24
|
+
/**
|
|
25
|
+
* The image name displayed on the leading edge of the list item cell.
|
|
26
|
+
*/
|
|
27
|
+
imageName?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Url for image displayed on the leading edge of the list item cell.
|
|
30
|
+
*/
|
|
31
|
+
imgUrl?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Is Artist flag.
|
|
34
|
+
*/
|
|
35
|
+
isArtist?: boolean
|
|
36
|
+
/**
|
|
37
|
+
* The sub items arranged in a row.
|
|
38
|
+
* @namespace iOS
|
|
39
|
+
*/
|
|
40
|
+
rowItems?: ListItem[];
|
|
41
|
+
/**
|
|
42
|
+
* A Boolean value indicating whether the list item cell shows a disclosure indicator on the trailing edge of the list item cell.
|
|
43
|
+
* @namespace iOS
|
|
44
|
+
*/
|
|
45
|
+
showsDisclosureIndicator?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Is Playing flag.
|
|
48
|
+
* @namespace iOS
|
|
49
|
+
*/
|
|
50
|
+
isPlaying?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
** Value between 0.0 and 1.0 for progress bar of the list item cell.
|
|
53
|
+
* @namespace iOS
|
|
54
|
+
*/
|
|
55
|
+
playbackProgress?: number;
|
|
56
|
+
/**
|
|
57
|
+
* The image from file system displayed on the trailing edge of the list item cell.
|
|
58
|
+
* @namespace iOS
|
|
59
|
+
*/
|
|
60
|
+
accessoryImage?: ImageSourcePropType;
|
|
61
|
+
/**
|
|
62
|
+
* Sets the initial enabled state for Row.
|
|
63
|
+
* @default true
|
|
64
|
+
* @namespace Android
|
|
65
|
+
*/
|
|
66
|
+
enabled?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Shows an icon at the end of the row that indicates that the row is browsable.
|
|
69
|
+
* Browsable rows can be used, for example, to represent the parent row in a hierarchy of lists with child lists.
|
|
70
|
+
* If a row is browsable, then no Action or Toggle can be added to it.
|
|
71
|
+
* @namespace Android
|
|
72
|
+
*/
|
|
73
|
+
browsable?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* If a row has a toggle set, then no Action or numeric decoration can be set.
|
|
76
|
+
* @namespace Android
|
|
77
|
+
*/
|
|
78
|
+
toggle?: number;
|
|
79
|
+
/**
|
|
80
|
+
* Adds an additional action to the end of the row.
|
|
81
|
+
* @namespace Android
|
|
82
|
+
*/
|
|
83
|
+
action?: Action<'custom'>;
|
|
84
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ListItem } from './ListItem';
|
|
2
|
+
/**
|
|
3
|
+
* A list item update payload.
|
|
4
|
+
*/
|
|
5
|
+
export interface ListItemUpdate extends ListItem {
|
|
6
|
+
/**
|
|
7
|
+
* The section of item.
|
|
8
|
+
*/
|
|
9
|
+
sectionIndex: number;
|
|
10
|
+
/**
|
|
11
|
+
* The index of item.
|
|
12
|
+
*/
|
|
13
|
+
itemIndex: number;
|
|
14
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ListItem } from './ListItem';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A section of list items that appear in a list template.
|
|
5
|
+
*/
|
|
6
|
+
export interface ListSection {
|
|
7
|
+
/**
|
|
8
|
+
* The section header text.
|
|
9
|
+
*/
|
|
10
|
+
header?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The section index title.
|
|
13
|
+
*
|
|
14
|
+
* The system displays only the first character of the section index title.
|
|
15
|
+
*/
|
|
16
|
+
sectionIndexTitle?: string;
|
|
17
|
+
/**
|
|
18
|
+
* The list of items for the section.
|
|
19
|
+
*/
|
|
20
|
+
items?: ListItem[];
|
|
21
|
+
}
|