@javascriptcommon/react-native-carplay 2.3.11 → 2.4.2

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.
Files changed (136) hide show
  1. package/android/build.gradle +110 -0
  2. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  3. package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  4. package/android/gradle.properties +20 -0
  5. package/android/gradlew +234 -0
  6. package/android/gradlew.bat +89 -0
  7. package/android/src/main/AndroidManifest.xml +30 -0
  8. package/android/src/main/AndroidManifestNew.xml +30 -0
  9. package/android/src/main/java/org/birkir/carplay/CarPlayModule.kt +321 -0
  10. package/android/src/main/java/org/birkir/carplay/CarPlayPackage.kt +18 -0
  11. package/android/src/main/java/org/birkir/carplay/CarPlayService.kt +35 -0
  12. package/android/src/main/java/org/birkir/carplay/CarPlaySession.kt +126 -0
  13. package/android/src/main/java/org/birkir/carplay/parser/Ext.kt +11 -0
  14. package/android/src/main/java/org/birkir/carplay/parser/Parser.kt +18 -0
  15. package/android/src/main/java/org/birkir/carplay/parser/RCTGridTemplate.kt +28 -0
  16. package/android/src/main/java/org/birkir/carplay/parser/RCTListTemplate.kt +64 -0
  17. package/android/src/main/java/org/birkir/carplay/parser/RCTMapTemplate.kt +128 -0
  18. package/android/src/main/java/org/birkir/carplay/parser/RCTMessageTemplate.kt +28 -0
  19. package/android/src/main/java/org/birkir/carplay/parser/RCTPaneTemplate.kt +24 -0
  20. package/android/src/main/java/org/birkir/carplay/parser/RCTSearchTemplate.kt +41 -0
  21. package/android/src/main/java/org/birkir/carplay/parser/RCTTabTemplate.kt +157 -0
  22. package/android/src/main/java/org/birkir/carplay/parser/RCTTemplate.kt +419 -0
  23. package/android/src/main/java/org/birkir/carplay/parser/TemplateParser.kt +35 -0
  24. package/android/src/main/java/org/birkir/carplay/screens/CarScreen.kt +76 -0
  25. package/android/src/main/java/org/birkir/carplay/screens/CarScreenContext.kt +10 -0
  26. package/android/src/main/java/org/birkir/carplay/utils/EventEmitter.kt +167 -0
  27. package/android/src/main/java/org/birkir/carplay/utils/VirtualRenderer.kt +75 -0
  28. package/ios/RCTConvert+RNCarPlay.h +7 -8
  29. package/ios/RCTConvert+RNCarPlay.m +4 -3
  30. package/ios/RNCarPlay.h +11 -14
  31. package/ios/RNCarPlay.m +749 -945
  32. package/ios/RNCarPlayViewController.h +10 -0
  33. package/ios/RNCarPlayViewController.m +50 -0
  34. package/lib/CarPlay.d.ts +183 -0
  35. package/lib/CarPlay.d.ts.map +1 -0
  36. package/lib/index.d.ts +44 -0
  37. package/lib/index.d.ts.map +1 -0
  38. package/lib/interfaces/Action.d.ts +13 -0
  39. package/lib/interfaces/Action.d.ts.map +1 -0
  40. package/lib/interfaces/AlertAction.d.ts +6 -0
  41. package/lib/interfaces/AlertAction.d.ts.map +1 -0
  42. package/lib/interfaces/BarButton.d.ts +39 -0
  43. package/lib/interfaces/BarButton.d.ts.map +1 -0
  44. package/lib/interfaces/CarColor.d.ts +2 -0
  45. package/lib/interfaces/CarColor.d.ts.map +1 -0
  46. package/lib/interfaces/GridButton.d.ts +24 -0
  47. package/lib/interfaces/GridButton.d.ts.map +1 -0
  48. package/lib/interfaces/Header.d.ts +15 -0
  49. package/lib/interfaces/Header.d.ts.map +1 -0
  50. package/lib/interfaces/ListItem.d.ts +90 -0
  51. package/lib/interfaces/ListItem.d.ts.map +1 -0
  52. package/lib/interfaces/ListItemUpdate.d.ts +15 -0
  53. package/lib/interfaces/ListItemUpdate.d.ts.map +1 -0
  54. package/lib/interfaces/ListSection.d.ts +21 -0
  55. package/lib/interfaces/ListSection.d.ts.map +1 -0
  56. package/lib/interfaces/Maneuver.d.ts +31 -0
  57. package/lib/interfaces/Maneuver.d.ts.map +1 -0
  58. package/lib/interfaces/MapButton.d.ts +27 -0
  59. package/lib/interfaces/MapButton.d.ts.map +1 -0
  60. package/lib/interfaces/NavigationAlert.d.ts +44 -0
  61. package/lib/interfaces/NavigationAlert.d.ts.map +1 -0
  62. package/lib/interfaces/NavigationInfo.d.ts +17 -0
  63. package/lib/interfaces/NavigationInfo.d.ts.map +1 -0
  64. package/lib/interfaces/NavigationStep.d.ts +17 -0
  65. package/lib/interfaces/NavigationStep.d.ts.map +1 -0
  66. package/lib/interfaces/Pane.d.ts +29 -0
  67. package/lib/interfaces/Pane.d.ts.map +1 -0
  68. package/lib/interfaces/PauseReason.d.ts +8 -0
  69. package/lib/interfaces/PauseReason.d.ts.map +1 -0
  70. package/lib/interfaces/Place.d.ts +11 -0
  71. package/lib/interfaces/Place.d.ts.map +1 -0
  72. package/lib/interfaces/TextConfiguration.d.ts +6 -0
  73. package/lib/interfaces/TextConfiguration.d.ts.map +1 -0
  74. package/lib/interfaces/TimeRemainingColor.d.ts +2 -0
  75. package/lib/interfaces/TimeRemainingColor.d.ts.map +1 -0
  76. package/lib/interfaces/TravelEstimates.d.ts +37 -0
  77. package/lib/interfaces/TravelEstimates.d.ts.map +1 -0
  78. package/lib/interfaces/VoiceControlState.d.ts +8 -0
  79. package/lib/interfaces/VoiceControlState.d.ts.map +1 -0
  80. package/lib/navigation/NavigationSession.d.ts +18 -0
  81. package/lib/navigation/NavigationSession.d.ts.map +1 -0
  82. package/lib/navigation/Trip.d.ts +22 -0
  83. package/lib/navigation/Trip.d.ts.map +1 -0
  84. package/lib/templates/ActionSheetTemplate.d.ts +18 -0
  85. package/lib/templates/ActionSheetTemplate.d.ts.map +1 -0
  86. package/lib/templates/AlertTemplate.d.ts +17 -0
  87. package/lib/templates/AlertTemplate.d.ts.map +1 -0
  88. package/lib/templates/ContactTemplate.d.ts +36 -0
  89. package/lib/templates/ContactTemplate.d.ts.map +1 -0
  90. package/lib/templates/GridTemplate.d.ts +38 -0
  91. package/lib/templates/GridTemplate.d.ts.map +1 -0
  92. package/lib/templates/InformationTemplate.d.ts +28 -0
  93. package/lib/templates/InformationTemplate.d.ts.map +1 -0
  94. package/lib/templates/ListTemplate.d.ts +127 -0
  95. package/lib/templates/ListTemplate.d.ts.map +1 -0
  96. package/lib/templates/ListTemplate.js +24 -16
  97. package/lib/templates/MapTemplate.d.ts +171 -0
  98. package/lib/templates/MapTemplate.d.ts.map +1 -0
  99. package/lib/templates/NowPlayingTemplate.d.ts +31 -0
  100. package/lib/templates/NowPlayingTemplate.d.ts.map +1 -0
  101. package/lib/templates/PointOfInterestTemplate.d.ts +33 -0
  102. package/lib/templates/PointOfInterestTemplate.d.ts.map +1 -0
  103. package/lib/templates/SearchTemplate.d.ts +32 -0
  104. package/lib/templates/SearchTemplate.d.ts.map +1 -0
  105. package/lib/templates/SearchTemplate.js +2 -2
  106. package/lib/templates/TabBarTemplate.d.ts +27 -0
  107. package/lib/templates/TabBarTemplate.d.ts.map +1 -0
  108. package/lib/templates/Template.d.ts +82 -0
  109. package/lib/templates/Template.d.ts.map +1 -0
  110. package/lib/templates/Template.js +1 -1
  111. package/lib/templates/VoiceControlTemplate.d.ts +18 -0
  112. package/lib/templates/VoiceControlTemplate.d.ts.map +1 -0
  113. package/lib/templates/android/AndroidNavigationBaseTemplate.d.ts +19 -0
  114. package/lib/templates/android/AndroidNavigationBaseTemplate.d.ts.map +1 -0
  115. package/lib/templates/android/MessageTemplate.d.ts +16 -0
  116. package/lib/templates/android/MessageTemplate.d.ts.map +1 -0
  117. package/lib/templates/android/NavigationTemplate.d.ts +44 -0
  118. package/lib/templates/android/NavigationTemplate.d.ts.map +1 -0
  119. package/lib/templates/android/PaneTemplate.d.ts +13 -0
  120. package/lib/templates/android/PaneTemplate.d.ts.map +1 -0
  121. package/lib/templates/android/PlaceListMapTemplate.d.ts +58 -0
  122. package/lib/templates/android/PlaceListMapTemplate.d.ts.map +1 -0
  123. package/lib/templates/android/PlaceListNavigationTemplate.d.ts +51 -0
  124. package/lib/templates/android/PlaceListNavigationTemplate.d.ts.map +1 -0
  125. package/lib/templates/android/RoutePreviewNavigationTemplate.d.ts +60 -0
  126. package/lib/templates/android/RoutePreviewNavigationTemplate.d.ts.map +1 -0
  127. package/package.json +3 -3
  128. package/react-native-carplay.podspec +3 -3
  129. package/src/CarPlay.ts +28 -16
  130. package/src/interfaces/ListItem.ts +14 -8
  131. package/src/interfaces/ListSection.ts +1 -1
  132. package/src/templates/ListTemplate.ts +64 -44
  133. package/src/templates/NowPlayingTemplate.ts +10 -3
  134. package/src/templates/SearchTemplate.ts +2 -2
  135. package/src/templates/Template.ts +1 -1
  136. package/README.md +0 -633
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PaneTemplate.d.ts","sourceRoot":"","sources":["../../../src/templates/android/PaneTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAE7C,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD,IAAI,EAAE,IAAI,CAAC;IACX,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,YAAa,SAAQ,QAAQ,CAAC,kBAAkB,CAAC;IAC5D,IAAW,IAAI,IAAI,MAAM,CAExB;CACF"}
@@ -0,0 +1,58 @@
1
+ import { Action, HeaderAction } from '../../interfaces/Action';
2
+ import { AndroidNavigationBaseTemplate, AndroidNavigationBaseTemplateConfig } from './AndroidNavigationBaseTemplate';
3
+ import { Place } from '../../interfaces/Place';
4
+ import { ListItem } from '../../interfaces/ListItem';
5
+ export interface PlaceListMapTemplateConfig extends AndroidNavigationBaseTemplateConfig {
6
+ /**
7
+ * Sets an ActionStrip with a list of template-scoped actions for this template.
8
+ * The Action buttons in Map Based Template are automatically adjusted based on the screen size. On narrow width screen, icon Actions show by default. If no icon specify, showing title Actions instead. On wider width screen, title Actions show by default. If no title specify, showing icon Actions instead.
9
+ * @limit This template allows up to 4 Actions in its ActionStrip. Of the 4 allowed Actions, it can either be a title Action as set via setTitle, or a icon Action as set via setIcon.
10
+ */
11
+ actions?: Action[];
12
+ /**
13
+ * Sets the anchor maker on the map.
14
+ * An anchor marker will not be displayed unless set with this method.
15
+ * The anchor marker is displayed differently from other markers by the host.
16
+ * If not null, an anchor marker will be shown at the specified CarLocation on the map. The camera will adapt to always have the anchor marker visible within its viewport, along with other places' markers from Row that are currently visible in the Pane. This can be used to provide a reference point on the map (e.g. the center of a search region) as the user pages through the Pane's markers, for example.
17
+ */
18
+ anchor?: Place;
19
+ /**
20
+ * Sets whether to show the current location in the map.
21
+ * The map template will show the user's current location on the map.
22
+ * This functionality requires the app to have either the ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION permission. When isEnabled is true, the host may receive location updates from the app in order to show the user's current location.
23
+ */
24
+ currentLocationEnabled?: boolean;
25
+ /**
26
+ * Sets the Action that will be displayed in the header of the template.
27
+ * Unless set with this method, the template will not have a header action.
28
+ * @limit This template only supports either one of APP_ICON and BACK as a header Action.
29
+ */
30
+ headerAction?: HeaderAction;
31
+ /**
32
+ * Sets an ItemList to show in a list view along with the map.
33
+ * Unless set with this method, the template will not show an item list.
34
+ * To show a marker corresponding to a point of interest represented by a row, set the Place instance via setMetadata. The host will display the PlaceMarker in both the map and the list view as the row becomes visible.
35
+ * @limit The number of items in the ItemList should be smaller or equal than the limit provided by CONTENT_LIMIT_TYPE_PLACE_LIST. The host will ignore any items over that limit. The list itself cannot be selectable as set via setOnSelectedListener. Each Row can add up to 2 lines of texts via addText and cannot contain a Toggle.
36
+ */
37
+ itemList?: ListItem[];
38
+ /**
39
+ * Sets whether the template is in a loading state.
40
+ */
41
+ loading?: boolean;
42
+ /**
43
+ * Title for the map
44
+ */
45
+ title?: string;
46
+ }
47
+ /**
48
+ * A template that displays a map along with a list of places.
49
+ * The map can display markers corresponding to the places in the list. See setItemList for details.
50
+ * Template Restrictions In regards to template refreshes, as described in onGetTemplate, this template is considered a refresh of a previous one if:
51
+ * - The previous template is in a loading state (see setLoading, or
52
+ * - The template title has not changed, and the number of rows and the title (not counting spans) of each row between the previous and new ItemLists have not changed.
53
+ * - The template is sent in response to a user-initiated content refresh request. (see setOnContentRefreshListener.
54
+ */
55
+ export declare class PlaceListMapTemplate extends AndroidNavigationBaseTemplate<PlaceListMapTemplateConfig> {
56
+ get type(): string;
57
+ }
58
+ //# sourceMappingURL=PlaceListMapTemplate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlaceListMapTemplate.d.ts","sourceRoot":"","sources":["../../../src/templates/android/PlaceListMapTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EACL,6BAA6B,EAC7B,mCAAmC,EACpC,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,MAAM,WAAW,0BAA2B,SAAQ,mCAAmC;IACrF;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC;IACf;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC;;;;OAIG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;IACtB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,qBAAa,oBAAqB,SAAQ,6BAA6B,CAAC,0BAA0B,CAAC;IACjG,IAAW,IAAI,IAAI,MAAM,CAExB;CACF"}
@@ -0,0 +1,51 @@
1
+ import { Action } from '../../interfaces/Action';
2
+ import { Header } from '../../interfaces/Header';
3
+ import { ListItem } from '../../interfaces/ListItem';
4
+ import { AndroidNavigationBaseTemplate, AndroidNavigationBaseTemplateConfig } from './AndroidNavigationBaseTemplate';
5
+ export interface PlaceListNavigationTemplateConfig extends AndroidNavigationBaseTemplateConfig {
6
+ /**
7
+ * Sets an ActionStrip with a list of template-scoped actions for this template.
8
+ * The Action buttons in Map Based Template are automatically adjusted based on the screen size. On narrow width screen, icon Actions show by default. If no icon specify, showing title Actions instead. On wider width screen, title Actions show by default. If no title specify, showing icon Actions instead.
9
+ * @limit This template allows up to 4 Actions in its ActionStrip. Of the 4 allowed Actions, it can either be a title Action as set via setTitle, or a icon Action as set via setIcon.
10
+ */
11
+ actions?: Action[];
12
+ /**
13
+ * Sets the Header for this template.
14
+ */
15
+ header?: Header;
16
+ /**
17
+ * Sets an ItemList to show in a list view along with the map.
18
+ * Unless set with this method, the template will not show an item list.
19
+ * To show a marker corresponding to a point of interest represented by a row, set the Place instance via setMetadata. The host will display the PlaceMarker in both the map and the list view as the row becomes visible.
20
+ * @limit The number of items in the ItemList should be smaller or equal than the limit provided by CONTENT_LIMIT_TYPE_PLACE_LIST. The host will ignore any items over that limit. The list itself cannot be selectable as set via setOnSelectedListener. Each Row can add up to 2 lines of texts via addText and cannot contain a Toggle.
21
+ */
22
+ itemList?: ListItem[];
23
+ /**
24
+ * Sets whether the template is in a loading state.
25
+ */
26
+ loading?: boolean;
27
+ /**
28
+ * Sets an ActionStrip with a list of map-control related actions for this template, such as pan or zoom.
29
+ * The host will draw the buttons in an area that is associated with map controls.
30
+ * If the app does not include the PAN button in this ActionStrip, the app will not receive the user input for panning gestures from SurfaceCallback methods, and the host will exit any previously activated pan mode.
31
+ * @limit This template allows up to 4 Actions in its map ActionStrip. Only Actions with icons set via setIcon are allowed.
32
+ */
33
+ mapButtons?: Action[];
34
+ /**
35
+ * Title for the map
36
+ */
37
+ title?: string;
38
+ }
39
+ /**
40
+ * A template that supports showing a list of places alongside a custom drawn map.
41
+ * The template itself does not expose a drawing surface. In order to draw on the canvas, use setSurfaceCallback.
42
+ * Template Restrictions In regards to template refreshes, as described in onGetTemplate, this template is considered a refresh of a previous one if:
43
+ * - The previous template is in a loading state (see setLoading, or
44
+ * - The template title has not changed, and the number of rows and the title (not counting spans) of each row between the previous and new ItemLists have not changed.
45
+ * - The template is sent in response to a user-initiated content refresh request. (see setOnContentRefreshListener.
46
+ * In order to use this template your car app MUST declare that it uses the **androidx.car.app.NAVIGATION_TEMPLATES** permission in the manifest.
47
+ */
48
+ export declare class PlaceListNavigationTemplate extends AndroidNavigationBaseTemplate<PlaceListNavigationTemplateConfig> {
49
+ get type(): string;
50
+ }
51
+ //# sourceMappingURL=PlaceListNavigationTemplate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlaceListNavigationTemplate.d.ts","sourceRoot":"","sources":["../../../src/templates/android/PlaceListNavigationTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EACL,6BAA6B,EAC7B,mCAAmC,EACpC,MAAM,iCAAiC,CAAC;AAEzC,MAAM,WAAW,iCAAkC,SAAQ,mCAAmC;IAC5F;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;IACtB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;GAQG;AACH,qBAAa,2BAA4B,SAAQ,6BAA6B,CAAC,iCAAiC,CAAC;IAC/G,IAAW,IAAI,IAAI,MAAM,CAExB;CACF"}
@@ -0,0 +1,60 @@
1
+ import { Action } from '../../interfaces/Action';
2
+ import { Header } from '../../interfaces/Header';
3
+ import { ListItem } from '../../interfaces/ListItem';
4
+ import { AndroidNavigationBaseTemplate, AndroidNavigationBaseTemplateConfig } from './AndroidNavigationBaseTemplate';
5
+ export interface RoutePreviewNavigationTemplateConfig extends AndroidNavigationBaseTemplateConfig {
6
+ /**
7
+ * Sets an ActionStrip with a list of template-scoped actions for this template.
8
+ * The Action buttons in Map Based Template are automatically adjusted based on the screen size. On narrow width screen, icon Actions show by default. If no icon specify, showing title Actions instead. On wider width screen, title Actions show by default. If no title specify, showing icon Actions instead.
9
+ * @limit This template allows up to 4 Actions in its ActionStrip. Of the 4 allowed Actions, it can either be a title Action as set via setTitle, or a icon Action as set via setIcon.
10
+ */
11
+ actions?: Action[];
12
+ /**
13
+ * Sets the Header for this template.
14
+ */
15
+ header?: Header;
16
+ /**
17
+ * Sets an ItemList to show in a list view along with the map.
18
+ * Unless set with this method, the template will not show an item list.
19
+ * To show a marker corresponding to a point of interest represented by a row, set the Place instance via setMetadata. The host will display the PlaceMarker in both the map and the list view as the row becomes visible.
20
+ * @limit The number of items in the ItemList should be smaller or equal than the limit provided by CONTENT_LIMIT_TYPE_PLACE_LIST. The host will ignore any items over that limit. The list itself cannot be selectable as set via setOnSelectedListener. Each Row can add up to 2 lines of texts via addText and cannot contain a Toggle.
21
+ */
22
+ itemList?: ListItem[];
23
+ /**
24
+ * Sets whether the template is in a loading state.
25
+ */
26
+ loading?: boolean;
27
+ /**
28
+ * Sets an ActionStrip with a list of map-control related actions for this template, such as pan or zoom.
29
+ * The host will draw the buttons in an area that is associated with map controls.
30
+ * If the app does not include the PAN button in this ActionStrip, the app will not receive the user input for panning gestures from SurfaceCallback methods, and the host will exit any previously activated pan mode.
31
+ * @limit This template allows up to 4 Actions in its map ActionStrip. Only Actions with icons set via setIcon are allowed.
32
+ */
33
+ mapButtons?: Action[];
34
+ /**
35
+ * Sets the Action to allow users to request navigation using the currently selected route.
36
+ * This should not be null if the template is not in a loading state (see #setIsLoading}), and the Action's title must be set.
37
+ * Spans are not supported in the navigate action and will be ignored.
38
+ */
39
+ navigateAction?: Action;
40
+ /**
41
+ * Title for the map
42
+ */
43
+ title?: string;
44
+ }
45
+ /**
46
+ * A template that supports showing a list of routes alongside a custom drawn map.
47
+ * The list must have its ItemList.OnSelectedListener set, and the template must have its navigate action set (see setNavigateAction). These are used in conjunction to inform the app that:
48
+ * - A route has been selected. The app should also highlight the route on the map surface.
49
+ * - A navigate action has been triggered. The app should begin navigation using the selected route.
50
+ * The template itself does not expose a drawing surface. In order to draw on the canvas, use setSurfaceCallback.
51
+ * Template Restrictions In regards to template refreshes, as described in onGetTemplate, this template is considered a refresh of a previous one if:
52
+ * - The previous template is in a loading state (see setLoading, or
53
+ * - The template title has not changed, and the number of rows and the title (not counting spans) of each row between the previous and new ItemLists have not changed.
54
+ * Note that specifically, this means the app should not use this template to continuously refresh the routes as the car moves.
55
+ * In order to use this template your car app MUST declare that it uses the **androidx.car.app.NAVIGATION_TEMPLATES** permission in the manifest.
56
+ */
57
+ export declare class RoutePreviewNavigationTemplate extends AndroidNavigationBaseTemplate<RoutePreviewNavigationTemplateConfig> {
58
+ get type(): string;
59
+ }
60
+ //# sourceMappingURL=RoutePreviewNavigationTemplate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RoutePreviewNavigationTemplate.d.ts","sourceRoot":"","sources":["../../../src/templates/android/RoutePreviewNavigationTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EACL,6BAA6B,EAC7B,mCAAmC,EACpC,MAAM,iCAAiC,CAAC;AAEzC,MAAM,WAAW,oCAAqC,SAAQ,mCAAmC;IAC/F;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;IACtB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,8BAA+B,SAAQ,6BAA6B,CAAC,oCAAoC,CAAC;IACrH,IAAW,IAAI,IAAI,MAAM,CAExB;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@javascriptcommon/react-native-carplay",
3
- "version": "2.3.11",
3
+ "version": "2.4.2",
4
4
  "description": "CarPlay for React Native",
5
5
  "main": "lib/index.js",
6
6
  "react-native": "src/index.ts",
@@ -9,6 +9,7 @@
9
9
  "src",
10
10
  "lib",
11
11
  "ios",
12
+ "android",
12
13
  "react-native-carplay.podspec"
13
14
  ],
14
15
  "podspecPath": "./react-native-carplay.podspec",
@@ -16,7 +17,7 @@
16
17
  "prepack": "yarn run build",
17
18
  "lint": "eslint . --ext .ts,.tsx,.js,.jsx",
18
19
  "typecheck": "tsc --noEmit",
19
- "build": "tsc",
20
+ "build": "tsc -p tsconfig.build.json",
20
21
  "fix-all-files": "eslint . --ext .ts,.tsx,.js,.jsx --fix"
21
22
  },
22
23
  "repository": {
@@ -55,7 +56,6 @@
55
56
  "@types/node": "17.0.25",
56
57
  "@types/react": "18.0.6",
57
58
  "@types/react-native": "0.67.5",
58
- "babel-jest": "^29.2.1",
59
59
  "cross-env": "7.0.3",
60
60
  "docusaurus-plugin-typedoc": "0.19.2",
61
61
  "eslint": "^8.19.0",
@@ -3,7 +3,7 @@ require 'json'
3
3
  package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
4
 
5
5
  Pod::Spec.new do |s|
6
- s.name = 'react-native-carplay'
6
+ s.name = package['name']
7
7
  s.version = package['version']
8
8
  s.summary = package['description']
9
9
 
@@ -13,9 +13,9 @@ Pod::Spec.new do |s|
13
13
  s.authors = package['author']
14
14
  s.ios.deployment_target = '12.0'
15
15
 
16
- s.source = { :git => "https://github.com/Spicy-Sparks/react-native-carplay.git" }
16
+ s.source = { :git => "https://github.com/birkir/react-native-carplay.git" }
17
17
 
18
18
  s.source_files = "ios/*.{h,m}"
19
19
 
20
- s.dependency 'React-Core'
20
+ s.dependency 'React'
21
21
  end
package/src/CarPlay.ts CHANGED
@@ -1,29 +1,35 @@
1
- import { ImageSourcePropType, NativeEventEmitter, NativeModule, NativeModules, Platform } from 'react-native';
1
+ import {
2
+ ImageSourcePropType,
3
+ NativeEventEmitter,
4
+ NativeModule,
5
+ NativeModules,
6
+ Platform,
7
+ } from 'react-native';
8
+ import { Action } from './interfaces/Action';
9
+ import { Maneuver } from './interfaces/Maneuver';
10
+ import { PauseReason } from './interfaces/PauseReason';
11
+ import { TextConfiguration } from './interfaces/TextConfiguration';
12
+ import { TimeRemainingColor } from './interfaces/TimeRemainingColor';
13
+ import { TravelEstimates } from './interfaces/TravelEstimates';
14
+ import { TripConfig } from './navigation/Trip';
2
15
  import { ActionSheetTemplate } from './templates/ActionSheetTemplate';
3
16
  import { AlertTemplate } from './templates/AlertTemplate';
4
17
  import { ContactTemplate } from './templates/ContactTemplate';
5
18
  import { GridTemplate } from './templates/GridTemplate';
6
19
  import { InformationTemplate } from './templates/InformationTemplate';
7
20
  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
21
  import { MapTemplate } from './templates/MapTemplate';
22
+ import { NowPlayingTemplate } from './templates/NowPlayingTemplate';
13
23
  import { PointOfInterestTemplate } from './templates/PointOfInterestTemplate';
14
24
  import { SearchTemplate } from './templates/SearchTemplate';
15
25
  import { TabBarTemplate } from './templates/TabBarTemplate';
16
26
  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
27
  import { MessageTemplate } from './templates/android/MessageTemplate';
28
+ import { NavigationTemplate } from './templates/android/NavigationTemplate';
26
29
  import { PaneTemplate } from './templates/android/PaneTemplate';
30
+ import { PlaceListMapTemplate } from './templates/android/PlaceListMapTemplate';
31
+ import { PlaceListNavigationTemplate } from './templates/android/PlaceListNavigationTemplate';
32
+ import { RoutePreviewNavigationTemplate } from './templates/android/RoutePreviewNavigationTemplate';
27
33
 
28
34
  export interface InternalCarPlay extends NativeModule {
29
35
  checkForConnection(): void;
@@ -74,12 +80,13 @@ export interface InternalCarPlay extends NativeModule {
74
80
  dismissPanningInterface(id: string, animated: boolean): void;
75
81
  getMaximumListSectionCount(id: string): Promise<number>;
76
82
  getMaximumListItemCount(id: string): Promise<number>;
77
- getMaximumRowItemsCount(id: string): Promise<number>;
83
+ getMaximumListItemImageSize(id: string): Promise<ImageSize>;
84
+ getMaximumNumberOfGridImages(id: string): Promise<number>;
85
+ getMaximumListImageRowItemImageSize(id: string): Promise<ImageSize>;
78
86
  reactToSelectedResult(status: boolean): void;
79
87
  updateListTemplateSections(id: string, config: unknown): void;
80
88
  updateListTemplateItem(id: string, config: unknown): void;
81
- updateListTemplateRowItems(id: string, config: unknown): void;
82
- reactToUpdatedSearchText(items: unknown): void;
89
+ reactToUpdatedSearchText(id: string, items: unknown): void;
83
90
  updateTabBarTemplates(id: string, config: unknown): void;
84
91
  activateVoiceControlState(id: string, identifier: string): void;
85
92
  // Android
@@ -121,6 +128,11 @@ export type WindowInformation = {
121
128
  scale: number;
122
129
  };
123
130
 
131
+ export type ImageSize = {
132
+ width: number;
133
+ height: number;
134
+ };
135
+
124
136
  export type OnConnectCallback = (window: WindowInformation) => void;
125
137
  export type OnDisconnectCallback = () => void;
126
138
 
@@ -17,27 +17,33 @@ export interface ListItem {
17
17
  * Extra text displayed below the primary text in the list item cell.
18
18
  */
19
19
  detailText?: string;
20
+ /**
21
+ * Image from file system displayed on the leading edge of the list item cell.
22
+ */
23
+ placeholderImage?: ImageSourcePropType;
20
24
  /**
21
25
  * Image from file system displayed on the leading edge of the list item cell.
22
26
  */
23
27
  image?: ImageSourcePropType;
24
28
  /**
25
- * The image name displayed on the leading edge of the list item cell.
29
+ * A list of images shown in the ListRowImageItem
30
+ * @namespace iOS
26
31
  */
27
- imageName?: string;
32
+ placeholderImages?: ImageSourcePropType[];
28
33
  /**
29
- * Url for image displayed on the leading edge of the list item cell.
34
+ * A list of images shown in the ListRowImageItem
35
+ * @namespace iOS
30
36
  */
31
- imgUrl?: string;
37
+ images?: ImageSourcePropType[];
32
38
  /**
33
- * Is Artist flag.
39
+ * Url for image displayed on the leading edge of the list item cell.
34
40
  */
35
- isArtist?: boolean
41
+ imgUrl?: null;
36
42
  /**
37
- * The sub items arranged in a row.
43
+ * Url for image displayed on the leading edge of the list item cell.
38
44
  * @namespace iOS
39
45
  */
40
- rowItems?: ListItem[];
46
+ imgUrls?: string[];
41
47
  /**
42
48
  * A Boolean value indicating whether the list item cell shows a disclosure indicator on the trailing edge of the list item cell.
43
49
  * @namespace iOS
@@ -17,5 +17,5 @@ export interface ListSection {
17
17
  /**
18
18
  * The list of items for the section.
19
19
  */
20
- items?: ListItem[];
20
+ items: ListItem[];
21
21
  }
@@ -1,10 +1,11 @@
1
+ import { Platform } from 'react-native';
1
2
  import { CarPlay } from '../CarPlay';
3
+ import { Action } from '../interfaces/Action';
4
+ import { ListItem } from '../interfaces/ListItem';
2
5
  import { ListItemUpdate } from '../interfaces/ListItemUpdate';
3
6
  import { ListSection } from '../interfaces/ListSection';
4
7
  import { Template, TemplateConfig } from './Template';
5
8
 
6
- type CollectionType = '' | 'playlist' | 'artist' | 'groupedArtist' | 'editorial' | 'search' | 'user' | 'allTracks' | 'allRecent' | 'allFavorites'
7
-
8
9
  export interface ListTemplateConfig extends TemplateConfig {
9
10
  /**
10
11
  * The title displayed in the navigation bar while the list template is visible.
@@ -13,7 +14,12 @@ export interface ListTemplateConfig extends TemplateConfig {
13
14
  /**
14
15
  * The sections displayed in the list.
15
16
  */
16
- sections: ListSection[];
17
+ sections?: ListSection[];
18
+ /**
19
+ * Sets a single ItemList to show in the template.
20
+ * @namespace Android
21
+ */
22
+ items?: ListItem[];
17
23
  /**
18
24
  * An optional array of strings, ordered from most to least preferred.
19
25
  * The variant strings should be provided as localized, displayable content.
@@ -23,6 +29,7 @@ export interface ListTemplateConfig extends TemplateConfig {
23
29
  * that the template has no list items.
24
30
  * If the list template is updated to contain items, the empty view will be automatically
25
31
  * removed.
32
+ * @namespace iOS
26
33
  */
27
34
  emptyViewTitleVariants?: string[];
28
35
  /**
@@ -34,6 +41,7 @@ export interface ListTemplateConfig extends TemplateConfig {
34
41
  * that the template has no list items.
35
42
  * If the list template is updated to contain items, the empty view will be automatically
36
43
  * removed.
44
+ * @namespace iOS
37
45
  */
38
46
  emptyViewSubtitleVariants?: string[];
39
47
  /**
@@ -42,20 +50,19 @@ export interface ListTemplateConfig extends TemplateConfig {
42
50
  * When the returned promise is resolved the spinner will hide.
43
51
  * @param item Object with the selected index
44
52
  */
45
- onItemSelect?(item: { index: number }): Promise<void>;
53
+ onItemSelect?(item: { templateId: string; index: number }): Promise<void>;
46
54
 
47
55
  /**
48
- * Fired when row item is selected.
56
+ * Fired when image row item is selected.
49
57
  * Spinner shows by default.
50
58
  * When the returned promise is resolved the spinner will hide.
51
59
  * @param item Object with the selected index
52
60
  */
53
- onRowItemSelect?(item: { index: number }): Promise<void>;
54
-
55
- /**
56
- * Fired when the template is loaded.
57
- */
58
- onTemplateLoaded?(): Promise<void>;
61
+ onImageRowItemSelect?(item: {
62
+ templateId: string;
63
+ index: number;
64
+ imageIndex: number;
65
+ }): Promise<void>;
59
66
 
60
67
  /**
61
68
  * Fired when the back button is pressed
@@ -64,18 +71,14 @@ export interface ListTemplateConfig extends TemplateConfig {
64
71
 
65
72
  /**
66
73
  * Option to hide back button
67
- * (defaults to false)
74
+ * @default false
68
75
  */
69
76
  backButtonHidden?: boolean;
70
77
 
71
- /**
72
- * Back button title
73
- */
74
- backButtonTitle: string;
75
-
76
78
  /**
77
79
  * Assistant Configuration
78
80
  * @see https://developer.apple.com/documentation/carplay/cplisttemplate#3762508
81
+ * @namespace iOS
79
82
  */
80
83
  assistant?: {
81
84
  enabled: boolean;
@@ -83,16 +86,23 @@ export interface ListTemplateConfig extends TemplateConfig {
83
86
  visibility: 'off' | 'always' | 'limited';
84
87
  action: 'playMedia' | 'startCall';
85
88
  };
86
-
87
89
  /**
88
- * Set to true if you are asynchronously updating an existing template
90
+ * Sets whether the template is in a loading state.
91
+ * 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.
92
+ * If set to false, the UI will display the contents of the ItemList instance(s) added via setSingleList or addSectionedList.
93
+ * @namespace Android
89
94
  */
90
- updatingTemplate: boolean;
91
-
95
+ loading?: boolean;
96
+ /**
97
+ * Sets the Action that will be displayed in the header of the template.
98
+ * @namespace Android
99
+ */
100
+ headerAction?: Action<'appIcon' | 'back'>;
92
101
  /**
93
- * Set to true if you want to receive the onTemplateLoaded callback
102
+ * Sets the ActionStrip for this template or null to not display an .
103
+ * This template allows up to 2 Actions. Of the 2 allowed Actions, one of them can contain a title as set via setTitle. Otherwise, only Actions with icons are allowed.
94
104
  */
95
- needsTemplateLoadedCallback: boolean;
105
+ actions?: [Action<'custom'>] | [Action<'custom'>, Action<'custom'>];
96
106
  }
97
107
 
98
108
  /**
@@ -118,41 +128,43 @@ export class ListTemplate extends Template<ListTemplateConfig> {
118
128
  constructor(public config: ListTemplateConfig) {
119
129
  super(config);
120
130
 
121
- CarPlay.emitter.addListener('didSelectListItem', e => {
131
+ CarPlay.emitter.addListener('didSelectListItem', (e: { templateId: string; index: number }) => {
122
132
  if (config.onItemSelect && e.templateId === this.id) {
123
133
  void Promise.resolve(config.onItemSelect(e)).then(() => {
124
- CarPlay.bridge.reactToSelectedResult(true);
134
+ if (Platform.OS === 'ios') {
135
+ CarPlay.bridge.reactToSelectedResult(true);
136
+ }
125
137
  });
126
138
  }
127
139
  });
128
140
 
129
- CarPlay.emitter.addListener('didSelectRowItem', e => {
130
- if (config.onRowItemSelect && e.templateId === this.id) {
131
- void Promise.resolve(config.onRowItemSelect(e)).then(() => {
132
- CarPlay.bridge.reactToSelectedResult(true);
133
- });
134
- }
135
- });
136
-
137
- CarPlay.emitter.addListener('templateLoaded', e => {
138
- if (config.onTemplateLoaded && e.templateId === this.id) {
139
- void Promise.resolve(config.onTemplateLoaded())
140
- }
141
- });
141
+ CarPlay.emitter.addListener(
142
+ 'didSelectListItemRowImage',
143
+ (e: { templateId: string; index: number; imageIndex: number }) => {
144
+ if (config.onImageRowItemSelect && e.templateId === this.id) {
145
+ void Promise.resolve(config.onImageRowItemSelect(e)).then(() => {
146
+ if (Platform.OS === 'ios') {
147
+ CarPlay.bridge.reactToSelectedResult(true);
148
+ }
149
+ });
150
+ }
151
+ },
152
+ );
142
153
  }
143
154
 
144
155
  public updateSections = (sections: ListSection[]) => {
156
+ this.config.sections = sections;
145
157
  return CarPlay.bridge.updateListTemplateSections(this.id, this.parseConfig(sections));
146
158
  };
147
159
 
148
160
  public updateListTemplateItem = (config: ListItemUpdate) => {
161
+ const section = this.config.sections?.[config.sectionIndex];
162
+ if (section) {
163
+ section.items[config.itemIndex] = config;
164
+ }
149
165
  return CarPlay.bridge.updateListTemplateItem(this.id, this.parseConfig(config));
150
166
  };
151
167
 
152
- public updateListTemplateRowItems = (config: ListItemUpdate) => {
153
- return CarPlay.bridge.updateListTemplateRowItems(this.id, this.parseConfig(config));
154
- };
155
-
156
168
  public getMaximumListItemCount() {
157
169
  return CarPlay.bridge.getMaximumListItemCount(this.id);
158
170
  }
@@ -161,7 +173,15 @@ export class ListTemplate extends Template<ListTemplateConfig> {
161
173
  return CarPlay.bridge.getMaximumListSectionCount(this.id);
162
174
  }
163
175
 
164
- public getMaximumRowItemsCount() {
165
- return CarPlay.bridge.getMaximumRowItemsCount(this.id);
176
+ public getMaximumListItemImageSize() {
177
+ return CarPlay.bridge.getMaximumListItemImageSize(this.id);
178
+ }
179
+
180
+ public getMaximumNumberOfGridImages() {
181
+ return CarPlay.bridge.getMaximumNumberOfGridImages(this.id);
182
+ }
183
+
184
+ public getMaximumListImageRowItemImageSize() {
185
+ return CarPlay.bridge.getMaximumListImageRowItemImageSize(this.id);
166
186
  }
167
187
  }
@@ -1,10 +1,17 @@
1
+ import { ImageSourcePropType } from 'react-native';
1
2
  import { Template, TemplateConfig } from './Template';
2
3
 
3
4
  export type NowPlayingButton = {
4
5
  id: string;
5
- imageName: string;
6
- selected: boolean;
7
- };
6
+ } & (
7
+ | {
8
+ type: 'shuffle' | 'add-to-library' | 'more' | 'playback' | 'repeat';
9
+ }
10
+ | {
11
+ type: 'image';
12
+ image: ImageSourcePropType;
13
+ }
14
+ );
8
15
 
9
16
  export interface NowPlayingTemplateConfig extends TemplateConfig {
10
17
  albumArtistButtonEnabled?: boolean;
@@ -1,7 +1,7 @@
1
+ import { Image, Platform } from 'react-native';
1
2
  import { CarPlay } from '../CarPlay';
2
3
  import { ListItem } from '../interfaces/ListItem';
3
4
  import { BaseEvent, Template, TemplateConfig } from './Template';
4
- import { Image, Platform } from 'react-native';
5
5
 
6
6
  export interface SearchTemplateConfig extends TemplateConfig {
7
7
  /**
@@ -49,7 +49,7 @@ export class SearchTemplate extends Template<SearchTemplateConfig> {
49
49
  ...item,
50
50
  image: item.image ? Image.resolveAssetSource(item.image) : undefined,
51
51
  }));
52
- CarPlay.bridge.reactToUpdatedSearchText(parsedResults);
52
+ CarPlay.bridge.reactToUpdatedSearchText(e.templateId, parsedResults);
53
53
  }
54
54
  });
55
55
  }
@@ -3,7 +3,7 @@ import { CarPlay } from '../CarPlay';
3
3
  import { BarButton } from '../interfaces/BarButton';
4
4
 
5
5
  // eslint-disable-next-line @typescript-eslint/no-var-requires
6
- const resolveAssetSource = require('react-native/Libraries/Image/resolveAssetSource');
6
+ const resolveAssetSource = require('react-native/Libraries/Image/resolveAssetSource').default;
7
7
 
8
8
  export interface BaseEvent {
9
9
  /**