@iternio/react-native-auto-play 0.3.9 → 0.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.
Files changed (46) hide show
  1. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/AndroidAutoSession.kt +1 -0
  2. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridMapTemplate.kt +6 -2
  3. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/template/AndroidAutoTemplate.kt +2 -1
  4. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/template/MapTemplate.kt +6 -0
  5. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/utils/BitmapCache.kt +2 -2
  6. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/utils/Debouncer.kt +2 -1
  7. package/ios/hybrid/HybridMapTemplate.swift +9 -5
  8. package/ios/templates/MapTemplate.swift +57 -0
  9. package/ios/templates/Parser.swift +18 -7
  10. package/lib/components/OnAppearedChildRenderer.d.ts +10 -0
  11. package/lib/components/OnAppearedChildRenderer.js +26 -0
  12. package/lib/specs/MapTemplate.nitro.d.ts +2 -0
  13. package/lib/templates/MapTemplate.d.ts +15 -2
  14. package/lib/templates/MapTemplate.js +25 -3
  15. package/lib/types/Maneuver.d.ts +18 -0
  16. package/lib/types/Maneuver.js +13 -0
  17. package/lib/utils/NitroManeuver.d.ts +2 -0
  18. package/lib/utils/NitroMapButton.js +1 -1
  19. package/nitrogen/generated/android/c++/JHybridMapTemplateSpec.cpp +8 -0
  20. package/nitrogen/generated/android/c++/JHybridMapTemplateSpec.hpp +1 -0
  21. package/nitrogen/generated/android/c++/JManeuverState.hpp +64 -0
  22. package/nitrogen/generated/android/c++/JMapTemplateConfig.hpp +5 -1
  23. package/nitrogen/generated/android/c++/JNitroLoadingManeuver.hpp +15 -4
  24. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridMapTemplateSpec.kt +4 -0
  25. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/ManeuverState.kt +25 -0
  26. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/MapTemplateConfig.kt +7 -4
  27. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroLoadingManeuver.kt +9 -3
  28. package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Umbrella.hpp +3 -0
  29. package/nitrogen/generated/ios/c++/HybridMapTemplateSpecSwift.hpp +9 -0
  30. package/nitrogen/generated/ios/swift/HybridMapTemplateSpec.swift +1 -0
  31. package/nitrogen/generated/ios/swift/HybridMapTemplateSpec_cxx.swift +11 -0
  32. package/nitrogen/generated/ios/swift/ManeuverState.swift +48 -0
  33. package/nitrogen/generated/ios/swift/MapTemplateConfig.swift +12 -1
  34. package/nitrogen/generated/ios/swift/NitroLoadingManeuver.swift +25 -2
  35. package/nitrogen/generated/shared/c++/HybridMapTemplateSpec.cpp +1 -0
  36. package/nitrogen/generated/shared/c++/HybridMapTemplateSpec.hpp +4 -0
  37. package/nitrogen/generated/shared/c++/ManeuverState.hpp +64 -0
  38. package/nitrogen/generated/shared/c++/MapTemplateConfig.hpp +8 -1
  39. package/nitrogen/generated/shared/c++/NitroLoadingManeuver.hpp +15 -4
  40. package/package.json +1 -1
  41. package/src/components/OnAppearedChildRenderer.tsx +37 -0
  42. package/src/specs/MapTemplate.nitro.ts +2 -0
  43. package/src/templates/MapTemplate.ts +40 -4
  44. package/src/types/Maneuver.ts +19 -0
  45. package/src/utils/NitroManeuver.ts +2 -0
  46. package/src/utils/NitroMapButton.ts +1 -1
@@ -3,11 +3,12 @@ import { AppRegistry, Platform } from 'react-native';
3
3
  import { NitroModules } from 'react-native-nitro-modules';
4
4
  import type { AutoText } from '..';
5
5
  import { MapTemplateProvider } from '../components/MapTemplateContext';
6
+ import OnAppearedChildRenderer from '../components/OnAppearedChildRenderer';
6
7
  import { SafeAreaInsetsProvider } from '../components/SafeAreaInsetsContext';
7
8
  import { HybridAutoPlay } from '../hybrid/HybridAutoPlay';
8
9
  import type { MapTemplate as NitroMapTemplate } from '../specs/MapTemplate.nitro';
9
10
  import type { ActionButtonAndroid, MapButton, MapPanButton } from '../types/Button';
10
- import type { AutoManeuver } from '../types/Maneuver';
11
+ import type { AutoManeuver, ManeuverState } from '../types/Maneuver';
11
12
  import type { ColorScheme, RootComponentInitialProps } from '../types/RootComponent';
12
13
  import type {
13
14
  TripConfig,
@@ -17,6 +18,7 @@ import type {
17
18
  } from '../types/Trip';
18
19
  import { type NitroAction, NitroActionUtil } from '../utils/NitroAction';
19
20
  import { type NavigationAlert, NitroAlertUtil } from '../utils/NitroAlert';
21
+ import { type NitroColor, NitroColorUtil, type ThemedColor } from '../utils/NitroColor';
20
22
  import { NitroManeuverUtil, type NitroRoutingManeuver } from '../utils/NitroManeuver';
21
23
  import { NitroMapButton } from '../utils/NitroMapButton';
22
24
  import {
@@ -79,6 +81,8 @@ export interface NitroMapTemplateConfig extends TemplateConfig, NitroBaseMapTemp
79
81
  mapButtons?: Array<NitroMapButton>;
80
82
  headerActions?: Array<NitroAction>;
81
83
 
84
+ defaultGuidanceBackgroundColor?: NitroColor;
85
+
82
86
  /**
83
87
  * specify the percentage of screen height/width the pan button should scroll
84
88
  * @namespace iOS
@@ -130,7 +134,11 @@ export type BaseMapTemplateConfig<T> = {
130
134
 
131
135
  export type MapTemplateConfig = Omit<
132
136
  NitroMapTemplateConfig,
133
- 'mapButtons' | 'headerActions' | 'onStopNavigation' | 'onAutoDriveEnabled'
137
+ | 'mapButtons'
138
+ | 'headerActions'
139
+ | 'onStopNavigation'
140
+ | 'onAutoDriveEnabled'
141
+ | 'defaultGuidanceBackgroundColor'
134
142
  > &
135
143
  BaseMapTemplateConfig<MapTemplate> & {
136
144
  /**
@@ -149,6 +157,11 @@ export type MapTemplateConfig = Omit<
149
157
  * @namespace Android
150
158
  */
151
159
  onAutoDriveEnabled?: (template: MapTemplate) => void;
160
+
161
+ /**
162
+ * Initial navigation maneuver background color. Mainly useful, when in CarPlay the default loading maneuver does not have the right color.
163
+ */
164
+ defaultGuidanceBackgroundColor?: ThemedColor | string;
152
165
  };
153
166
 
154
167
  export interface TripSelectorCallback {
@@ -168,6 +181,7 @@ export class MapTemplate extends Template<MapTemplateConfig, MapTemplateConfig['
168
181
  headerActions,
169
182
  onStopNavigation,
170
183
  onAutoDriveEnabled,
184
+ defaultGuidanceBackgroundColor,
171
185
  ...baseConfig
172
186
  } = config;
173
187
 
@@ -180,7 +194,11 @@ export class MapTemplate extends Template<MapTemplateConfig, MapTemplateConfig['
180
194
  children: React.createElement(SafeAreaInsetsProvider, {
181
195
  moduleName: this.id,
182
196
  // biome-ignore lint/correctness/noChildrenProp: there is no other way in a ts file
183
- children: React.createElement(component, props),
197
+ children: React.createElement(OnAppearedChildRenderer, {
198
+ // biome-ignore lint/correctness/noChildrenProp: there is no other way in a ts file
199
+ children: React.createElement(component, props),
200
+ moduleName: this.id,
201
+ }),
184
202
  }),
185
203
  })
186
204
  );
@@ -192,6 +210,10 @@ export class MapTemplate extends Template<MapTemplateConfig, MapTemplateConfig['
192
210
  mapButtons: NitroMapButton.convert(this.template, mapButtons),
193
211
  onStopNavigation: () => onStopNavigation(this.template),
194
212
  onAutoDriveEnabled: onAutoDriveEnabled ? () => onAutoDriveEnabled(this.template) : undefined,
213
+ defaultGuidanceBackgroundColor:
214
+ defaultGuidanceBackgroundColor != null
215
+ ? NitroColorUtil.convert(defaultGuidanceBackgroundColor)
216
+ : undefined,
195
217
  };
196
218
 
197
219
  HybridMapTemplate.createMapTemplate(nitroConfig);
@@ -322,7 +344,11 @@ export class MapTemplate extends Template<MapTemplateConfig, MapTemplateConfig['
322
344
  }
323
345
 
324
346
  if (maneuvers.type === 'loading') {
325
- HybridMapTemplate.updateManeuvers(this.id, { isLoading: true });
347
+ HybridMapTemplate.updateManeuvers(this.id, {
348
+ isLoading: true,
349
+ cardBackgroundColor: NitroColorUtil.convert(maneuvers.cardBackgroundColor),
350
+ text: maneuvers.text != null ? maneuvers.text : undefined,
351
+ });
326
352
  return;
327
353
  }
328
354
 
@@ -341,4 +367,14 @@ export class MapTemplate extends Template<MapTemplateConfig, MapTemplateConfig['
341
367
  public stopNavigation() {
342
368
  HybridMapTemplate.stopNavigation(this.id);
343
369
  }
370
+
371
+ /**
372
+ * Sets the current maneuver state indicating progress within a maneuver.
373
+ * Transition through: continue → initial → prepare → execute → continue
374
+ * @namespace iOS sets CPManeuverState on the CPNavigationSession, used by instrument cluster and HUD
375
+ * @namespace Android no-op, Android Auto does not have an equivalent API
376
+ */
377
+ public setManeuverState(state: ManeuverState) {
378
+ HybridMapTemplate.setManeuverState(this.id, state);
379
+ }
344
380
  }
@@ -64,6 +64,19 @@ export enum KeepType {
64
64
  FollowRoad = 2,
65
65
  }
66
66
 
67
+ /**
68
+ * Describes the progress within a maneuver.
69
+ * Transition through: Continue → Initial → Prepare → Execute → Continue
70
+ * @namespace iOS sets CPManeuverState on the CPNavigationSession
71
+ * @namespace Android no-op, Android Auto does not have an equivalent API
72
+ */
73
+ export enum ManeuverState {
74
+ Continue = 0, // iOS .continue
75
+ Initial = 1, // iOS .initial
76
+ Prepare = 2, // iOS .prepare
77
+ Execute = 3, // iOS .execute
78
+ }
79
+
67
80
  export interface BaseManeuver {
68
81
  /**
69
82
  * @namespace iOS specify a unique identifier, sending over a Maneuver with a known id will only update the travelEstimates on the previously sent Maneuver
@@ -239,6 +252,12 @@ export type MessageManeuver = {
239
252
 
240
253
  export type LoadingManeuver = {
241
254
  type: 'loading';
255
+ cardBackgroundColor: ThemedColor | string;
256
+ /**
257
+ * @namespace iOS CarPlay — shows text on the loading maneuver card
258
+ * @namespace Android Auto — not supported
259
+ */
260
+ text?: string;
242
261
  };
243
262
 
244
263
  export type AutoManeuver =
@@ -54,6 +54,8 @@ export interface NitroMessageManeuver {
54
54
 
55
55
  interface NitroLoadingManeuver {
56
56
  isLoading: true;
57
+ cardBackgroundColor: NitroColor;
58
+ text?: string;
57
59
  }
58
60
 
59
61
  export type NitroManeuver =
@@ -27,7 +27,7 @@ const convert = <T>(template: T, mapButtons?: MapButtons<T>): Array<NitroMapButt
27
27
  ? button.image.backgroundColor
28
28
  : 'transparent';
29
29
 
30
- const fontScale = (button.image.fontScale ?? Platform.OS === 'android') ? 1.0 : 0.65;
30
+ const fontScale = button.image.fontScale ?? (Platform.OS === 'android' ? 1.0 : 0.65);
31
31
 
32
32
  return {
33
33
  type,