@iternio/react-native-auto-play 0.1.1 → 0.1.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.
@@ -129,15 +129,13 @@ class HybridAutoPlay: HybridAutoPlaySpec {
129
129
  scene,
130
130
  interfaceController in
131
131
  let carPlayTemplate = template.getTemplate()
132
-
132
+
133
133
  if carPlayTemplate is CPMapTemplate {
134
134
  try await MainActor.run {
135
135
  try scene.initRootView()
136
136
  }
137
137
  }
138
138
 
139
- await template.invalidate()
140
-
141
139
  let _ = try await interfaceController.setRootTemplate(
142
140
  carPlayTemplate,
143
141
  animated: false
@@ -162,9 +160,9 @@ class HybridAutoPlay: HybridAutoPlaySpec {
162
160
 
163
161
  return try await RootModule.withInterfaceController {
164
162
  interfaceController in
165
-
163
+
166
164
  let carPlayTemplate = template.getTemplate()
167
-
165
+
168
166
  if carPlayTemplate is CPAlertTemplate {
169
167
  let animated = try await
170
168
  !interfaceController.dismissTemplate(
@@ -39,6 +39,13 @@ class AutoPlayScene: UIResponder {
39
39
  current
40
40
  }
41
41
 
42
+ // Get trait collection from the CarPlay interface controller
43
+ if let carTraitCollection = interfaceController?.interfaceController
44
+ .carTraitCollection
45
+ {
46
+ self.traitCollection = carTraitCollection
47
+ }
48
+
42
49
  if let window = self.window {
43
50
  ViewUtils.showLaunchScreen(window: window)
44
51
  safeAreaInsets = window.safeAreaInsets
@@ -64,7 +71,7 @@ class AutoPlayScene: UIResponder {
64
71
  "window nil for module: \(moduleName)"
65
72
  )
66
73
  }
67
-
74
+
68
75
  guard
69
76
  let rootView = ViewUtils.getRootView(
70
77
  moduleName: moduleName,
@@ -84,6 +91,11 @@ class AutoPlayScene: UIResponder {
84
91
  }
85
92
 
86
93
  open func traitCollectionDidChange(traitCollection: UITraitCollection) {
94
+ if self.traitCollection.userInterfaceStyle
95
+ == traitCollection.userInterfaceStyle
96
+ {
97
+ return
98
+ }
87
99
  self.traitCollection = traitCollection
88
100
  TemplateStore.traitCollectionDidChange()
89
101
  }
@@ -0,0 +1,8 @@
1
+ import type { HybridObject } from 'react-native-nitro-modules';
2
+ import type { CleanupCallback } from '../types/Event';
3
+ export interface VoiceInput extends HybridObject<{
4
+ android: 'kotlin';
5
+ ios: 'swift';
6
+ }> {
7
+ registerVoiceInputListener(callback: (voiceInputResult?: string, error?: string) => void): CleanupCallback;
8
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iternio/react-native-auto-play",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Android Auto and Apple CarPlay for react-native",
5
5
  "main": "lib/index",
6
6
  "module": "lib/index",
@@ -1,15 +0,0 @@
1
- import type { HybridObject } from 'react-native-nitro-modules';
2
- import type { CleanupCallback } from '../types/Event';
3
- import type { Telemetry } from '../types/Telemetry';
4
- export interface HybridAndroidAutoTelemetry extends HybridObject<{
5
- android: 'kotlin';
6
- }> {
7
- /**
8
- * Register a listener for Android Auto telemetry data. Should be registered only after the telemetry permissions are granted otherwise no data will be received.
9
- * @param callback the callback to receive the telemetry data
10
- * @param error the error message if the telemetry listener failed to start
11
- * @returns callback to remove the listener
12
- * @namespace Android
13
- */
14
- registerTelemetryListener(callback: (tlm?: Telemetry, error?: string) => void): CleanupCallback;
15
- }
@@ -1,64 +0,0 @@
1
- import type { HybridObject } from 'react-native-nitro-modules';
2
- import type { TemplateConfig } from '../templates/Template';
3
- import type { CleanupCallback, EventName, SafeAreaInsets, VisibilityState } from '../types/Event';
4
- import type { NitroAction } from '../utils/NitroAction';
5
- export interface NitroTemplateConfig extends TemplateConfig {
6
- id: string;
7
- }
8
- export interface HybridAutoPlay extends HybridObject<{
9
- android: 'kotlin';
10
- ios: 'swift';
11
- }> {
12
- /**
13
- * attach a listener for didConnect and didDisconnect
14
- * @namespace all
15
- * @param eventType generic events
16
- * @returns callback to remove the listener
17
- */
18
- addListener(eventType: EventName, callback: () => void): CleanupCallback;
19
- /**
20
- * adds a listener for the session/scene state
21
- * fires willAppear & didAppear when the scene/session is visible
22
- * fires willDisappear & didDisappear when the scene/session is not visible
23
- * @param moduleName on of @AutoPlayModules, a cluster scene uuid or your main for the WindowApplicationSceneDelegate
24
- */
25
- addListenerRenderState(moduleName: string, callback: (payload: VisibilityState) => void): CleanupCallback;
26
- /**
27
- * sets the specified template as root template, initializes a new stack
28
- * Promise might contain an error message in case setting root template failed
29
- * can be used on any Android screen/iOS scene
30
- */
31
- setRootTemplate(templateId: string): Promise<void>;
32
- /**
33
- * push a template to the AutoPlayRoot Android screen/iOS scene
34
- */
35
- pushTemplate(templateId: string): Promise<void>;
36
- /**
37
- * remove the top template from the stack
38
- * @param animate - defaults to true
39
- */
40
- popTemplate(animate?: boolean): Promise<void>;
41
- /**
42
- * remove all templates from the stack except the root template
43
- * @param animate - defaults to true
44
- */
45
- popToRootTemplate(animate?: boolean): Promise<void>;
46
- /**
47
- * removes all templates until the specified one is the top template
48
- */
49
- popToTemplate(templateId: string, animate?: boolean): Promise<void>;
50
- /**
51
- * callback for safe area insets changes
52
- * @param insets the insets that you use to determine the safe area for this view.
53
- */
54
- addSafeAreaInsetsListener(moduleName: string, callback: (insets: SafeAreaInsets) => void): CleanupCallback;
55
- /**
56
- * update a templates headerActions
57
- */
58
- setTemplateHeaderActions(templateId: string, headerActions?: Array<NitroAction>): void;
59
- /**
60
- * Check if AutoPlay is connected.
61
- * @returns true if AutoPlay is connected, false otherwise.
62
- */
63
- isConnected(): boolean;
64
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,22 +0,0 @@
1
- import type { HybridObject } from 'react-native-nitro-modules';
2
- import type { CleanupCallback, EventName } from '../types/Event';
3
- import type { ColorScheme } from '../types/RootComponent';
4
- import type { NitroImage } from '../utils/NitroImage';
5
- export interface BaseCarPlayDashboardButton {
6
- titleVariants: Array<string>;
7
- subtitleVariants: Array<string>;
8
- onPress: () => void;
9
- launchHeadUnitScene?: boolean;
10
- }
11
- interface NitroCarPlayDashboardButton extends BaseCarPlayDashboardButton {
12
- image: NitroImage;
13
- }
14
- export interface HybridCarPlayDashboard extends HybridObject<{
15
- ios: 'swift';
16
- }> {
17
- addListener(eventType: EventName, callback: () => void): CleanupCallback;
18
- setButtons(buttons: Array<NitroCarPlayDashboardButton>): Promise<void>;
19
- initRootView(): void;
20
- addListenerColorScheme(callback: (payload: ColorScheme) => void): CleanupCallback;
21
- }
22
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,19 +0,0 @@
1
- import type { HybridObject } from 'react-native-nitro-modules';
2
- import type { CleanupCallback } from '../types/Event';
3
- import type { ColorScheme } from '../types/RootComponent';
4
- import type { NitroAttributedString } from '../utils/NitroAttributedString';
5
- type ClusterEventName = 'didConnect' | 'didConnectWithWindow' | 'didDisconnect' | 'didDisconnectFromWindow';
6
- export type ZoomEvent = 'in' | 'out';
7
- export interface HybridCluster extends HybridObject<{
8
- android: 'kotlin';
9
- ios: 'swift';
10
- }> {
11
- addListener(eventType: ClusterEventName, callback: (clusterId: string) => void): CleanupCallback;
12
- initRootView(clusterId: string): Promise<void>;
13
- setAttributedInactiveDescriptionVariants(clusterId: string, attributedInactiveDescriptionVariants: Array<NitroAttributedString>): void;
14
- addListenerColorScheme(callback: (clusterId: string, payload: ColorScheme) => void): CleanupCallback;
15
- addListenerZoom(callback: (clusterId: string, payload: ZoomEvent) => void): CleanupCallback;
16
- addListenerCompass(callback: (clusterId: string, payload: boolean) => void): CleanupCallback;
17
- addListenerSpeedLimit(callback: (clusterId: string, payload: boolean) => void): CleanupCallback;
18
- }
19
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,14 +0,0 @@
1
- import type { HybridObject } from 'react-native-nitro-modules';
2
- import type { NitroGridTemplateConfig } from '../templates/GridTemplate';
3
- import type { NitroGridButton } from '../utils/NitroGrid';
4
- import type { NitroTemplateConfig } from './HybridAutoPlay.nitro';
5
- interface GridTemplateConfig extends NitroTemplateConfig, NitroGridTemplateConfig {
6
- }
7
- export interface HybridGridTemplate extends HybridObject<{
8
- android: 'kotlin';
9
- ios: 'swift';
10
- }> {
11
- createGridTemplate(config: GridTemplateConfig): void;
12
- updateGridTemplateButtons(templateId: string, buttons: Array<NitroGridButton>): void;
13
- }
14
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,13 +0,0 @@
1
- import type { HybridObject } from 'react-native-nitro-modules';
2
- import type { NitroInformationTemplateConfig } from '../templates/InformationTemplate';
3
- import type { NitroTemplateConfig } from './HybridAutoPlay.nitro';
4
- interface InformationTemplateConfig extends NitroTemplateConfig, NitroInformationTemplateConfig {
5
- }
6
- export interface HybridInformationTemplate extends HybridObject<{
7
- android: 'kotlin';
8
- ios: 'swift';
9
- }> {
10
- createInformationTemplate(config: InformationTemplateConfig): void;
11
- updateInformationTemplateSections(templateId: string, section: NitroInformationTemplateConfig['section']): void;
12
- }
13
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,13 +0,0 @@
1
- import type { HybridObject } from 'react-native-nitro-modules';
2
- import type { NitroListTemplateConfig } from '../templates/ListTemplate';
3
- import type { NitroTemplateConfig } from './HybridAutoPlay.nitro';
4
- interface ListTemplateConfig extends NitroTemplateConfig, NitroListTemplateConfig {
5
- }
6
- export interface HybridListTemplate extends HybridObject<{
7
- android: 'kotlin';
8
- ios: 'swift';
9
- }> {
10
- createListTemplate(config: ListTemplateConfig): void;
11
- updateListTemplateSections(templateId: string, sections: NitroListTemplateConfig['sections']): void;
12
- }
13
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,25 +0,0 @@
1
- import type { HybridObject } from 'react-native-nitro-modules';
2
- import type { NavigationAlertCallbacks, NitroMapTemplateConfig, TripSelectorCallback, VisibleTravelEstimate } from '../templates/MapTemplate';
3
- import type { TripConfig, TripPoint, TripPreviewTextConfiguration, TripsConfig } from '../types/Trip';
4
- import type { NitroNavigationAlert } from '../utils/NitroAlert';
5
- import type { NitroManeuver } from '../utils/NitroManeuver';
6
- import type { NitroMapButton } from '../utils/NitroMapButton';
7
- import type { NitroTemplateConfig } from './HybridAutoPlay.nitro';
8
- interface MapTemplateConfig extends NitroTemplateConfig, NitroMapTemplateConfig {
9
- }
10
- export interface HybridMapTemplate extends HybridObject<{
11
- android: 'kotlin';
12
- ios: 'swift';
13
- }> {
14
- createMapTemplate(config: MapTemplateConfig): void;
15
- showNavigationAlert(templateId: string, alert: NitroNavigationAlert): NavigationAlertCallbacks;
16
- showTripSelector(templateId: string, trips: Array<TripsConfig>, selectedTripId: string | undefined, textConfig: TripPreviewTextConfiguration, onTripSelected: (tripId: string, routeId: string) => void, onTripStarted: (tripId: string, routeId: string) => void, onBackPressed: () => void, mapButtons: Array<NitroMapButton>): TripSelectorCallback;
17
- hideTripSelector(templateId: string): void;
18
- setTemplateMapButtons(templateId: string, buttons?: Array<NitroMapButton>): void;
19
- updateVisibleTravelEstimate(templateId: string, visibleTravelEstimate: VisibleTravelEstimate): void;
20
- updateTravelEstimates(templateId: string, steps: Array<TripPoint>): void;
21
- updateManeuvers(templateId: string, maneuvers: NitroManeuver): void;
22
- startNavigation(templateId: string, trip: TripConfig): void;
23
- stopNavigation(templateId: string): void;
24
- }
25
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,12 +0,0 @@
1
- import type { HybridObject } from 'react-native-nitro-modules';
2
- import type { NitroMessageTemplateConfig } from '../templates/MessageTemplate';
3
- import type { NitroTemplateConfig } from './HybridAutoPlay.nitro';
4
- interface MessageTemplateConfig extends NitroTemplateConfig, NitroMessageTemplateConfig {
5
- }
6
- export interface HybridMessageTemplate extends HybridObject<{
7
- android: 'kotlin';
8
- ios: 'swift';
9
- }> {
10
- createMessageTemplate(config: MessageTemplateConfig): void;
11
- }
12
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,13 +0,0 @@
1
- import type { HybridObject } from 'react-native-nitro-modules';
2
- import type { NitroSearchTemplateConfig } from '../templates/SearchTemplate';
3
- import type { NitroTemplateConfig } from './HybridAutoPlay.nitro';
4
- interface SearchTemplateConfig extends NitroTemplateConfig, NitroSearchTemplateConfig {
5
- }
6
- export interface HybridSearchTemplate extends HybridObject<{
7
- android: 'kotlin';
8
- ios: 'swift';
9
- }> {
10
- createSearchTemplate(config: SearchTemplateConfig): void;
11
- updateSearchResults(templateId: string, results: NitroSearchTemplateConfig['results']): void;
12
- }
13
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,37 +0,0 @@
1
- type Translation = {
2
- x: number;
3
- y: number;
4
- };
5
- type Velocity = {
6
- x: number;
7
- y: number;
8
- };
9
- /**
10
- * @param translation screen coordinate offset
11
- * @param velocity only reported on iOS/CarPlay
12
- */
13
- export type PanGestureWithTranslationEventPayload = {
14
- translation: Translation;
15
- velocity?: Velocity;
16
- };
17
- /**
18
- * @param x screen coordinate of the pinch center
19
- * @param y screen coordinate of the pinch center
20
- * @param scaleFactor value > 0.0 and < 2.0 when 1.0 means no scaling, > 1.0 zoom in and < 1.0 zoom out, value == 2.0 is a double tap
21
- * @namespace Android
22
- */
23
- export type PinchGestureEventPayload = {
24
- x: number;
25
- y: number;
26
- scaleFactor: number;
27
- };
28
- /**
29
- * @param x screen coordinate of the press event
30
- * @param y screen coordinate of the press event
31
- * @namespace Android
32
- */
33
- export type PressEventPayload = {
34
- x: number;
35
- y: number;
36
- };
37
- export {};
@@ -1 +0,0 @@
1
- export {};