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

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.
@@ -533,15 +533,6 @@ class MapTemplate: NSObject, AutoPlayTemplate, AutoPlayHeaderProviding,
533
533
  startedTrip trip: CPTrip,
534
534
  using routeChoice: CPRouteChoice
535
535
  ) {
536
- if let onTripStarted = self.onTripStarted {
537
- let tripId = trip.id
538
- let routeId = routeChoice.id
539
-
540
- onTripStarted(tripId, routeId)
541
- }
542
-
543
- hideTripSelector()
544
-
545
536
  let trip = CPTrip(
546
537
  origin: trip.origin,
547
538
  destination: trip.destination,
@@ -550,6 +541,15 @@ class MapTemplate: NSObject, AutoPlayTemplate, AutoPlayHeaderProviding,
550
541
  )
551
542
 
552
543
  startNavigation(trip: trip)
544
+
545
+ if let onTripStarted = self.onTripStarted {
546
+ let tripId = trip.id
547
+ let routeId = routeChoice.id
548
+
549
+ onTripStarted(tripId, routeId)
550
+ }
551
+
552
+ hideTripSelector()
553
553
  }
554
554
 
555
555
  func updateVisibleTravelEstimate(
@@ -0,0 +1,7 @@
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;
@@ -0,0 +1,20 @@
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
+ }
@@ -0,0 +1,2 @@
1
+ import type { AutoPlay as NitroAutoPlay } from './specs/AutoPlay.nitro';
2
+ export declare const HybridAutoPlay: NitroAutoPlay;
package/lib/hybrid.js ADDED
@@ -0,0 +1,2 @@
1
+ import { NitroModules } from 'react-native-nitro-modules';
2
+ export const HybridAutoPlay = NitroModules.createHybridObject('AutoPlay');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iternio/react-native-auto-play",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Android Auto and Apple CarPlay for react-native",
5
5
  "main": "lib/index",
6
6
  "module": "lib/index",
@@ -1,8 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- export {};