@iternio/react-native-auto-play 0.1.7 → 0.1.8

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 CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  [![npm version](https://img.shields.io/npm/v/@iternio/react-native-auto-play.svg)](https://www.npmjs.com/package/@iternio/react-native-auto-play)
11
11
  [![npm downloads](https://img.shields.io/npm/dm/@iternio/react-native-auto-play.svg)](https://www.npmjs.com/package/@iternio/react-native-auto-play)
12
- [![License](https://img.shields.io/npm/l/@iternio/react-native-auto-play.svg)](https://github.com/Iternio-Planning-AB/react-native-auto-play/blob/main/LICENSE)
12
+ [![License](https://img.shields.io/npm/l/@iternio/react-native-auto-play.svg)](https://github.com/Iternio-Planning-AB/react-native-auto-play/blob/master/LICENSE.md)
13
13
 
14
14
  ## Features
15
15
 
@@ -196,6 +196,30 @@ In case you wanna open up your CarPlay app from one of the CarPlay dashboard but
196
196
  ### Android Auto
197
197
  No platform specific setup required - we got you covered with all the required stuff.
198
198
 
199
+ ### Android Auto Customization
200
+ You can customize certain behaviors of the library on Android Auto by setting properties in your app's `android/gradle.properties` file.
201
+
202
+ - **Telemetry Update Interval**: Control how often telemetry data is updated.
203
+ ```properties
204
+ ReactNativeAutoPlay_androidTelemetryUpdateInterval=4000
205
+ ```
206
+ The value is in milliseconds. The default is `4000`.
207
+
208
+ - **UI Scale Factor**: Apply a scaling factor to the React Native UI rendered on the car screen. This does not affect the templates.
209
+ ```properties
210
+ ReactNativeAutoPlay_androidAutoScaleFactor=1.5f
211
+ ```
212
+ The default value is `1.5`.
213
+
214
+ - **Cluster Splash Screen**: Customize the splash screen shown on the instrument cluster.
215
+ ```properties
216
+ # Delay in milliseconds after the root component is rendered before the splash screen hides.
217
+ ReactNativeAutoPlay_clusterSplashDelayMs=1000
218
+ # Duration of the splash screen fade out animation in milliseconds.
219
+ ReactNativeAutoPlay_clusterSplashDurationMs=500
220
+ ```
221
+ The default values are `1000` for the delay and `500` for the duration.
222
+
199
223
  ## Icons
200
224
  The library is using [Material Symbols](https://fonts.google.com/icons) for iconography. The font is bundled with the library, so no extra setup is required. You can use these icons on both Android Auto and CarPlay.
201
225
 
@@ -384,8 +408,8 @@ useEffect(() => {
384
408
 
385
409
  - `useMapTemplate()`: Get a reference to the parent `MapTemplate` instance.
386
410
  - `useVoiceInput()`: Access voice input functionality - Android Auto only.
387
- - `useSafeAreaInsets()`: Get safe area insets for the car screen.
388
- - `useFocusedEffect()`: A useEffect alternative that executes when the specified component is visible to the user - use any of the `AutoPlayModules` enum or a cluster uuid.
411
+ - `useSafeAreaInsets()`: Get safe area insets for any root component.
412
+ - `useFocusedEffect()`: A useEffect alternative that executes when the specified component is visible to the user - use any of the `AutoPlayModules` enum or a cluster uuid to sepcify the component the effect should listen for.
389
413
  - `useAndroidAutoTelemetry()`: Access to car telemetry data on Android Auto.
390
414
  ```tsx
391
415
  import {
@@ -442,6 +466,17 @@ useEffect(() => {
442
466
  - **Broken exceptions with `react-native-skia`**: When using `react-native-skia` up to version `2.4.7`, exceptions on iOS are not reported correctly. This is fixed in newer versions of `react-native-skia`. For more details, see this [pull request](https://github.com/Shopify/react-native-skia/pull/3595).
443
467
  - **AppState on iOS**: The `AppState` module from React Native does not work correctly on iOS because this library uses scenes, which are not supported by the stock `AppState` module. This library provides a custom state listener that works for both Android and iOS. Use `HybridAutoPlay.addListenerRenderState` instead of `AppState`.
444
468
  - **Timers stop on screen lock**: iOS stops all timers when the device's main screen is turned off. To ensure timers continue to run (which is often necessary for background tasks related to autoplay), a patch for `react-native` is required. A patch is included in the root `patches/` directory and can be applied using `patch-package`.
469
+ - **expo-splash-screen stuck on iOS**: The `expo-splash-screen` module is broken on iOS because it does not support scenes, which are used by this library. This can cause the splash screen to be stuck on either the mobile device or on CarPlay. To fix this, a patch for `expo-splash-screen` is included in the root `patches/` directory and can be applied using `patch-package`. After applying the patch, you can hide the splash screen for a specific scene by passing the module name to the `hide` or `hideAsync` function. The module name can be one of the values from the `AutoPlayModules` enum or the UUID of a cluster screen.
470
+ ```tsx
471
+ import { hideAsync } from 'expo-splash-screen';
472
+ import { AutoPlayModules } from '@iternio/react-native-auto-play';
473
+
474
+ // Hide the splash screen for the main app
475
+ hideAsync(AutoPlayModules.App);
476
+
477
+ // Hide the splash screen for the CarPlay screen
478
+ hideAsync(AutoPlayModules.AutoPlayRoot);
479
+ ```
445
480
 
446
481
  ## Contributing
447
482
 
@@ -450,3 +485,4 @@ Contributions are welcome! Please submit a pull request.
450
485
  ## License
451
486
 
452
487
  This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
488
+
@@ -70,6 +70,9 @@ class AutoPlayInterfaceController: NSObject, CPInterfaceControllerDelegate {
70
70
  ) async throws -> String? {
71
71
  guard let templateId = topTemplateId else { return nil }
72
72
 
73
+ // Ensure at least one template remains
74
+ guard templates.count > 1 else { return nil }
75
+
73
76
  try await interfaceController.popTemplate(
74
77
  animated: animated
75
78
  )
@@ -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
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iternio/react-native-auto-play",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Android Auto and Apple CarPlay for react-native",
5
5
  "main": "lib/index",
6
6
  "module": "lib/index",
@@ -1,7 +0,0 @@
1
- /**
2
- * A hook to determine if the CarPlay/Android Auto screen is currently focused (visible).
3
- *
4
- * @param moduleName The name of the module to listen to.
5
- * @returns `true` if the screen is focused, `false` otherwise.
6
- */
7
- export declare function useIsAutoPlayFocused(moduleName: string): boolean;
@@ -1,20 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- import { HybridAutoPlay } from '..';
3
- /**
4
- * A hook to determine if the CarPlay/Android Auto screen is currently focused (visible).
5
- *
6
- * @param moduleName The name of the module to listen to.
7
- * @returns `true` if the screen is focused, `false` otherwise.
8
- */
9
- export function useIsAutoPlayFocused(moduleName) {
10
- const [isFocused, setIsFocused] = useState(false);
11
- useEffect(() => {
12
- const remove = HybridAutoPlay.addListenerRenderState(moduleName, (state) => {
13
- setIsFocused(state === 'didAppear');
14
- });
15
- return () => {
16
- remove();
17
- };
18
- }, [moduleName]);
19
- return isFocused;
20
- }
package/lib/hybrid.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import type { AutoPlay as NitroAutoPlay } from './specs/AutoPlay.nitro';
2
- export declare const HybridAutoPlay: NitroAutoPlay;
package/lib/hybrid.js DELETED
@@ -1,2 +0,0 @@
1
- import { NitroModules } from 'react-native-nitro-modules';
2
- export const HybridAutoPlay = NitroModules.createHybridObject('AutoPlay');