@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
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { TravelEstimates } from './TravelEstimates';
|
|
2
|
+
import { ColorValue, ImageSourcePropType, ProcessedColorValue } from 'react-native';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Navigation instructions and distance from the previous maneuver.
|
|
6
|
+
*/
|
|
7
|
+
export interface Maneuver {
|
|
8
|
+
junctionImage?: ImageSourcePropType;
|
|
9
|
+
initialTravelEstimates?: TravelEstimates;
|
|
10
|
+
symbolImage?: ImageSourcePropType;
|
|
11
|
+
/**
|
|
12
|
+
* The size of the image in points. Please read the CarPlay App Programming Guide
|
|
13
|
+
* to get the recommended size.
|
|
14
|
+
*/
|
|
15
|
+
symbolImageSize?: { width: number; height: number };
|
|
16
|
+
/**
|
|
17
|
+
* Allows the supplied symbol image to be tinted
|
|
18
|
+
* via a color, ie. 'red'. This functionality would usually
|
|
19
|
+
* be available via the `<Image>` tag but carplay requires
|
|
20
|
+
* an image asset to this tinting is done on the native side.
|
|
21
|
+
* If a string is supplied, it will be passed to `processColor`.
|
|
22
|
+
* You may also use `processColor` yourself.
|
|
23
|
+
*/
|
|
24
|
+
tintSymbolImage?: null | number | ColorValue | ProcessedColorValue;
|
|
25
|
+
instructionVariants: string[];
|
|
26
|
+
|
|
27
|
+
// not yet implemented
|
|
28
|
+
dashboardInstructionVariants?: string[];
|
|
29
|
+
notificationInstructionVariants?: string[];
|
|
30
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ImageSourcePropType } from 'react-native';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A button representing an action that a map template displays on the CarPlay screen.
|
|
5
|
+
*/
|
|
6
|
+
export interface MapButton {
|
|
7
|
+
/**
|
|
8
|
+
* Button ID
|
|
9
|
+
*/
|
|
10
|
+
id: string;
|
|
11
|
+
/**
|
|
12
|
+
* The image to display on the button.
|
|
13
|
+
*/
|
|
14
|
+
image?: ImageSourcePropType;
|
|
15
|
+
/**
|
|
16
|
+
* The image to display when focus is on the button.
|
|
17
|
+
*/
|
|
18
|
+
focusedImage?: ImageSourcePropType;
|
|
19
|
+
/**
|
|
20
|
+
* A Boolean value that enables and disables the map button.
|
|
21
|
+
*/
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* A Boolean value that hides and shows the map button.
|
|
25
|
+
*/
|
|
26
|
+
hidden?: boolean;
|
|
27
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ImageSourcePropType } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export enum NavigationAlertActionStyle {
|
|
4
|
+
Default = 0,
|
|
5
|
+
Cancel = 1,
|
|
6
|
+
Destructive = 2,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface NavigationAlertAction {
|
|
10
|
+
/**
|
|
11
|
+
* The action button's title.
|
|
12
|
+
*/
|
|
13
|
+
title: string;
|
|
14
|
+
/**
|
|
15
|
+
* The display style for the action button.
|
|
16
|
+
*/
|
|
17
|
+
style?: NavigationAlertActionStyle;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* An alert panel that displays map or navigation related information to the user.
|
|
22
|
+
*/
|
|
23
|
+
export interface NavigationAlert {
|
|
24
|
+
lightImage?: ImageSourcePropType;
|
|
25
|
+
darkImage?: ImageSourcePropType;
|
|
26
|
+
/**
|
|
27
|
+
* An array of title strings.
|
|
28
|
+
*/
|
|
29
|
+
titleVariants: string[];
|
|
30
|
+
/**
|
|
31
|
+
* An array of subtitle strings.
|
|
32
|
+
*/
|
|
33
|
+
subtitleVariants?: string[];
|
|
34
|
+
/**
|
|
35
|
+
* The primary action, and button, for the navigation alert.
|
|
36
|
+
*/
|
|
37
|
+
primaryAction: NavigationAlertAction;
|
|
38
|
+
/**
|
|
39
|
+
* An optional, secondary action (and button) for the navigation alert.
|
|
40
|
+
*/
|
|
41
|
+
secondaryAction?: NavigationAlertAction;
|
|
42
|
+
/**
|
|
43
|
+
* The amount of time, in seconds, that the alert is visible.
|
|
44
|
+
*/
|
|
45
|
+
duration: number;
|
|
46
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ImageResolvedAssetSource } from 'react-native';
|
|
2
|
+
import { NavigationStep } from './NavigationStep';
|
|
3
|
+
|
|
4
|
+
export type NavigationRoutingInfo = {
|
|
5
|
+
type: 'routingInfo';
|
|
6
|
+
loading?: boolean;
|
|
7
|
+
junctionImage?: ImageResolvedAssetSource;
|
|
8
|
+
nextStep?: NavigationStep;
|
|
9
|
+
distance: number;
|
|
10
|
+
distanceUnits: number;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type NavigationMessageInfo = {
|
|
14
|
+
type: 'messageInfo';
|
|
15
|
+
title: string;
|
|
16
|
+
icon?: ImageResolvedAssetSource;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type NavigationInfo = NavigationRoutingInfo | NavigationMessageInfo;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ImageResolvedAssetSource } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export type NavigationStep = {
|
|
4
|
+
lane: {
|
|
5
|
+
shape: number;
|
|
6
|
+
recommended: boolean;
|
|
7
|
+
};
|
|
8
|
+
cue?: string;
|
|
9
|
+
lanesImage: ImageResolvedAssetSource;
|
|
10
|
+
maneuver?: {
|
|
11
|
+
type: number;
|
|
12
|
+
icon: ImageResolvedAssetSource;
|
|
13
|
+
roundaboutExitAngle: number;
|
|
14
|
+
roundaboutExitNumber: number;
|
|
15
|
+
};
|
|
16
|
+
road?: string;
|
|
17
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ImageSourcePropType } from 'react-native';
|
|
2
|
+
import { Action } from './Action';
|
|
3
|
+
import { ListItem } from './ListItem';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents a list of rows used for displaying informational content and a set of Actions that users can perform based on such content.
|
|
7
|
+
* @namespace Android
|
|
8
|
+
*/
|
|
9
|
+
export interface Pane {
|
|
10
|
+
/**
|
|
11
|
+
* Sets whether the Pane is in a loading state.
|
|
12
|
+
* If set to true, the UI will display a loading indicator where the list content would be otherwise. The caller is expected to call invalidate and send the new template content to the host once the data is ready. If set to false, the UI shows the actual row contents.
|
|
13
|
+
*/
|
|
14
|
+
loading?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Sets an CarIcon to display alongside the rows in the pane.
|
|
17
|
+
* Image Sizing Guidance To minimize scaling artifacts across a wide range of car screens, apps should provide images targeting a 480 x 480 dp bounding box. If the image exceeds this maximum size in either one of the dimensions, it will be scaled down to be centered inside the bounding box while preserving its aspect ratio.
|
|
18
|
+
*/
|
|
19
|
+
image?: ImageSourcePropType;
|
|
20
|
+
/**
|
|
21
|
+
* Actions to display alongside the rows in the pane.
|
|
22
|
+
* By default, no actions are displayed.
|
|
23
|
+
*/
|
|
24
|
+
actions?: Action[];
|
|
25
|
+
/**
|
|
26
|
+
* Rows to display in the list.
|
|
27
|
+
*/
|
|
28
|
+
items?: ListItem[];
|
|
29
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ImageSourcePropType } from 'react-native';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A place to be displayed on the map.
|
|
5
|
+
* @namespace Android
|
|
6
|
+
*/
|
|
7
|
+
export interface Place {
|
|
8
|
+
latitude: number;
|
|
9
|
+
longitude: number;
|
|
10
|
+
// Marker icon on the map
|
|
11
|
+
icon: ImageSourcePropType;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type TimeRemainingColor = 0 | 1 | 2 | 3;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CarColor } from './CarColor';
|
|
2
|
+
|
|
3
|
+
export type DistanceUnits = 'meters' | 'miles' | 'kilometers' | 'yards' | 'feet';
|
|
4
|
+
|
|
5
|
+
export interface TravelEstimates {
|
|
6
|
+
/**
|
|
7
|
+
* Distance remaining
|
|
8
|
+
*/
|
|
9
|
+
distanceRemaining: number;
|
|
10
|
+
/**
|
|
11
|
+
* Time remaining in seconds
|
|
12
|
+
*/
|
|
13
|
+
timeRemaining: number;
|
|
14
|
+
/**
|
|
15
|
+
* unit of measurement for the
|
|
16
|
+
* distance, defaults to kilometer
|
|
17
|
+
* @namespace iOS
|
|
18
|
+
*/
|
|
19
|
+
distanceUnits?: DistanceUnits;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Color of the distance remaining
|
|
23
|
+
* @namespace Android
|
|
24
|
+
*/
|
|
25
|
+
distanceRemainingColor?: CarColor;
|
|
26
|
+
/**
|
|
27
|
+
* Color of the time remaining
|
|
28
|
+
* @namespace Android
|
|
29
|
+
*/
|
|
30
|
+
timeRemainingColor?: CarColor;
|
|
31
|
+
/**
|
|
32
|
+
* Destination time
|
|
33
|
+
* @namespace Android
|
|
34
|
+
*/
|
|
35
|
+
destinationTime?: {
|
|
36
|
+
timeSinceEpochMillis: number;
|
|
37
|
+
id: string;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { CarPlay } from '../CarPlay';
|
|
2
|
+
import { Maneuver } from '../interfaces/Maneuver';
|
|
3
|
+
import { PauseReason } from '../interfaces/PauseReason';
|
|
4
|
+
import { TravelEstimates } from '../interfaces/TravelEstimates';
|
|
5
|
+
import { MapTemplate } from '../templates/MapTemplate';
|
|
6
|
+
import { Trip } from './Trip';
|
|
7
|
+
import { Image, processColor } from 'react-native';
|
|
8
|
+
|
|
9
|
+
export class NavigationSession {
|
|
10
|
+
public maneuvers: Maneuver[] = [];
|
|
11
|
+
|
|
12
|
+
constructor(public id: string, public trip: Trip, public mapTemplate: MapTemplate) {}
|
|
13
|
+
|
|
14
|
+
public updateManeuvers(maneuvers: Maneuver[]) {
|
|
15
|
+
this.maneuvers = maneuvers;
|
|
16
|
+
const windowScale = CarPlay.window?.scale ?? 1;
|
|
17
|
+
CarPlay.bridge.updateManeuversNavigationSession(
|
|
18
|
+
this.id,
|
|
19
|
+
maneuvers.map(maneuver => {
|
|
20
|
+
if (maneuver.symbolImage) {
|
|
21
|
+
const image = Image.resolveAssetSource(maneuver.symbolImage);
|
|
22
|
+
maneuver.symbolImage = image;
|
|
23
|
+
maneuver.symbolImageSize = maneuver.symbolImageSize ?? { width: 50, height: 50 };
|
|
24
|
+
const width = Math.floor((maneuver.symbolImageSize.width * windowScale) / image.scale);
|
|
25
|
+
const height = Math.floor((maneuver.symbolImageSize.height * windowScale) / image.scale);
|
|
26
|
+
maneuver.symbolImageSize = { width, height };
|
|
27
|
+
}
|
|
28
|
+
if (maneuver.junctionImage) {
|
|
29
|
+
maneuver.junctionImage = Image.resolveAssetSource(maneuver.junctionImage);
|
|
30
|
+
}
|
|
31
|
+
if (maneuver.tintSymbolImage && typeof maneuver.tintSymbolImage === 'string') {
|
|
32
|
+
maneuver.tintSymbolImage = processColor(maneuver.tintSymbolImage);
|
|
33
|
+
}
|
|
34
|
+
return maneuver;
|
|
35
|
+
}),
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public updateTravelEstimates(maneuverIndex: number, travelEstimates: TravelEstimates) {
|
|
40
|
+
if (!travelEstimates.distanceUnits) {
|
|
41
|
+
travelEstimates.distanceUnits = 'kilometers';
|
|
42
|
+
}
|
|
43
|
+
CarPlay.bridge.updateTravelEstimatesNavigationSession(this.id, maneuverIndex, travelEstimates);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public cancel() {
|
|
47
|
+
CarPlay.bridge.cancelNavigationSession(this.id);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public finish() {
|
|
51
|
+
CarPlay.bridge.finishNavigationSession(this.id);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public pause(reason: PauseReason, description?: string) {
|
|
55
|
+
CarPlay.bridge.pauseNavigationSession(this.id, reason, description);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { CarPlay } from '../CarPlay';
|
|
2
|
+
|
|
3
|
+
export interface RouteChoice {
|
|
4
|
+
additionalInformationVariants: string[];
|
|
5
|
+
selectionSummaryVariants: string[];
|
|
6
|
+
summaryVariants: string[];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface TripPoint {
|
|
10
|
+
latitude: number;
|
|
11
|
+
longitude: number;
|
|
12
|
+
name: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface TripConfig {
|
|
16
|
+
id?: string;
|
|
17
|
+
origin: TripPoint;
|
|
18
|
+
destination: TripPoint;
|
|
19
|
+
routeChoices: RouteChoice[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class Trip {
|
|
23
|
+
public id!: string;
|
|
24
|
+
|
|
25
|
+
constructor(public config: TripConfig) {
|
|
26
|
+
if (config.id) {
|
|
27
|
+
this.id = config.id;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (!this.id) {
|
|
31
|
+
this.id = `trip-${Date.now()}-${Math.round(Math.random() * Number.MAX_SAFE_INTEGER)}`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
CarPlay.bridge.createTrip(this.id, config);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AlertAction } from '../interfaces/AlertAction';
|
|
2
|
+
import { Template, TemplateConfig } from './Template';
|
|
3
|
+
|
|
4
|
+
export interface ActionSheetTemplateConfig extends TemplateConfig {
|
|
5
|
+
title: string;
|
|
6
|
+
message?: string;
|
|
7
|
+
actions: AlertAction[];
|
|
8
|
+
onActionButtonPressed?(e: { id: string; templateId: string }): void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class ActionSheetTemplate extends Template<ActionSheetTemplateConfig> {
|
|
12
|
+
public get type(): string {
|
|
13
|
+
return 'actionsheet';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get eventMap() {
|
|
17
|
+
return {
|
|
18
|
+
actionButtonPressed: 'onActionButtonPressed',
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AlertAction } from '../interfaces/AlertAction';
|
|
2
|
+
import { Template, TemplateConfig } from './Template';
|
|
3
|
+
|
|
4
|
+
export interface AlertTemplateConfig extends TemplateConfig {
|
|
5
|
+
titleVariants: string[];
|
|
6
|
+
actions?: AlertAction[];
|
|
7
|
+
onActionButtonPressed?(e: { id: string; templateId: string }): void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class AlertTemplate extends Template<AlertTemplateConfig> {
|
|
11
|
+
public get type(): string {
|
|
12
|
+
return 'alert';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
get eventMap() {
|
|
16
|
+
return {
|
|
17
|
+
actionButtonPressed: 'onActionButtonPressed',
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ImageSourcePropType } from 'react-native';
|
|
2
|
+
import { Template, TemplateConfig } from './Template';
|
|
3
|
+
|
|
4
|
+
export interface ContactButtonEvent {
|
|
5
|
+
id: string;
|
|
6
|
+
templateId: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ContactActionBase {
|
|
10
|
+
id: string;
|
|
11
|
+
type: 'call' | 'directions' | 'message';
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
title?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ContactActionMessage extends ContactActionBase {
|
|
17
|
+
type: 'message';
|
|
18
|
+
phoneOrEmail: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type ContactAction = ContactActionBase | ContactActionMessage;
|
|
22
|
+
|
|
23
|
+
export interface ContactTemplateConfig extends TemplateConfig {
|
|
24
|
+
name: string;
|
|
25
|
+
image: ImageSourcePropType;
|
|
26
|
+
subtitle?: string;
|
|
27
|
+
informativeText?: string;
|
|
28
|
+
actions?: ContactAction[];
|
|
29
|
+
/**
|
|
30
|
+
* Fired when bar button is pressed
|
|
31
|
+
* @param e Event
|
|
32
|
+
*/
|
|
33
|
+
onButtonPressed?(e: ContactButtonEvent): void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export class ContactTemplate extends Template<ContactTemplateConfig> {
|
|
37
|
+
public get type(): string {
|
|
38
|
+
return 'contact';
|
|
39
|
+
}
|
|
40
|
+
get eventMap() {
|
|
41
|
+
return {
|
|
42
|
+
buttonPressed: 'onButtonPressed',
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { GridButton } from '../interfaces/GridButton';
|
|
2
|
+
import { BaseEvent, Template, TemplateConfig } from './Template';
|
|
3
|
+
|
|
4
|
+
export interface ButtonPressedEvent extends BaseEvent {
|
|
5
|
+
/**
|
|
6
|
+
* Button ID
|
|
7
|
+
*/
|
|
8
|
+
id: string;
|
|
9
|
+
/**
|
|
10
|
+
* Button Index
|
|
11
|
+
*/
|
|
12
|
+
index: number;
|
|
13
|
+
/**
|
|
14
|
+
* template ID
|
|
15
|
+
*/
|
|
16
|
+
templateId: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface GridTemplateConfig extends TemplateConfig {
|
|
20
|
+
/**
|
|
21
|
+
* The title displayed in the navigation bar while the list template is visible.
|
|
22
|
+
*/
|
|
23
|
+
title?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The array of grid buttons displayed on the template.
|
|
26
|
+
*/
|
|
27
|
+
buttons: GridButton[];
|
|
28
|
+
/**
|
|
29
|
+
* Fired when a button is pressed
|
|
30
|
+
*/
|
|
31
|
+
onButtonPressed?(e: ButtonPressedEvent): void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class GridTemplate extends Template<GridTemplateConfig> {
|
|
35
|
+
public get type(): string {
|
|
36
|
+
return 'grid';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
get eventMap() {
|
|
40
|
+
return {
|
|
41
|
+
gridButtonPressed: 'onButtonPressed',
|
|
42
|
+
backButtonPressed: 'onBackButtonPressed',
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Template, TemplateConfig } from './Template';
|
|
2
|
+
import { CarPlay } from '../CarPlay';
|
|
3
|
+
|
|
4
|
+
export interface InformationItem {
|
|
5
|
+
title: string;
|
|
6
|
+
detail: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface InformationAction {
|
|
10
|
+
id: string;
|
|
11
|
+
title: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface InformationTemplateConfig extends TemplateConfig {
|
|
15
|
+
title: string;
|
|
16
|
+
leading?: boolean;
|
|
17
|
+
items: InformationItem[];
|
|
18
|
+
actions: InformationAction[];
|
|
19
|
+
onActionButtonPressed(e: { id: string; templateId: string }): void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class InformationTemplate extends Template<InformationTemplateConfig> {
|
|
23
|
+
public get type(): string {
|
|
24
|
+
return 'information';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
get eventMap() {
|
|
28
|
+
return {
|
|
29
|
+
actionButtonPressed: 'onActionButtonPressed',
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public updateInformationTemplateItems = (items: InformationItem[]) => {
|
|
34
|
+
this.config.items = items;
|
|
35
|
+
return CarPlay.bridge.updateInformationTemplateItems(this.id, this.parseConfig(items));
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
public updateInformationTemplateActions = (actions: InformationAction[]) => {
|
|
39
|
+
this.config.actions = actions;
|
|
40
|
+
return CarPlay.bridge.updateInformationTemplateActions(this.id, this.parseConfig(actions));
|
|
41
|
+
};
|
|
42
|
+
}
|