@iternio/react-native-auto-play 0.5.14-beta.1 → 0.6.1
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 +270 -36
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/AndroidAutoSession.kt +5 -0
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridMapTemplate.kt +9 -2
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/NativeBackdrop.kt +40 -0
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/VirtualRenderer.kt +52 -0
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/template/GridTemplate.kt +47 -13
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/template/Parser.kt +69 -15
- package/ios/Types.swift +3 -0
- package/ios/extensions/UIImage+Toggle.swift +5 -2
- package/ios/hybrid/HybridAutoPlay.swift +28 -16
- package/ios/hybrid/HybridMapTemplate.swift +22 -5
- package/ios/scenes/AutoPlayInterfaceController.swift +261 -72
- package/ios/templates/AutoPlayMapPanelDelegate.swift +190 -0
- package/ios/templates/AutoPlayTemplate.swift +24 -2
- package/ios/templates/GridTemplate.swift +57 -57
- package/ios/templates/InformationTemplate.swift +84 -9
- package/ios/templates/ListTemplate.swift +66 -11
- package/ios/templates/MapTemplate.swift +83 -68
- package/ios/templates/MessageTemplate.swift +72 -6
- package/ios/templates/Parser.swift +564 -69
- package/ios/templates/SearchTemplate.swift +1 -1
- package/ios/templates/TemplateStore.swift +5 -15
- package/ios/utils/SymbolFont.swift +13 -28
- package/jest.js +2 -0
- package/lib/Constants.d.ts +4 -0
- package/lib/Constants.js +6 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.web.d.ts +73 -0
- package/lib/index.web.js +72 -1
- package/lib/specs/MapTemplate.nitro.d.ts +3 -1
- package/lib/templates/GridTemplate.d.ts +23 -3
- package/lib/templates/GridTemplate.js +8 -0
- package/lib/templates/InformationTemplate.d.ts +38 -12
- package/lib/templates/ListTemplate.d.ts +16 -47
- package/lib/templates/MapTemplate.d.ts +26 -2
- package/lib/templates/MapTemplate.js +16 -2
- package/lib/templates/MessageTemplate.d.ts +52 -11
- package/lib/templates/MessageTemplate.js +1 -1
- package/lib/types/Image.d.ts +6 -1
- package/lib/utils/NitroColor.d.ts +1 -0
- package/lib/utils/NitroColor.js +8 -0
- package/lib/utils/NitroImage.js +1 -1
- package/lib/utils/NitroManeuver.js +1 -3
- package/lib/utils/NitroOptionsPanel.d.ts +103 -0
- package/lib/utils/NitroOptionsPanel.js +63 -0
- package/lib/utils/NitroSection.d.ts +89 -2
- package/lib/utils/NitroSection.js +49 -2
- package/lib-cjs/AutoPlayHeadlessJsTask.js +16 -0
- package/lib-cjs/Constants.js +9 -0
- package/lib-cjs/components/MapTemplateContext.js +10 -0
- package/lib-cjs/components/SafeAreaInsetsContext.js +21 -0
- package/lib-cjs/components/SafeAreaView.js +22 -0
- package/lib-cjs/components/WindowInformationWrapper.js +20 -0
- package/lib-cjs/hooks/useAndroidAutoTelemetry.js +115 -0
- package/lib-cjs/hooks/useFocusedEffect.js +35 -0
- package/lib-cjs/hooks/useMapTemplate.js +13 -0
- package/lib-cjs/hooks/useSafeAreaInsets.js +9 -0
- package/lib-cjs/hooks/useVoiceInput.js +42 -0
- package/lib-cjs/hybrid/HybridAndroidAutoTelemetry.js +4 -0
- package/lib-cjs/hybrid/HybridAndroidWindowInformation.js +4 -0
- package/lib-cjs/hybrid/HybridAutoPlay.js +5 -0
- package/lib-cjs/hybrid/HybridVoice.js +61 -0
- package/lib-cjs/index.js +76 -0
- package/lib-cjs/index.web.js +98 -0
- package/lib-cjs/scenes/AutoPlayCluster.js +140 -0
- package/lib-cjs/scenes/CarPlayDashboardScene.js +100 -0
- package/lib-cjs/specs/AndroidAutoTelemetry.nitro.js +2 -0
- package/lib-cjs/specs/AndroidAutomotive.nitro.js +16 -0
- package/lib-cjs/specs/AndroidWindowInformation.nitro.js +2 -0
- package/lib-cjs/specs/AutoPlay.nitro.js +2 -0
- package/lib-cjs/specs/CarPlayDashboard.nitro.js +2 -0
- package/lib-cjs/specs/Cluster.nitro.js +2 -0
- package/lib-cjs/specs/GridTemplate.nitro.js +2 -0
- package/lib-cjs/specs/InformationTemplate.nitro.js +2 -0
- package/lib-cjs/specs/ListTemplate.nitro.js +2 -0
- package/lib-cjs/specs/MapTemplate.nitro.js +2 -0
- package/lib-cjs/specs/MessageTemplate.nitro.js +2 -0
- package/lib-cjs/specs/SearchTemplate.nitro.js +2 -0
- package/lib-cjs/specs/SignInTemplate.nitro.js +2 -0
- package/lib-cjs/specs/Voice.nitro.js +2 -0
- package/lib-cjs/templates/GridTemplate.js +41 -0
- package/lib-cjs/templates/InformationTemplate.js +49 -0
- package/lib-cjs/templates/ListTemplate.js +33 -0
- package/lib-cjs/templates/MapTemplate.js +168 -0
- package/lib-cjs/templates/MessageTemplate.js +50 -0
- package/lib-cjs/templates/SearchTemplate.js +32 -0
- package/lib-cjs/templates/SignInTemplate.js +55 -0
- package/lib-cjs/templates/Template.js +40 -0
- package/lib-cjs/types/Button.js +12 -0
- package/lib-cjs/types/Event.js +2 -0
- package/lib-cjs/types/Image.js +2 -0
- package/lib-cjs/types/Maneuver.js +77 -0
- package/lib-cjs/types/RootComponent.js +2 -0
- package/lib-cjs/types/SignInMethod.js +22 -0
- package/lib-cjs/types/Telemetry.js +24 -0
- package/lib-cjs/types/Text.js +8 -0
- package/lib-cjs/types/Trip.js +2 -0
- package/lib-cjs/types/Voice.js +2 -0
- package/lib-cjs/utils/ErrorUtil.js +34 -0
- package/lib-cjs/utils/NitroAction.js +129 -0
- package/lib-cjs/utils/NitroAlert.js +19 -0
- package/lib-cjs/utils/NitroAttributedString.js +14 -0
- package/lib-cjs/utils/NitroColor.js +32 -0
- package/lib-cjs/utils/NitroGrid.js +12 -0
- package/lib-cjs/utils/NitroImage.js +97 -0
- package/lib-cjs/utils/NitroManeuver.js +79 -0
- package/lib-cjs/utils/NitroMapButton.js +33 -0
- package/lib-cjs/utils/NitroOptionsPanel.js +66 -0
- package/lib-cjs/utils/NitroSection.js +112 -0
- package/nitrogen/generated/android/ReactNativeAutoPlay+autolinking.cmake +1 -0
- package/nitrogen/generated/android/c++/JChargingConnector.hpp +79 -0
- package/nitrogen/generated/android/c++/JGridImageSize.hpp +64 -0
- package/nitrogen/generated/android/c++/JGridTemplateConfig.hpp +7 -1
- package/nitrogen/generated/android/c++/JHybridGridTemplateSpec.cpp +4 -0
- package/nitrogen/generated/android/c++/JHybridInformationTemplateSpec.cpp +12 -0
- package/nitrogen/generated/android/c++/JHybridListTemplateSpec.cpp +12 -0
- package/nitrogen/generated/android/c++/JHybridMapTemplateSpec.cpp +78 -3
- package/nitrogen/generated/android/c++/JHybridMapTemplateSpec.hpp +2 -1
- package/nitrogen/generated/android/c++/JHybridSearchTemplateSpec.cpp +12 -0
- package/nitrogen/generated/android/c++/JInformationTemplateConfig.hpp +6 -0
- package/nitrogen/generated/android/c++/JListImageType.hpp +67 -0
- package/nitrogen/generated/android/c++/JListTemplateConfig.hpp +6 -0
- package/nitrogen/generated/android/c++/JNitroChargerLocation.hpp +115 -0
- package/nitrogen/generated/android/c++/JNitroChargerOutlet.hpp +82 -0
- package/nitrogen/generated/android/c++/JNitroColor.hpp +8 -4
- package/nitrogen/generated/android/c++/JNitroOptionsPanelChargerSection.hpp +112 -0
- package/nitrogen/generated/android/c++/JNitroOptionsPanelConfig.hpp +157 -0
- package/nitrogen/generated/android/c++/JNitroOptionsPanelGridSection.hpp +102 -0
- package/nitrogen/generated/android/c++/JNitroOptionsPanelSection.cpp +30 -0
- package/nitrogen/generated/android/c++/JNitroOptionsPanelSection.hpp +129 -0
- package/nitrogen/generated/android/c++/JNitroRow.hpp +33 -3
- package/nitrogen/generated/android/c++/JNitroSection.hpp +6 -0
- package/nitrogen/generated/android/c++/JSearchTemplateConfig.hpp +6 -0
- package/nitrogen/generated/android/c++/JWaypointCoordinate.hpp +65 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/ChargingConnector.kt +30 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/GridImageSize.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/GridTemplateConfig.kt +9 -4
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridMapTemplateSpec.kt +5 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/ListImageType.kt +26 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroChargerLocation.kt +90 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroChargerOutlet.kt +70 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroColor.kt +9 -4
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroOptionsPanelChargerSection.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroOptionsPanelConfig.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroOptionsPanelGridSection.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroOptionsPanelSection.kt +75 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroRow.kt +36 -6
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/WaypointCoordinate.kt +61 -0
- package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Bridge.hpp +174 -0
- package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Umbrella.hpp +27 -0
- package/nitrogen/generated/ios/c++/HybridGridTemplateSpecSwift.hpp +3 -0
- package/nitrogen/generated/ios/c++/HybridInformationTemplateSpecSwift.hpp +9 -0
- package/nitrogen/generated/ios/c++/HybridListTemplateSpecSwift.hpp +9 -0
- package/nitrogen/generated/ios/c++/HybridMapTemplateSpecSwift.hpp +47 -1
- package/nitrogen/generated/ios/c++/HybridSearchTemplateSpecSwift.hpp +9 -0
- package/nitrogen/generated/ios/swift/ChargingConnector.swift +68 -0
- package/nitrogen/generated/ios/swift/GridImageSize.swift +48 -0
- package/nitrogen/generated/ios/swift/GridTemplateConfig.swift +12 -1
- package/nitrogen/generated/ios/swift/HybridMapTemplateSpec.swift +2 -1
- package/nitrogen/generated/ios/swift/HybridMapTemplateSpec_cxx.swift +31 -4
- package/nitrogen/generated/ios/swift/ListImageType.swift +52 -0
- package/nitrogen/generated/ios/swift/NitroChargerLocation.swift +161 -0
- package/nitrogen/generated/ios/swift/NitroChargerOutlet.swift +65 -0
- package/nitrogen/generated/ios/swift/NitroColor.swift +20 -2
- package/nitrogen/generated/ios/swift/NitroOptionsPanelChargerSection.swift +64 -0
- package/nitrogen/generated/ios/swift/NitroOptionsPanelConfig.swift +94 -0
- package/nitrogen/generated/ios/swift/NitroOptionsPanelGridSection.swift +53 -0
- package/nitrogen/generated/ios/swift/NitroOptionsPanelSection.swift +32 -0
- package/nitrogen/generated/ios/swift/NitroRow.swift +81 -1
- package/nitrogen/generated/ios/swift/WaypointCoordinate.swift +52 -0
- package/nitrogen/generated/shared/c++/ChargingConnector.hpp +104 -0
- package/nitrogen/generated/shared/c++/GridImageSize.hpp +84 -0
- package/nitrogen/generated/shared/c++/GridTemplateConfig.hpp +8 -1
- package/nitrogen/generated/shared/c++/HybridMapTemplateSpec.cpp +1 -0
- package/nitrogen/generated/shared/c++/HybridMapTemplateSpec.hpp +5 -1
- package/nitrogen/generated/shared/c++/ListImageType.hpp +88 -0
- package/nitrogen/generated/shared/c++/NitroChargerLocation.hpp +131 -0
- package/nitrogen/generated/shared/c++/NitroChargerOutlet.hpp +98 -0
- package/nitrogen/generated/shared/c++/NitroColor.hpp +7 -3
- package/nitrogen/generated/shared/c++/NitroOptionsPanelChargerSection.hpp +98 -0
- package/nitrogen/generated/shared/c++/NitroOptionsPanelConfig.hpp +107 -0
- package/nitrogen/generated/shared/c++/NitroOptionsPanelGridSection.hpp +91 -0
- package/nitrogen/generated/shared/c++/NitroRow.hpp +39 -2
- package/nitrogen/generated/shared/c++/WaypointCoordinate.hpp +91 -0
- package/package.json +7 -3
- package/src/Constants.ts +9 -0
- package/src/index.ts +1 -0
- package/src/index.web.ts +166 -0
- package/src/specs/MapTemplate.nitro.ts +3 -1
- package/src/templates/GridTemplate.ts +38 -3
- package/src/templates/InformationTemplate.ts +60 -29
- package/src/templates/ListTemplate.ts +27 -55
- package/src/templates/MapTemplate.ts +60 -2
- package/src/templates/MessageTemplate.ts +71 -24
- package/src/types/Image.ts +6 -1
- package/src/utils/NitroColor.ts +10 -1
- package/src/utils/NitroImage.ts +1 -5
- package/src/utils/NitroManeuver.ts +1 -4
- package/src/utils/NitroOptionsPanel.ts +218 -0
- package/src/utils/NitroSection.ts +160 -5
|
@@ -36,6 +36,14 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct GlyphImage;
|
|
|
36
36
|
namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct AssetImage; }
|
|
37
37
|
// Forward declaration of `RemoteImage` to properly resolve imports.
|
|
38
38
|
namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct RemoteImage; }
|
|
39
|
+
// Forward declaration of `ListImageType` to properly resolve imports.
|
|
40
|
+
namespace margelo::nitro::swe::iternio::reactnativeautoplay { enum class ListImageType; }
|
|
41
|
+
// Forward declaration of `WaypointCoordinate` to properly resolve imports.
|
|
42
|
+
namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct WaypointCoordinate; }
|
|
43
|
+
// Forward declaration of `Distance` to properly resolve imports.
|
|
44
|
+
namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct Distance; }
|
|
45
|
+
// Forward declaration of `DurationWithTimeZone` to properly resolve imports.
|
|
46
|
+
namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct DurationWithTimeZone; }
|
|
39
47
|
|
|
40
48
|
#include "AutoText.hpp"
|
|
41
49
|
#include <optional>
|
|
@@ -43,7 +51,12 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct RemoteImage
|
|
|
43
51
|
#include "AssetImage.hpp"
|
|
44
52
|
#include "RemoteImage.hpp"
|
|
45
53
|
#include <variant>
|
|
54
|
+
#include "ListImageType.hpp"
|
|
46
55
|
#include <functional>
|
|
56
|
+
#include "WaypointCoordinate.hpp"
|
|
57
|
+
#include "Distance.hpp"
|
|
58
|
+
#include "DurationWithTimeZone.hpp"
|
|
59
|
+
#include <string>
|
|
47
60
|
|
|
48
61
|
namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
49
62
|
|
|
@@ -57,13 +70,19 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
|
57
70
|
std::optional<bool> browsable SWIFT_PRIVATE;
|
|
58
71
|
bool enabled SWIFT_PRIVATE;
|
|
59
72
|
std::optional<std::variant<GlyphImage, AssetImage, RemoteImage>> image SWIFT_PRIVATE;
|
|
73
|
+
std::optional<ListImageType> imageType SWIFT_PRIVATE;
|
|
60
74
|
std::optional<bool> checked SWIFT_PRIVATE;
|
|
61
75
|
std::optional<std::function<void(std::optional<bool> /* checked */)>> onPress SWIFT_PRIVATE;
|
|
62
76
|
std::optional<bool> selected SWIFT_PRIVATE;
|
|
77
|
+
std::optional<WaypointCoordinate> coordinate SWIFT_PRIVATE;
|
|
78
|
+
std::optional<Distance> distance SWIFT_PRIVATE;
|
|
79
|
+
std::optional<DurationWithTimeZone> duration SWIFT_PRIVATE;
|
|
80
|
+
std::optional<bool> travelEstimatesVisible SWIFT_PRIVATE;
|
|
81
|
+
std::optional<std::string> address SWIFT_PRIVATE;
|
|
63
82
|
|
|
64
83
|
public:
|
|
65
84
|
NitroRow() = default;
|
|
66
|
-
explicit NitroRow(AutoText title, std::optional<AutoText> detailedText, std::optional<bool> browsable, bool enabled, std::optional<std::variant<GlyphImage, AssetImage, RemoteImage>> image, std::optional<bool> checked, std::optional<std::function<void(std::optional<bool> /* checked */)>> onPress, std::optional<bool> selected): title(title), detailedText(detailedText), browsable(browsable), enabled(enabled), image(image), checked(checked), onPress(onPress), selected(selected) {}
|
|
85
|
+
explicit NitroRow(AutoText title, std::optional<AutoText> detailedText, std::optional<bool> browsable, bool enabled, std::optional<std::variant<GlyphImage, AssetImage, RemoteImage>> image, std::optional<ListImageType> imageType, std::optional<bool> checked, std::optional<std::function<void(std::optional<bool> /* checked */)>> onPress, std::optional<bool> selected, std::optional<WaypointCoordinate> coordinate, std::optional<Distance> distance, std::optional<DurationWithTimeZone> duration, std::optional<bool> travelEstimatesVisible, std::optional<std::string> address): title(title), detailedText(detailedText), browsable(browsable), enabled(enabled), image(image), imageType(imageType), checked(checked), onPress(onPress), selected(selected), coordinate(coordinate), distance(distance), duration(duration), travelEstimatesVisible(travelEstimatesVisible), address(address) {}
|
|
67
86
|
|
|
68
87
|
public:
|
|
69
88
|
// NitroRow is not equatable because these properties are not equatable: onPress
|
|
@@ -84,9 +103,15 @@ namespace margelo::nitro {
|
|
|
84
103
|
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "browsable"))),
|
|
85
104
|
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "enabled"))),
|
|
86
105
|
JSIConverter<std::optional<std::variant<margelo::nitro::swe::iternio::reactnativeautoplay::GlyphImage, margelo::nitro::swe::iternio::reactnativeautoplay::AssetImage, margelo::nitro::swe::iternio::reactnativeautoplay::RemoteImage>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "image"))),
|
|
106
|
+
JSIConverter<std::optional<margelo::nitro::swe::iternio::reactnativeautoplay::ListImageType>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "imageType"))),
|
|
87
107
|
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "checked"))),
|
|
88
108
|
JSIConverter<std::optional<std::function<void(std::optional<bool>)>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onPress"))),
|
|
89
|
-
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "selected")))
|
|
109
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "selected"))),
|
|
110
|
+
JSIConverter<std::optional<margelo::nitro::swe::iternio::reactnativeautoplay::WaypointCoordinate>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "coordinate"))),
|
|
111
|
+
JSIConverter<std::optional<margelo::nitro::swe::iternio::reactnativeautoplay::Distance>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "distance"))),
|
|
112
|
+
JSIConverter<std::optional<margelo::nitro::swe::iternio::reactnativeautoplay::DurationWithTimeZone>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "duration"))),
|
|
113
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "travelEstimatesVisible"))),
|
|
114
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "address")))
|
|
90
115
|
);
|
|
91
116
|
}
|
|
92
117
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::swe::iternio::reactnativeautoplay::NitroRow& arg) {
|
|
@@ -96,9 +121,15 @@ namespace margelo::nitro {
|
|
|
96
121
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "browsable"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.browsable));
|
|
97
122
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "enabled"), JSIConverter<bool>::toJSI(runtime, arg.enabled));
|
|
98
123
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "image"), JSIConverter<std::optional<std::variant<margelo::nitro::swe::iternio::reactnativeautoplay::GlyphImage, margelo::nitro::swe::iternio::reactnativeautoplay::AssetImage, margelo::nitro::swe::iternio::reactnativeautoplay::RemoteImage>>>::toJSI(runtime, arg.image));
|
|
124
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "imageType"), JSIConverter<std::optional<margelo::nitro::swe::iternio::reactnativeautoplay::ListImageType>>::toJSI(runtime, arg.imageType));
|
|
99
125
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "checked"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.checked));
|
|
100
126
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "onPress"), JSIConverter<std::optional<std::function<void(std::optional<bool>)>>>::toJSI(runtime, arg.onPress));
|
|
101
127
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "selected"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.selected));
|
|
128
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "coordinate"), JSIConverter<std::optional<margelo::nitro::swe::iternio::reactnativeautoplay::WaypointCoordinate>>::toJSI(runtime, arg.coordinate));
|
|
129
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "distance"), JSIConverter<std::optional<margelo::nitro::swe::iternio::reactnativeautoplay::Distance>>::toJSI(runtime, arg.distance));
|
|
130
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "duration"), JSIConverter<std::optional<margelo::nitro::swe::iternio::reactnativeautoplay::DurationWithTimeZone>>::toJSI(runtime, arg.duration));
|
|
131
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "travelEstimatesVisible"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.travelEstimatesVisible));
|
|
132
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "address"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.address));
|
|
102
133
|
return obj;
|
|
103
134
|
}
|
|
104
135
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -114,9 +145,15 @@ namespace margelo::nitro {
|
|
|
114
145
|
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "browsable")))) return false;
|
|
115
146
|
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "enabled")))) return false;
|
|
116
147
|
if (!JSIConverter<std::optional<std::variant<margelo::nitro::swe::iternio::reactnativeautoplay::GlyphImage, margelo::nitro::swe::iternio::reactnativeautoplay::AssetImage, margelo::nitro::swe::iternio::reactnativeautoplay::RemoteImage>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "image")))) return false;
|
|
148
|
+
if (!JSIConverter<std::optional<margelo::nitro::swe::iternio::reactnativeautoplay::ListImageType>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "imageType")))) return false;
|
|
117
149
|
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "checked")))) return false;
|
|
118
150
|
if (!JSIConverter<std::optional<std::function<void(std::optional<bool>)>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onPress")))) return false;
|
|
119
151
|
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "selected")))) return false;
|
|
152
|
+
if (!JSIConverter<std::optional<margelo::nitro::swe::iternio::reactnativeautoplay::WaypointCoordinate>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "coordinate")))) return false;
|
|
153
|
+
if (!JSIConverter<std::optional<margelo::nitro::swe::iternio::reactnativeautoplay::Distance>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "distance")))) return false;
|
|
154
|
+
if (!JSIConverter<std::optional<margelo::nitro::swe::iternio::reactnativeautoplay::DurationWithTimeZone>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "duration")))) return false;
|
|
155
|
+
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "travelEstimatesVisible")))) return false;
|
|
156
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "address")))) return false;
|
|
120
157
|
return true;
|
|
121
158
|
}
|
|
122
159
|
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// WaypointCoordinate.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
|
+
#include <optional>
|
|
34
|
+
|
|
35
|
+
namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A struct which can be represented as a JavaScript object (WaypointCoordinate).
|
|
39
|
+
*/
|
|
40
|
+
struct WaypointCoordinate final {
|
|
41
|
+
public:
|
|
42
|
+
double latitude SWIFT_PRIVATE;
|
|
43
|
+
double longitude SWIFT_PRIVATE;
|
|
44
|
+
std::optional<double> altitude SWIFT_PRIVATE;
|
|
45
|
+
|
|
46
|
+
public:
|
|
47
|
+
WaypointCoordinate() = default;
|
|
48
|
+
explicit WaypointCoordinate(double latitude, double longitude, std::optional<double> altitude): latitude(latitude), longitude(longitude), altitude(altitude) {}
|
|
49
|
+
|
|
50
|
+
public:
|
|
51
|
+
friend bool operator==(const WaypointCoordinate& lhs, const WaypointCoordinate& rhs) = default;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
} // namespace margelo::nitro::swe::iternio::reactnativeautoplay
|
|
55
|
+
|
|
56
|
+
namespace margelo::nitro {
|
|
57
|
+
|
|
58
|
+
// C++ WaypointCoordinate <> JS WaypointCoordinate (object)
|
|
59
|
+
template <>
|
|
60
|
+
struct JSIConverter<margelo::nitro::swe::iternio::reactnativeautoplay::WaypointCoordinate> final {
|
|
61
|
+
static inline margelo::nitro::swe::iternio::reactnativeautoplay::WaypointCoordinate fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
62
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
63
|
+
return margelo::nitro::swe::iternio::reactnativeautoplay::WaypointCoordinate(
|
|
64
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "latitude"))),
|
|
65
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "longitude"))),
|
|
66
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "altitude")))
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::swe::iternio::reactnativeautoplay::WaypointCoordinate& arg) {
|
|
70
|
+
jsi::Object obj(runtime);
|
|
71
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "latitude"), JSIConverter<double>::toJSI(runtime, arg.latitude));
|
|
72
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "longitude"), JSIConverter<double>::toJSI(runtime, arg.longitude));
|
|
73
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "altitude"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.altitude));
|
|
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, "latitude")))) return false;
|
|
85
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "longitude")))) return false;
|
|
86
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "altitude")))) return false;
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
} // namespace margelo::nitro
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iternio/react-native-auto-play",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Android Auto and Apple CarPlay for react-native",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"module": "lib/index",
|
|
7
|
+
"browser": "lib/index.web",
|
|
7
8
|
"types": "lib/index.d.ts",
|
|
8
9
|
"react-native": "src/index",
|
|
9
10
|
"source": "src/index",
|
|
@@ -11,6 +12,8 @@
|
|
|
11
12
|
"src",
|
|
12
13
|
"react-native.config.js",
|
|
13
14
|
"lib",
|
|
15
|
+
"lib-cjs",
|
|
16
|
+
"jest.js",
|
|
14
17
|
"nitrogen",
|
|
15
18
|
"android/build.gradle",
|
|
16
19
|
"android/gradle.properties",
|
|
@@ -30,12 +33,13 @@
|
|
|
30
33
|
],
|
|
31
34
|
"scripts": {
|
|
32
35
|
"typecheck": "tsc --noEmit",
|
|
33
|
-
"clean": "rm -rf android/build node_modules/**/android/build lib",
|
|
36
|
+
"clean": "rm -rf android/build node_modules/**/android/build lib lib-cjs",
|
|
34
37
|
"lint": "biome check src",
|
|
35
38
|
"lint-ci": "biome ci src --reporter=summary",
|
|
36
39
|
"typescript": "tsc",
|
|
40
|
+
"build:jest": "tsc -p tsconfig.jest.json",
|
|
37
41
|
"specs": "nitrogen --logLevel=\"debug\"",
|
|
38
|
-
"prepare": "yarn circular && tsc && nitrogen",
|
|
42
|
+
"prepare": "yarn circular && tsc && yarn build:jest && nitrogen",
|
|
39
43
|
"swift:format": "swift-format format ./ios --in-place --recursive",
|
|
40
44
|
"circular": "dpdm ./src/* --circular --exit-code circular:1 --no-tree --warning=false --transform"
|
|
41
45
|
},
|
package/src/Constants.ts
ADDED
package/src/index.ts
CHANGED
package/src/index.web.ts
CHANGED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// Web/Jest stub for the native CarPlay/Android Auto surface. Nothing here talks to a real native
|
|
2
|
+
// module — every function call resolves to `undefined` (or an already-resolved promise, which is
|
|
3
|
+
// indistinguishable from `undefined` to an `await`er) rather than throwing. Types are preserved by
|
|
4
|
+
// casting against the real exports, so callers still get full type-checking/autocomplete.
|
|
5
|
+
//
|
|
6
|
+
// Anything below that's already safe as-is (pure types, plain enums, or modules that neither
|
|
7
|
+
// create native objects nor import anything that does) is re-exported directly instead of stubbed.
|
|
8
|
+
|
|
9
|
+
import { createElement } from 'react';
|
|
10
|
+
import { View, type ViewProps } from 'react-native';
|
|
11
|
+
import type { AndroidAutomotive } from './specs/AndroidAutomotive.nitro';
|
|
12
|
+
import type { AutoPlay } from './specs/AutoPlay.nitro';
|
|
13
|
+
import type { Voice } from './specs/Voice.nitro';
|
|
14
|
+
import type { GridTemplate as RealGridTemplate } from './templates/GridTemplate';
|
|
15
|
+
import type { InformationTemplate as RealInformationTemplate } from './templates/InformationTemplate';
|
|
16
|
+
import type { ListTemplate as RealListTemplate } from './templates/ListTemplate';
|
|
17
|
+
import type { MapTemplate as RealMapTemplate } from './templates/MapTemplate';
|
|
18
|
+
import type { MessageTemplate as RealMessageTemplate } from './templates/MessageTemplate';
|
|
19
|
+
import type { SearchTemplate as RealSearchTemplate } from './templates/SearchTemplate';
|
|
20
|
+
import type { SignInTemplate as RealSignInTemplate } from './templates/SignInTemplate';
|
|
21
|
+
import type { Template as RealTemplate } from './templates/Template';
|
|
22
|
+
import type { SafeAreaInsets } from './types/Event';
|
|
23
|
+
import type { Telemetry } from './types/Telemetry';
|
|
24
|
+
|
|
25
|
+
function noop() {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Any property access returns a no-op function, so any method call is safe regardless of name. */
|
|
30
|
+
function createNoopObject<T>(): T {
|
|
31
|
+
return new Proxy(
|
|
32
|
+
{},
|
|
33
|
+
{
|
|
34
|
+
get: (_target, prop) => (prop === 'then' || prop === 'toJSON' ? undefined : noop),
|
|
35
|
+
}
|
|
36
|
+
) as T;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function createNoopClass<T>(): new (...args: never[]) => T {
|
|
40
|
+
function NoopInstance() {
|
|
41
|
+
return createNoopObject<T>();
|
|
42
|
+
}
|
|
43
|
+
return NoopInstance as unknown as new (
|
|
44
|
+
...args: never[]
|
|
45
|
+
) => T;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export * from './Constants';
|
|
49
|
+
export * from './hooks/useMapTemplate';
|
|
50
|
+
export type {
|
|
51
|
+
ActiveCarUxRestrictions,
|
|
52
|
+
AppFocusState,
|
|
53
|
+
} from './specs/AndroidAutomotive.nitro';
|
|
54
|
+
export { CarUxRestrictions } from './specs/AndroidAutomotive.nitro';
|
|
55
|
+
export type { GridImageSize, GridTemplateConfig } from './templates/GridTemplate';
|
|
56
|
+
export type { InformationItems, InformationTemplateConfig } from './templates/InformationTemplate';
|
|
57
|
+
export type {
|
|
58
|
+
DefaultRow,
|
|
59
|
+
ListImageType,
|
|
60
|
+
ListTemplateConfig,
|
|
61
|
+
MultiSection,
|
|
62
|
+
RadioRow,
|
|
63
|
+
Section,
|
|
64
|
+
SingleSection,
|
|
65
|
+
TextRow,
|
|
66
|
+
ToggleRow,
|
|
67
|
+
WaypointCoordinate,
|
|
68
|
+
WaypointRow,
|
|
69
|
+
} from './templates/ListTemplate';
|
|
70
|
+
export type {
|
|
71
|
+
BaseMapTemplateConfig,
|
|
72
|
+
ChargerLocation,
|
|
73
|
+
ChargerOutlet,
|
|
74
|
+
ChargingConnector,
|
|
75
|
+
HeaderActionsAndroidMap,
|
|
76
|
+
MapButtons,
|
|
77
|
+
MapHeaderActions,
|
|
78
|
+
MapTemplateConfig,
|
|
79
|
+
OptionsPanelChargerSection,
|
|
80
|
+
OptionsPanelConfig,
|
|
81
|
+
OptionsPanelGridSection,
|
|
82
|
+
OptionsPanelListSection,
|
|
83
|
+
OptionsPanelSection,
|
|
84
|
+
PanelActionsIos,
|
|
85
|
+
PanelHeaderActions,
|
|
86
|
+
Point,
|
|
87
|
+
TripSelectorCallback,
|
|
88
|
+
VisibleTravelEstimate,
|
|
89
|
+
} from './templates/MapTemplate';
|
|
90
|
+
export type { MessageTemplateConfig } from './templates/MessageTemplate';
|
|
91
|
+
export type { SearchSection, SearchTemplateConfig } from './templates/SearchTemplate';
|
|
92
|
+
export type { SignInTemplateConfig } from './templates/SignInTemplate';
|
|
93
|
+
export type {
|
|
94
|
+
ActionButton,
|
|
95
|
+
HeaderActions,
|
|
96
|
+
HeaderActionsAndroid,
|
|
97
|
+
HeaderActionsIos,
|
|
98
|
+
NitroBaseMapTemplateConfig,
|
|
99
|
+
NitroTemplateConfig,
|
|
100
|
+
TemplateConfig,
|
|
101
|
+
} from './templates/Template';
|
|
102
|
+
export * from './types/Button';
|
|
103
|
+
export * from './types/Event';
|
|
104
|
+
export * from './types/Image';
|
|
105
|
+
export * from './types/Maneuver';
|
|
106
|
+
export * from './types/RootComponent';
|
|
107
|
+
export * from './types/SignInMethod';
|
|
108
|
+
export * from './types/Telemetry';
|
|
109
|
+
export * from './types/Text';
|
|
110
|
+
export * from './types/Trip';
|
|
111
|
+
export type { VoiceInputChunk, VoiceInputOptions, VoiceInputResult } from './types/Voice';
|
|
112
|
+
export * from './utils/ErrorUtil';
|
|
113
|
+
export type {
|
|
114
|
+
AlertPriority,
|
|
115
|
+
NavigationAlert as Alert,
|
|
116
|
+
NavigationAlertAction as AlertAction,
|
|
117
|
+
} from './utils/NitroAlert';
|
|
118
|
+
export type { ThemedColor } from './utils/NitroColor';
|
|
119
|
+
export type { GridButton } from './utils/NitroGrid';
|
|
120
|
+
|
|
121
|
+
export enum AutoPlayModules {
|
|
122
|
+
App = 'main',
|
|
123
|
+
AutoPlayRoot = 'AutoPlayRoot',
|
|
124
|
+
CarPlayDashboard = 'CarPlayDashboard',
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const NO_INSETS: SafeAreaInsets = { top: 0, bottom: 0, left: 0, right: 0 };
|
|
128
|
+
export const useSafeAreaInsets = () => NO_INSETS;
|
|
129
|
+
export const SafeAreaView = (props: ViewProps) => createElement(View, props);
|
|
130
|
+
|
|
131
|
+
export function setIconFont(_name: string, _glyphMap?: Record<string, number>): void {}
|
|
132
|
+
|
|
133
|
+
export const useFocusedEffect = () => {};
|
|
134
|
+
|
|
135
|
+
export const useVoiceInput = () => ({
|
|
136
|
+
voiceInputResult: undefined,
|
|
137
|
+
resetVoiceInputResult: () => {},
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
export const useAndroidAutoTelemetry = (): {
|
|
141
|
+
permissionsGranted: boolean | null;
|
|
142
|
+
telemetry: Telemetry | undefined;
|
|
143
|
+
error: string | undefined;
|
|
144
|
+
} => ({
|
|
145
|
+
permissionsGranted: null,
|
|
146
|
+
telemetry: undefined,
|
|
147
|
+
error: undefined,
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
export const AutoPlayCluster = createNoopObject<Record<string, unknown>>();
|
|
151
|
+
export const CarPlayDashboard = createNoopObject<Record<string, unknown>>();
|
|
152
|
+
|
|
153
|
+
export const HybridAndroidAutomotive: AndroidAutomotive | null = null;
|
|
154
|
+
export { HybridAndroidAutoTelemetry } from './hybrid/HybridAndroidAutoTelemetry';
|
|
155
|
+
export { HybridAndroidWindowInformation } from './hybrid/HybridAndroidWindowInformation';
|
|
156
|
+
export const HybridAutoPlay = createNoopObject<AutoPlay>();
|
|
157
|
+
export const HybridVoice = createNoopObject<Voice>();
|
|
158
|
+
|
|
159
|
+
export const Template = createNoopClass<InstanceType<typeof RealTemplate>>();
|
|
160
|
+
export const ListTemplate = createNoopClass<RealListTemplate>();
|
|
161
|
+
export const GridTemplate = createNoopClass<RealGridTemplate>();
|
|
162
|
+
export const InformationTemplate = createNoopClass<RealInformationTemplate>();
|
|
163
|
+
export const MessageTemplate = createNoopClass<RealMessageTemplate>();
|
|
164
|
+
export const MapTemplate = createNoopClass<RealMapTemplate>();
|
|
165
|
+
export const SearchTemplate = createNoopClass<RealSearchTemplate>();
|
|
166
|
+
export const SignInTemplate = createNoopClass<RealSignInTemplate>();
|
|
@@ -15,6 +15,7 @@ import type {
|
|
|
15
15
|
import type { NitroNavigationAlert } from '../utils/NitroAlert';
|
|
16
16
|
import type { NitroManeuver } from '../utils/NitroManeuver';
|
|
17
17
|
import type { NitroMapButton } from '../utils/NitroMapButton';
|
|
18
|
+
import type { NitroOptionsPanelConfig } from '../utils/NitroOptionsPanel';
|
|
18
19
|
import type { NitroTemplateConfig } from './AutoPlay.nitro';
|
|
19
20
|
|
|
20
21
|
interface MapTemplateConfig extends NitroTemplateConfig, NitroMapTemplateConfig {}
|
|
@@ -47,7 +48,8 @@ export interface MapTemplate extends HybridObject<{ android: 'kotlin'; ios: 'swi
|
|
|
47
48
|
): void;
|
|
48
49
|
updateTravelEstimates(templateId: string, steps: Array<TripPoint>): void;
|
|
49
50
|
updateManeuvers(templateId: string, maneuvers: NitroManeuver): void;
|
|
50
|
-
startNavigation(templateId: string, trip: TripConfig): void
|
|
51
|
+
startNavigation(templateId: string, trip: TripConfig): Promise<void>;
|
|
51
52
|
stopNavigation(templateId: string): void;
|
|
52
53
|
setManeuverState(templateId: string, state: ManeuverState): void;
|
|
54
|
+
updateOptionsPanel(templateId: string, config?: NitroOptionsPanelConfig): Promise<void>;
|
|
53
55
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
1
2
|
import { NitroModules } from 'react-native-nitro-modules';
|
|
2
3
|
import type { GridTemplate as NitroGridTemplate } from '../specs/GridTemplate.nitro';
|
|
3
4
|
import type { AutoText } from '../types/Text';
|
|
4
5
|
import { type NitroAction, NitroActionUtil } from '../utils/NitroAction';
|
|
5
6
|
import { type GridButton, type NitroGridButton, NitroGridUtil } from '../utils/NitroGrid';
|
|
6
7
|
import { NitroMapButton } from '../utils/NitroMapButton';
|
|
7
|
-
import type { BaseMapTemplateConfig } from './MapTemplate';
|
|
8
|
+
import type { BaseMapTemplateConfig, PanelHeaderActions } from './MapTemplate';
|
|
8
9
|
import {
|
|
9
10
|
type HeaderActions,
|
|
10
11
|
type NitroBaseMapTemplateConfig,
|
|
@@ -15,10 +16,17 @@ import {
|
|
|
15
16
|
|
|
16
17
|
const HybridGridTemplate = NitroModules.createHybridObject<NitroGridTemplate>('GridTemplate');
|
|
17
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Controls the size of Android grid items. A selected size requires Android Car API 8.
|
|
21
|
+
* @namespace Android
|
|
22
|
+
*/
|
|
23
|
+
export type GridImageSize = 'unset' | 'large' | 'medium' | 'small';
|
|
24
|
+
|
|
18
25
|
export interface NitroGridTemplateConfig extends TemplateConfig {
|
|
19
26
|
headerActions?: Array<NitroAction>;
|
|
20
27
|
title: AutoText;
|
|
21
28
|
buttons: Array<NitroGridButton>;
|
|
29
|
+
imageSize?: GridImageSize;
|
|
22
30
|
mapConfig?: NitroBaseMapTemplateConfig;
|
|
23
31
|
}
|
|
24
32
|
|
|
@@ -34,10 +42,25 @@ export type GridTemplateConfig = Omit<
|
|
|
34
42
|
buttons: Array<GridButton<GridTemplate>>;
|
|
35
43
|
|
|
36
44
|
/**
|
|
37
|
-
*
|
|
45
|
+
* Controls the size of all images in the Android grid. Defaults to `unset`, which preserves
|
|
46
|
+
* the platform's standard grid layout. `large`, `medium`, and `small` require Android Car API
|
|
47
|
+
* 8. Ignored (with a `__DEV__` warning) when `mapConfig` is also set — `MapWithContentTemplate`
|
|
48
|
+
* does not support the sized grid content type.
|
|
38
49
|
* @namespace Android
|
|
39
50
|
*/
|
|
40
|
-
|
|
51
|
+
imageSize?: GridImageSize;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* If mapConfig is defined, it will use a MapWithContentTemplate with the current template. This results in a GridTemplate with a map in background. No actions need to be specified, can be empty object.
|
|
55
|
+
* @namespace Android - uses MapWithContentTemplate
|
|
56
|
+
* @namespace iOS - renders as a CPMapPanel on the current root map template (iOS 27+);
|
|
57
|
+
* `headerActions` here is Android-only — on iOS this template's own `headerActions` are
|
|
58
|
+
* applied to the root map template's nav bar instead, since CarPlay has no separate header
|
|
59
|
+
* for the map behind a panel.
|
|
60
|
+
*/
|
|
61
|
+
mapConfig?: Omit<BaseMapTemplateConfig<GridTemplate>, 'headerActions'> & {
|
|
62
|
+
headerActions?: PanelHeaderActions<GridTemplate>;
|
|
63
|
+
};
|
|
41
64
|
};
|
|
42
65
|
|
|
43
66
|
export class GridTemplate extends Template<GridTemplateConfig, HeaderActions<GridTemplate>> {
|
|
@@ -48,6 +71,18 @@ export class GridTemplate extends Template<GridTemplateConfig, HeaderActions<Gri
|
|
|
48
71
|
|
|
49
72
|
const { headerActions, buttons, mapConfig, ...rest } = config;
|
|
50
73
|
|
|
74
|
+
if (
|
|
75
|
+
__DEV__ &&
|
|
76
|
+
Platform.OS === 'android' &&
|
|
77
|
+
mapConfig != null &&
|
|
78
|
+
rest.imageSize != null &&
|
|
79
|
+
rest.imageSize !== 'unset'
|
|
80
|
+
) {
|
|
81
|
+
console.warn(
|
|
82
|
+
'GridTemplate: imageSize is ignored on Android when mapConfig is set — MapWithContentTemplate does not support the sized grid content type'
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
51
86
|
const nitroConfig: NitroGridTemplateConfig & NitroTemplateConfig = {
|
|
52
87
|
...rest,
|
|
53
88
|
id: this.id,
|
|
@@ -7,7 +7,7 @@ import { type NitroAction, NitroActionUtil } from '../utils/NitroAction';
|
|
|
7
7
|
import { NitroMapButton } from '../utils/NitroMapButton';
|
|
8
8
|
import { type NitroSection, NitroSectionUtil } from '../utils/NitroSection';
|
|
9
9
|
import type { SingleSection, TextRow } from './ListTemplate';
|
|
10
|
-
import type { BaseMapTemplateConfig } from './MapTemplate';
|
|
10
|
+
import type { BaseMapTemplateConfig, PanelActionsIos, PanelHeaderActions } from './MapTemplate';
|
|
11
11
|
import {
|
|
12
12
|
type HeaderActions,
|
|
13
13
|
type NitroBaseMapTemplateConfig,
|
|
@@ -16,6 +16,10 @@ import {
|
|
|
16
16
|
type TemplateConfig,
|
|
17
17
|
} from './Template';
|
|
18
18
|
|
|
19
|
+
type InformationActionsAndroid<T> =
|
|
20
|
+
| [CustomActionButtonAndroid<T>]
|
|
21
|
+
| [CustomActionButtonAndroid<T>, CustomActionButtonAndroid<T>];
|
|
22
|
+
|
|
19
23
|
const HybridInformationTemplate =
|
|
20
24
|
NitroModules.createHybridObject<NitroInformationTemplate>('InformationTemplate');
|
|
21
25
|
|
|
@@ -33,7 +37,7 @@ export type InformationItems =
|
|
|
33
37
|
| [TextRow, TextRow, TextRow]
|
|
34
38
|
| [TextRow, TextRow, TextRow, TextRow];
|
|
35
39
|
|
|
36
|
-
|
|
40
|
+
type InformationTemplateBaseConfig = Omit<
|
|
37
41
|
NitroInformationTemplateConfig,
|
|
38
42
|
'headerActions' | 'section' | 'mapConfig' | 'actions'
|
|
39
43
|
> & {
|
|
@@ -47,35 +51,62 @@ export type InformationTemplateConfig = Omit<
|
|
|
47
51
|
* @namespace iOS this is an InformationTemplate, ⚠️ the row image is NOT supported
|
|
48
52
|
*/
|
|
49
53
|
items?: InformationItems;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* If mapConfig is defined, it will use a MapWithContentTemplate with the current template. This results in a PaneTemplate with a map in background. No actions need to be specified, can be empty object.
|
|
53
|
-
* @namespace Android
|
|
54
|
-
*/
|
|
55
|
-
mapConfig?: BaseMapTemplateConfig<InformationTemplate>;
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* @namespace Android up to 2 buttons of type TextButton, TextAndImageButton or ImageButton
|
|
59
|
-
* @namespace iOS - up to 3 buttons of type TextButton
|
|
60
|
-
*/
|
|
61
|
-
actions?: {
|
|
62
|
-
android?:
|
|
63
|
-
| [CustomActionButtonAndroid<InformationTemplate>]
|
|
64
|
-
| [
|
|
65
|
-
CustomActionButtonAndroid<InformationTemplate>,
|
|
66
|
-
CustomActionButtonAndroid<InformationTemplate>,
|
|
67
|
-
];
|
|
68
|
-
ios?:
|
|
69
|
-
| [
|
|
70
|
-
TextButton<InformationTemplate>,
|
|
71
|
-
TextButton<InformationTemplate>,
|
|
72
|
-
TextButton<InformationTemplate>,
|
|
73
|
-
]
|
|
74
|
-
| [TextButton<InformationTemplate>, TextButton<InformationTemplate>]
|
|
75
|
-
| [TextButton<InformationTemplate>];
|
|
76
|
-
};
|
|
77
54
|
};
|
|
78
55
|
|
|
56
|
+
/**
|
|
57
|
+
* `actions`/`mapConfig` are a discriminated union — `mapConfig` restricts `actions.ios` to at
|
|
58
|
+
* most one `TextButton` plus one icon-only `ImageButton` (a `CPMapPanel` can't show more), vs. up
|
|
59
|
+
* to three `TextButton`s otherwise. If your `mapConfig` value comes from a variable/prop rather
|
|
60
|
+
* than an inline literal, TS can't narrow which branch applies — assign it to a local `const` and
|
|
61
|
+
* branch with `if (mapConfig) { ... } else { ... }` into two separate constructor calls instead
|
|
62
|
+
* of passing it straight through to one.
|
|
63
|
+
*/
|
|
64
|
+
export type InformationTemplateConfig = InformationTemplateBaseConfig &
|
|
65
|
+
(
|
|
66
|
+
| {
|
|
67
|
+
mapConfig?: undefined;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @namespace Android up to 2 buttons of type TextButton, TextAndImageButton or ImageButton
|
|
71
|
+
* @namespace iOS - up to 3 buttons of type TextButton
|
|
72
|
+
*/
|
|
73
|
+
actions?: {
|
|
74
|
+
android?: InformationActionsAndroid<InformationTemplate>;
|
|
75
|
+
ios?:
|
|
76
|
+
| [
|
|
77
|
+
TextButton<InformationTemplate>,
|
|
78
|
+
TextButton<InformationTemplate>,
|
|
79
|
+
TextButton<InformationTemplate>,
|
|
80
|
+
]
|
|
81
|
+
| [TextButton<InformationTemplate>, TextButton<InformationTemplate>]
|
|
82
|
+
| [TextButton<InformationTemplate>];
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
| {
|
|
86
|
+
/**
|
|
87
|
+
* If mapConfig is defined, it will use a MapWithContentTemplate with the current template. This results in a PaneTemplate with a map in background. No actions need to be specified, can be empty object.
|
|
88
|
+
* @namespace Android - uses MapWithContentTemplate
|
|
89
|
+
* @namespace iOS - renders as a CPMapPanel on the current root map template (iOS 27+);
|
|
90
|
+
* `headerActions` here is Android-only — on iOS this template's own `headerActions` are
|
|
91
|
+
* applied to the root map template's nav bar instead, since CarPlay has no separate
|
|
92
|
+
* header for the map behind a panel.
|
|
93
|
+
*/
|
|
94
|
+
mapConfig: Omit<BaseMapTemplateConfig<InformationTemplate>, 'headerActions'> & {
|
|
95
|
+
headerActions?: PanelHeaderActions<InformationTemplate>;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @namespace Android up to 2 buttons of type TextButton, TextAndImageButton or ImageButton
|
|
100
|
+
* @namespace iOS - the panel can only show one TextButton plus one optional icon-only
|
|
101
|
+
* ImageButton, see PanelActionsIos
|
|
102
|
+
*/
|
|
103
|
+
actions?: {
|
|
104
|
+
android?: InformationActionsAndroid<InformationTemplate>;
|
|
105
|
+
ios?: PanelActionsIos<InformationTemplate>;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
|
|
79
110
|
export class InformationTemplate extends Template<
|
|
80
111
|
InformationTemplateConfig,
|
|
81
112
|
HeaderActions<InformationTemplate>
|