@iternio/react-native-auto-play 0.5.5 → 0.5.7
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 +2 -1
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAndroidWindowInformation.kt +49 -0
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAutoPlay.kt +1 -0
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/VirtualRenderer.kt +116 -29
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/VoiceInputManager.kt +2 -1
- package/ios/utils/VoiceInputManager.swift +41 -47
- package/lib/HybridAutoPlay.d.ts +2 -0
- package/lib/HybridAutoPlay.js +2 -0
- package/lib/components/OnAppearedChildRenderer.d.ts +10 -0
- package/lib/components/OnAppearedChildRenderer.js +26 -0
- package/lib/components/WindowInformationWrapper.d.ts +15 -0
- package/lib/components/WindowInformationWrapper.js +17 -0
- package/lib/hooks/useIsAutoPlayFocused.d.ts +7 -0
- package/lib/hooks/useIsAutoPlayFocused.js +20 -0
- package/lib/hybrid/HybridAndroidWindowInformation.android.d.ts +2 -0
- package/lib/hybrid/HybridAndroidWindowInformation.android.js +2 -0
- package/lib/hybrid/HybridAndroidWindowInformation.d.ts +2 -0
- package/lib/hybrid/HybridAndroidWindowInformation.js +1 -0
- package/lib/hybrid.d.ts +2 -0
- package/lib/hybrid.js +2 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +2 -1
- package/lib/scenes/AutoPlayCluster.js +6 -1
- package/lib/specs/AndroidWindowInformation.nitro.d.ts +22 -0
- package/lib/specs/AndroidWindowInformation.nitro.js +1 -0
- package/lib/specs/AutomotivePermissionRequestTemplate.d.ts +11 -0
- package/lib/specs/AutomotivePermissionRequestTemplate.js +1 -0
- package/lib/specs/AutomotivePermissionRequestTemplate.nitro.d.ts +11 -0
- package/lib/specs/AutomotivePermissionRequestTemplate.nitro.js +1 -0
- package/lib/templates/AutomotivePermissionRequestTemplate.d.ts +23 -0
- package/lib/templates/AutomotivePermissionRequestTemplate.js +18 -0
- package/lib/templates/MapTemplate.js +6 -1
- package/lib/types/Glyphmap.d.ts +4105 -0
- package/lib/types/Glyphmap.js +4105 -0
- package/lib/types/RootComponent.d.ts +4 -0
- package/lib/utils/NitroOptionsPanel.d.ts +67 -0
- package/lib/utils/NitroOptionsPanel.js +48 -0
- package/nitro.json +6 -0
- package/nitrogen/generated/android/ReactNativeAutoPlay+autolinking.cmake +2 -0
- package/nitrogen/generated/android/ReactNativeAutoPlayOnLoad.cpp +18 -0
- package/nitrogen/generated/android/c++/JFunc_void_WindowInformation.hpp +77 -0
- package/nitrogen/generated/android/c++/JHybridAndroidWindowInformationSpec.cpp +68 -0
- package/nitrogen/generated/android/c++/JHybridAndroidWindowInformationSpec.hpp +63 -0
- package/nitrogen/generated/android/c++/JWindowInformation.hpp +65 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_WindowInformation.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAndroidWindowInformationSpec.kt +59 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/WindowInformation.kt +61 -0
- package/nitrogen/generated/shared/c++/HybridAndroidWindowInformationSpec.cpp +21 -0
- package/nitrogen/generated/shared/c++/HybridAndroidWindowInformationSpec.hpp +65 -0
- package/nitrogen/generated/shared/c++/WindowInformation.hpp +91 -0
- package/package.json +1 -1
- package/src/components/WindowInformationWrapper.tsx +30 -0
- package/src/hybrid/HybridAndroidWindowInformation.android.ts +5 -0
- package/src/hybrid/HybridAndroidWindowInformation.ts +3 -0
- package/src/index.ts +2 -1
- package/src/scenes/AutoPlayCluster.ts +6 -1
- package/src/specs/AndroidWindowInformation.nitro.ts +24 -0
- package/src/templates/MapTemplate.ts +6 -1
- package/src/types/RootComponent.ts +4 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// WindowInformation.kt
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
package com.margelo.nitro.swe.iternio.reactnativeautoplay
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
import java.util.Objects
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents the JavaScript object/struct "WindowInformation".
|
|
17
|
+
*/
|
|
18
|
+
@DoNotStrip
|
|
19
|
+
@Keep
|
|
20
|
+
data class WindowInformation(
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
val width: Double,
|
|
24
|
+
@DoNotStrip
|
|
25
|
+
@Keep
|
|
26
|
+
val height: Double,
|
|
27
|
+
@DoNotStrip
|
|
28
|
+
@Keep
|
|
29
|
+
val scale: Double
|
|
30
|
+
) {
|
|
31
|
+
/* primary constructor */
|
|
32
|
+
|
|
33
|
+
override fun equals(other: Any?): Boolean {
|
|
34
|
+
if (this === other) return true
|
|
35
|
+
if (other !is WindowInformation) return false
|
|
36
|
+
return Objects.deepEquals(this.width, other.width)
|
|
37
|
+
&& Objects.deepEquals(this.height, other.height)
|
|
38
|
+
&& Objects.deepEquals(this.scale, other.scale)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
override fun hashCode(): Int {
|
|
42
|
+
return arrayOf<Any?>(
|
|
43
|
+
width,
|
|
44
|
+
height,
|
|
45
|
+
scale
|
|
46
|
+
).contentDeepHashCode()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
companion object {
|
|
50
|
+
/**
|
|
51
|
+
* Constructor called from C++
|
|
52
|
+
*/
|
|
53
|
+
@DoNotStrip
|
|
54
|
+
@Keep
|
|
55
|
+
@Suppress("unused")
|
|
56
|
+
@JvmStatic
|
|
57
|
+
private fun fromCpp(width: Double, height: Double, scale: Double): WindowInformation {
|
|
58
|
+
return WindowInformation(width, height, scale)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridAndroidWindowInformationSpec.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "HybridAndroidWindowInformationSpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
11
|
+
|
|
12
|
+
void HybridAndroidWindowInformationSpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridMethod("addWindowInformationListener", &HybridAndroidWindowInformationSpec::addWindowInformationListener);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
} // namespace margelo::nitro::swe::iternio::reactnativeautoplay
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridAndroidWindowInformationSpec.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/HybridObject.hpp>)
|
|
11
|
+
#include <NitroModules/HybridObject.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
// Forward declaration of `WindowInformation` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct WindowInformation; }
|
|
18
|
+
|
|
19
|
+
#include <functional>
|
|
20
|
+
#include <string>
|
|
21
|
+
#include "WindowInformation.hpp"
|
|
22
|
+
|
|
23
|
+
namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
24
|
+
|
|
25
|
+
using namespace margelo::nitro;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* An abstract base class for `AndroidWindowInformation`
|
|
29
|
+
* Inherit this class to create instances of `HybridAndroidWindowInformationSpec` in C++.
|
|
30
|
+
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
31
|
+
* @example
|
|
32
|
+
* ```cpp
|
|
33
|
+
* class HybridAndroidWindowInformation: public HybridAndroidWindowInformationSpec {
|
|
34
|
+
* public:
|
|
35
|
+
* HybridAndroidWindowInformation(...): HybridObject(TAG) { ... }
|
|
36
|
+
* // ...
|
|
37
|
+
* };
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
class HybridAndroidWindowInformationSpec: public virtual HybridObject {
|
|
41
|
+
public:
|
|
42
|
+
// Constructor
|
|
43
|
+
explicit HybridAndroidWindowInformationSpec(): HybridObject(TAG) { }
|
|
44
|
+
|
|
45
|
+
// Destructor
|
|
46
|
+
~HybridAndroidWindowInformationSpec() override = default;
|
|
47
|
+
|
|
48
|
+
public:
|
|
49
|
+
// Properties
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
public:
|
|
53
|
+
// Methods
|
|
54
|
+
virtual std::function<void()> addWindowInformationListener(const std::string& moduleName, const std::function<void(const WindowInformation& /* window */)>& callback) = 0;
|
|
55
|
+
|
|
56
|
+
protected:
|
|
57
|
+
// Hybrid Setup
|
|
58
|
+
void loadHybridMethods() override;
|
|
59
|
+
|
|
60
|
+
protected:
|
|
61
|
+
// Tag for logging
|
|
62
|
+
static constexpr auto TAG = "AndroidWindowInformation";
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
} // namespace margelo::nitro::swe::iternio::reactnativeautoplay
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// WindowInformation.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
26
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
27
|
+
#else
|
|
28
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A struct which can be represented as a JavaScript object (WindowInformation).
|
|
39
|
+
*/
|
|
40
|
+
struct WindowInformation final {
|
|
41
|
+
public:
|
|
42
|
+
double width SWIFT_PRIVATE;
|
|
43
|
+
double height SWIFT_PRIVATE;
|
|
44
|
+
double scale SWIFT_PRIVATE;
|
|
45
|
+
|
|
46
|
+
public:
|
|
47
|
+
WindowInformation() = default;
|
|
48
|
+
explicit WindowInformation(double width, double height, double scale): width(width), height(height), scale(scale) {}
|
|
49
|
+
|
|
50
|
+
public:
|
|
51
|
+
friend bool operator==(const WindowInformation& lhs, const WindowInformation& rhs) = default;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
} // namespace margelo::nitro::swe::iternio::reactnativeautoplay
|
|
55
|
+
|
|
56
|
+
namespace margelo::nitro {
|
|
57
|
+
|
|
58
|
+
// C++ WindowInformation <> JS WindowInformation (object)
|
|
59
|
+
template <>
|
|
60
|
+
struct JSIConverter<margelo::nitro::swe::iternio::reactnativeautoplay::WindowInformation> final {
|
|
61
|
+
static inline margelo::nitro::swe::iternio::reactnativeautoplay::WindowInformation fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
62
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
63
|
+
return margelo::nitro::swe::iternio::reactnativeautoplay::WindowInformation(
|
|
64
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "width"))),
|
|
65
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "height"))),
|
|
66
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "scale")))
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::swe::iternio::reactnativeautoplay::WindowInformation& arg) {
|
|
70
|
+
jsi::Object obj(runtime);
|
|
71
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "width"), JSIConverter<double>::toJSI(runtime, arg.width));
|
|
72
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "height"), JSIConverter<double>::toJSI(runtime, arg.height));
|
|
73
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "scale"), JSIConverter<double>::toJSI(runtime, arg.scale));
|
|
74
|
+
return obj;
|
|
75
|
+
}
|
|
76
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
77
|
+
if (!value.isObject()) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
jsi::Object obj = value.getObject(runtime);
|
|
81
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "width")))) return false;
|
|
85
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "height")))) return false;
|
|
86
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "scale")))) return false;
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
} // namespace margelo::nitro
|
package/package.json
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { createElement, useEffect, useState } from 'react';
|
|
3
|
+
import { HybridAndroidWindowInformation } from '../hybrid/HybridAndroidWindowInformation';
|
|
4
|
+
import type { RootComponentInitialProps } from '../types/RootComponent';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Renders a user-provided root component and keeps its `window` prop up to date when the host
|
|
8
|
+
* recreates the render surface with new dimensions (some head units run Android Auto windowed
|
|
9
|
+
* and resize it at runtime), so consumers can simply read `props.window` without registering a
|
|
10
|
+
* listener themselves.
|
|
11
|
+
* On iOS this only passes the initial props through — CarPlay windows keep their size for the
|
|
12
|
+
* lifetime of a scene, so there is nothing to subscribe to.
|
|
13
|
+
*/
|
|
14
|
+
export function WindowInformationWrapper({
|
|
15
|
+
moduleName,
|
|
16
|
+
component,
|
|
17
|
+
componentProps,
|
|
18
|
+
}: {
|
|
19
|
+
moduleName: string;
|
|
20
|
+
component: React.ComponentType<RootComponentInitialProps>;
|
|
21
|
+
componentProps: RootComponentInitialProps;
|
|
22
|
+
}) {
|
|
23
|
+
const [window, setWindow] = useState(componentProps.window);
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
return HybridAndroidWindowInformation?.addWindowInformationListener(moduleName, setWindow);
|
|
27
|
+
}, [moduleName]);
|
|
28
|
+
|
|
29
|
+
return createElement(component, { ...componentProps, window });
|
|
30
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { NitroModules } from 'react-native-nitro-modules';
|
|
2
|
+
import type { AndroidWindowInformation } from '../specs/AndroidWindowInformation.nitro';
|
|
3
|
+
|
|
4
|
+
export const HybridAndroidWindowInformation: AndroidWindowInformation | null =
|
|
5
|
+
NitroModules.createHybridObject<AndroidWindowInformation>('AndroidWindowInformation');
|
package/src/index.ts
CHANGED
|
@@ -2,13 +2,14 @@ import { Platform } from 'react-native';
|
|
|
2
2
|
import { NitroModules } from 'react-native-nitro-modules';
|
|
3
3
|
import AutoPlayHeadlessJsTask from './AutoPlayHeadlessJsTask';
|
|
4
4
|
import { HybridAndroidAutoTelemetry } from './hybrid/HybridAndroidAutoTelemetry';
|
|
5
|
+
import { HybridAndroidWindowInformation } from './hybrid/HybridAndroidWindowInformation';
|
|
5
6
|
import { HybridAutoPlay } from './hybrid/HybridAutoPlay';
|
|
6
7
|
import { HybridVoice } from './hybrid/HybridVoice';
|
|
7
8
|
import type { AndroidAutomotive } from './specs/AndroidAutomotive.nitro';
|
|
8
9
|
|
|
9
10
|
AutoPlayHeadlessJsTask.registerHeadlessTask(HybridAutoPlay);
|
|
10
11
|
|
|
11
|
-
export { HybridAndroidAutoTelemetry, HybridAutoPlay, HybridVoice };
|
|
12
|
+
export { HybridAndroidAutoTelemetry, HybridAndroidWindowInformation, HybridAutoPlay, HybridVoice };
|
|
12
13
|
|
|
13
14
|
export const HybridAndroidAutomotive =
|
|
14
15
|
Platform.OS === 'android'
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { AppRegistry, Platform } from 'react-native';
|
|
3
3
|
import { NitroModules } from 'react-native-nitro-modules';
|
|
4
4
|
import { SafeAreaInsetsProvider } from '../components/SafeAreaInsetsContext';
|
|
5
|
+
import { WindowInformationWrapper } from '../components/WindowInformationWrapper';
|
|
5
6
|
import type { Cluster as NitroCluster, ZoomEvent } from '../specs/Cluster.nitro';
|
|
6
7
|
import type { ColorScheme, RootComponentInitialProps } from '../types/RootComponent';
|
|
7
8
|
import type { AutoAttributedString } from '../utils/NitroAttributedString';
|
|
@@ -62,7 +63,11 @@ class Cluster {
|
|
|
62
63
|
React.createElement(SafeAreaInsetsProvider, {
|
|
63
64
|
moduleName: clusterId,
|
|
64
65
|
// biome-ignore lint/correctness/noChildrenProp: there is no other way in a ts file
|
|
65
|
-
children: React.createElement(
|
|
66
|
+
children: React.createElement(WindowInformationWrapper, {
|
|
67
|
+
moduleName: clusterId,
|
|
68
|
+
component,
|
|
69
|
+
componentProps: props,
|
|
70
|
+
}),
|
|
66
71
|
})
|
|
67
72
|
);
|
|
68
73
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
+
import type { CleanupCallback } from '../types/Event';
|
|
3
|
+
import type { WindowInformation } from '../types/RootComponent';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Android-only access to render-surface window dimensions. On iOS this module does not exist —
|
|
7
|
+
* use the platform-split `HybridAndroidWindowInformation` wrapper which resolves to `null` there.
|
|
8
|
+
*/
|
|
9
|
+
export interface AndroidWindowInformation extends HybridObject<{ android: 'kotlin' }> {
|
|
10
|
+
/**
|
|
11
|
+
* callback for window dimension changes, fired when the host recreates the render surface
|
|
12
|
+
* with a different size (some head units run Android Auto windowed and resize it at runtime).
|
|
13
|
+
* Root components rendered via a template's `component` prop do NOT need this — their
|
|
14
|
+
* `window` prop is kept up to date automatically. Use this listener only for
|
|
15
|
+
* size-dependent logic living outside a root component.
|
|
16
|
+
* Fires with the last known window information immediately if the surface is already initialized.
|
|
17
|
+
* @param moduleName one of @AutoPlayModules or a cluster scene uuid
|
|
18
|
+
* @namespace Android
|
|
19
|
+
*/
|
|
20
|
+
addWindowInformationListener(
|
|
21
|
+
moduleName: string,
|
|
22
|
+
callback: (window: WindowInformation) => void
|
|
23
|
+
): CleanupCallback;
|
|
24
|
+
}
|
|
@@ -4,6 +4,7 @@ import { NitroModules } from 'react-native-nitro-modules';
|
|
|
4
4
|
import type { AutoText } from '..';
|
|
5
5
|
import { MapTemplateProvider } from '../components/MapTemplateContext';
|
|
6
6
|
import { SafeAreaInsetsProvider } from '../components/SafeAreaInsetsContext';
|
|
7
|
+
import { WindowInformationWrapper } from '../components/WindowInformationWrapper';
|
|
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';
|
|
@@ -196,7 +197,11 @@ export class MapTemplate extends Template<MapTemplateConfig, MapTemplateConfig['
|
|
|
196
197
|
children: React.createElement(SafeAreaInsetsProvider, {
|
|
197
198
|
moduleName: this.id,
|
|
198
199
|
// biome-ignore lint/correctness/noChildrenProp: there is no other way in a ts file
|
|
199
|
-
children: React.createElement(
|
|
200
|
+
children: React.createElement(WindowInformationWrapper, {
|
|
201
|
+
moduleName: this.id,
|
|
202
|
+
component,
|
|
203
|
+
componentProps: props,
|
|
204
|
+
}),
|
|
200
205
|
}),
|
|
201
206
|
})
|
|
202
207
|
);
|
|
@@ -21,6 +21,10 @@ export type RootComponentInitialProps = {
|
|
|
21
21
|
* this is the initial color scheme, add onAppearanceDidChange on MapTemplate to get updates
|
|
22
22
|
*/
|
|
23
23
|
colorScheme: ColorScheme;
|
|
24
|
+
/**
|
|
25
|
+
* the dimensions of the render surface, kept up to date when the host resizes the surface
|
|
26
|
+
* (e.g. head units running Android Auto windowed)
|
|
27
|
+
*/
|
|
24
28
|
window: WindowInformation;
|
|
25
29
|
};
|
|
26
30
|
|