@iternio/react-native-auto-play 0.3.9 → 0.3.11
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/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/AndroidAutoSession.kt +1 -0
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridMapTemplate.kt +6 -2
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/template/AndroidAutoTemplate.kt +2 -1
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/template/MapTemplate.kt +6 -0
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/utils/BitmapCache.kt +2 -2
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/utils/Debouncer.kt +2 -1
- package/ios/hybrid/HybridMapTemplate.swift +9 -5
- package/ios/templates/MapTemplate.swift +57 -0
- package/ios/templates/Parser.swift +18 -7
- package/lib/components/OnAppearedChildRenderer.d.ts +10 -0
- package/lib/components/OnAppearedChildRenderer.js +26 -0
- package/lib/specs/MapTemplate.nitro.d.ts +2 -0
- package/lib/templates/MapTemplate.d.ts +15 -2
- package/lib/templates/MapTemplate.js +25 -3
- package/lib/types/Maneuver.d.ts +18 -0
- package/lib/types/Maneuver.js +13 -0
- package/lib/utils/NitroManeuver.d.ts +2 -0
- package/lib/utils/NitroMapButton.js +1 -1
- package/nitrogen/generated/android/c++/JHybridMapTemplateSpec.cpp +8 -0
- package/nitrogen/generated/android/c++/JHybridMapTemplateSpec.hpp +1 -0
- package/nitrogen/generated/android/c++/JManeuverState.hpp +64 -0
- package/nitrogen/generated/android/c++/JMapTemplateConfig.hpp +5 -1
- package/nitrogen/generated/android/c++/JNitroLoadingManeuver.hpp +15 -4
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridMapTemplateSpec.kt +4 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/ManeuverState.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/MapTemplateConfig.kt +7 -4
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroLoadingManeuver.kt +9 -3
- package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Umbrella.hpp +3 -0
- package/nitrogen/generated/ios/c++/HybridMapTemplateSpecSwift.hpp +9 -0
- package/nitrogen/generated/ios/swift/HybridMapTemplateSpec.swift +1 -0
- package/nitrogen/generated/ios/swift/HybridMapTemplateSpec_cxx.swift +11 -0
- package/nitrogen/generated/ios/swift/ManeuverState.swift +48 -0
- package/nitrogen/generated/ios/swift/MapTemplateConfig.swift +12 -1
- package/nitrogen/generated/ios/swift/NitroLoadingManeuver.swift +25 -2
- package/nitrogen/generated/shared/c++/HybridMapTemplateSpec.cpp +1 -0
- package/nitrogen/generated/shared/c++/HybridMapTemplateSpec.hpp +4 -0
- package/nitrogen/generated/shared/c++/ManeuverState.hpp +64 -0
- package/nitrogen/generated/shared/c++/MapTemplateConfig.hpp +8 -1
- package/nitrogen/generated/shared/c++/NitroLoadingManeuver.hpp +15 -4
- package/package.json +1 -1
- package/src/components/OnAppearedChildRenderer.tsx +37 -0
- package/src/specs/MapTemplate.nitro.ts +2 -0
- package/src/templates/MapTemplate.ts +40 -4
- package/src/types/Maneuver.ts +19 -0
- package/src/utils/NitroManeuver.ts +2 -0
- package/src/utils/NitroMapButton.ts +1 -1
|
@@ -10,7 +10,10 @@
|
|
|
10
10
|
#include <fbjni/fbjni.h>
|
|
11
11
|
#include "NitroLoadingManeuver.hpp"
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
#include "JNitroColor.hpp"
|
|
14
|
+
#include "NitroColor.hpp"
|
|
15
|
+
#include <optional>
|
|
16
|
+
#include <string>
|
|
14
17
|
|
|
15
18
|
namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
16
19
|
|
|
@@ -33,8 +36,14 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
|
33
36
|
static const auto clazz = javaClassStatic();
|
|
34
37
|
static const auto fieldIsLoading = clazz->getField<jboolean>("isLoading");
|
|
35
38
|
jboolean isLoading = this->getFieldValue(fieldIsLoading);
|
|
39
|
+
static const auto fieldCardBackgroundColor = clazz->getField<JNitroColor>("cardBackgroundColor");
|
|
40
|
+
jni::local_ref<JNitroColor> cardBackgroundColor = this->getFieldValue(fieldCardBackgroundColor);
|
|
41
|
+
static const auto fieldText = clazz->getField<jni::JString>("text");
|
|
42
|
+
jni::local_ref<jni::JString> text = this->getFieldValue(fieldText);
|
|
36
43
|
return NitroLoadingManeuver(
|
|
37
|
-
static_cast<bool>(isLoading)
|
|
44
|
+
static_cast<bool>(isLoading),
|
|
45
|
+
cardBackgroundColor->toCpp(),
|
|
46
|
+
text != nullptr ? std::make_optional(text->toStdString()) : std::nullopt
|
|
38
47
|
);
|
|
39
48
|
}
|
|
40
49
|
|
|
@@ -44,12 +53,14 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
|
44
53
|
*/
|
|
45
54
|
[[maybe_unused]]
|
|
46
55
|
static jni::local_ref<JNitroLoadingManeuver::javaobject> fromCpp(const NitroLoadingManeuver& value) {
|
|
47
|
-
using JSignature = JNitroLoadingManeuver(jboolean);
|
|
56
|
+
using JSignature = JNitroLoadingManeuver(jboolean, jni::alias_ref<JNitroColor>, jni::alias_ref<jni::JString>);
|
|
48
57
|
static const auto clazz = javaClassStatic();
|
|
49
58
|
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
50
59
|
return create(
|
|
51
60
|
clazz,
|
|
52
|
-
value.isLoading
|
|
61
|
+
value.isLoading,
|
|
62
|
+
JNitroColor::fromCpp(value.cardBackgroundColor),
|
|
63
|
+
value.text.has_value() ? jni::make_jstring(value.text.value()) : nullptr
|
|
53
64
|
);
|
|
54
65
|
}
|
|
55
66
|
};
|
|
@@ -81,6 +81,10 @@ abstract class HybridMapTemplateSpec: HybridObject() {
|
|
|
81
81
|
@DoNotStrip
|
|
82
82
|
@Keep
|
|
83
83
|
abstract fun stopNavigation(templateId: String): Unit
|
|
84
|
+
|
|
85
|
+
@DoNotStrip
|
|
86
|
+
@Keep
|
|
87
|
+
abstract fun setManeuverState(templateId: String, state: ManeuverState): Unit
|
|
84
88
|
|
|
85
89
|
// Default implementation of `HybridObject.toString()`
|
|
86
90
|
override fun toString(): String {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ManeuverState.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
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Represents the JavaScript enum/union "ManeuverState".
|
|
15
|
+
*/
|
|
16
|
+
@DoNotStrip
|
|
17
|
+
@Keep
|
|
18
|
+
enum class ManeuverState(@DoNotStrip @Keep val value: Int) {
|
|
19
|
+
CONTINUE(0),
|
|
20
|
+
INITIAL(1),
|
|
21
|
+
PREPARE(2),
|
|
22
|
+
EXECUTE(3);
|
|
23
|
+
|
|
24
|
+
companion object
|
|
25
|
+
}
|
|
@@ -70,6 +70,9 @@ data class MapTemplateConfig(
|
|
|
70
70
|
val headerActions: Array<NitroAction>?,
|
|
71
71
|
@DoNotStrip
|
|
72
72
|
@Keep
|
|
73
|
+
val defaultGuidanceBackgroundColor: NitroColor?,
|
|
74
|
+
@DoNotStrip
|
|
75
|
+
@Keep
|
|
73
76
|
val panButtonScrollPercentage: Double?,
|
|
74
77
|
@DoNotStrip
|
|
75
78
|
@Keep
|
|
@@ -78,8 +81,8 @@ data class MapTemplateConfig(
|
|
|
78
81
|
/**
|
|
79
82
|
* Create a new instance of MapTemplateConfig from Kotlin
|
|
80
83
|
*/
|
|
81
|
-
constructor(id: String, onWillAppear: ((animated: Boolean?) -> Unit)?, onWillDisappear: ((animated: Boolean?) -> Unit)?, onDidAppear: ((animated: Boolean?) -> Unit)?, onDidDisappear: ((animated: Boolean?) -> Unit)?, onPopped: (() -> Unit)?, autoDismissMs: Double?, visibleTravelEstimate: VisibleTravelEstimate?, onDidPan: ((translation: Point, velocity: Point?) -> Unit)?, onDidUpdateZoomGestureWithCenter: ((center: Point, scale: Double) -> Unit)?, onClick: ((center: Point) -> Unit)?, onDoubleClick: ((center: Point) -> Unit)?, onAppearanceDidChange: ((colorScheme: ColorScheme) -> Unit)?, onStopNavigation: () -> Unit, onAutoDriveEnabled: (() -> Unit)?, mapButtons: Array<NitroMapButton>?, headerActions: Array<NitroAction>?, panButtonScrollPercentage: Double?, onDidChangePanningInterface: ((isPanningInterfaceVisible: Boolean) -> Unit)?):
|
|
82
|
-
this(id, onWillAppear?.let { Func_void_std__optional_bool__java(it) }, onWillDisappear?.let { Func_void_std__optional_bool__java(it) }, onDidAppear?.let { Func_void_std__optional_bool__java(it) }, onDidDisappear?.let { Func_void_std__optional_bool__java(it) }, onPopped?.let { Func_void_java(it) }, autoDismissMs, visibleTravelEstimate, onDidPan?.let { Func_void_Point_std__optional_Point__java(it) }, onDidUpdateZoomGestureWithCenter?.let { Func_void_Point_double_java(it) }, onClick?.let { Func_void_Point_java(it) }, onDoubleClick?.let { Func_void_Point_java(it) }, onAppearanceDidChange?.let { Func_void_ColorScheme_java(it) }, Func_void_java(onStopNavigation), onAutoDriveEnabled?.let { Func_void_java(it) }, mapButtons, headerActions, panButtonScrollPercentage, onDidChangePanningInterface?.let { Func_void_bool_java(it) })
|
|
84
|
+
constructor(id: String, onWillAppear: ((animated: Boolean?) -> Unit)?, onWillDisappear: ((animated: Boolean?) -> Unit)?, onDidAppear: ((animated: Boolean?) -> Unit)?, onDidDisappear: ((animated: Boolean?) -> Unit)?, onPopped: (() -> Unit)?, autoDismissMs: Double?, visibleTravelEstimate: VisibleTravelEstimate?, onDidPan: ((translation: Point, velocity: Point?) -> Unit)?, onDidUpdateZoomGestureWithCenter: ((center: Point, scale: Double) -> Unit)?, onClick: ((center: Point) -> Unit)?, onDoubleClick: ((center: Point) -> Unit)?, onAppearanceDidChange: ((colorScheme: ColorScheme) -> Unit)?, onStopNavigation: () -> Unit, onAutoDriveEnabled: (() -> Unit)?, mapButtons: Array<NitroMapButton>?, headerActions: Array<NitroAction>?, defaultGuidanceBackgroundColor: NitroColor?, panButtonScrollPercentage: Double?, onDidChangePanningInterface: ((isPanningInterfaceVisible: Boolean) -> Unit)?):
|
|
85
|
+
this(id, onWillAppear?.let { Func_void_std__optional_bool__java(it) }, onWillDisappear?.let { Func_void_std__optional_bool__java(it) }, onDidAppear?.let { Func_void_std__optional_bool__java(it) }, onDidDisappear?.let { Func_void_std__optional_bool__java(it) }, onPopped?.let { Func_void_java(it) }, autoDismissMs, visibleTravelEstimate, onDidPan?.let { Func_void_Point_std__optional_Point__java(it) }, onDidUpdateZoomGestureWithCenter?.let { Func_void_Point_double_java(it) }, onClick?.let { Func_void_Point_java(it) }, onDoubleClick?.let { Func_void_Point_java(it) }, onAppearanceDidChange?.let { Func_void_ColorScheme_java(it) }, Func_void_java(onStopNavigation), onAutoDriveEnabled?.let { Func_void_java(it) }, mapButtons, headerActions, defaultGuidanceBackgroundColor, panButtonScrollPercentage, onDidChangePanningInterface?.let { Func_void_bool_java(it) })
|
|
83
86
|
|
|
84
87
|
companion object {
|
|
85
88
|
/**
|
|
@@ -89,8 +92,8 @@ data class MapTemplateConfig(
|
|
|
89
92
|
@Keep
|
|
90
93
|
@Suppress("unused")
|
|
91
94
|
@JvmStatic
|
|
92
|
-
private fun fromCpp(id: String, onWillAppear: Func_void_std__optional_bool_?, onWillDisappear: Func_void_std__optional_bool_?, onDidAppear: Func_void_std__optional_bool_?, onDidDisappear: Func_void_std__optional_bool_?, onPopped: Func_void?, autoDismissMs: Double?, visibleTravelEstimate: VisibleTravelEstimate?, onDidPan: Func_void_Point_std__optional_Point_?, onDidUpdateZoomGestureWithCenter: Func_void_Point_double?, onClick: Func_void_Point?, onDoubleClick: Func_void_Point?, onAppearanceDidChange: Func_void_ColorScheme?, onStopNavigation: Func_void, onAutoDriveEnabled: Func_void?, mapButtons: Array<NitroMapButton>?, headerActions: Array<NitroAction>?, panButtonScrollPercentage: Double?, onDidChangePanningInterface: Func_void_bool?): MapTemplateConfig {
|
|
93
|
-
return MapTemplateConfig(id, onWillAppear, onWillDisappear, onDidAppear, onDidDisappear, onPopped, autoDismissMs, visibleTravelEstimate, onDidPan, onDidUpdateZoomGestureWithCenter, onClick, onDoubleClick, onAppearanceDidChange, onStopNavigation, onAutoDriveEnabled, mapButtons, headerActions, panButtonScrollPercentage, onDidChangePanningInterface)
|
|
95
|
+
private fun fromCpp(id: String, onWillAppear: Func_void_std__optional_bool_?, onWillDisappear: Func_void_std__optional_bool_?, onDidAppear: Func_void_std__optional_bool_?, onDidDisappear: Func_void_std__optional_bool_?, onPopped: Func_void?, autoDismissMs: Double?, visibleTravelEstimate: VisibleTravelEstimate?, onDidPan: Func_void_Point_std__optional_Point_?, onDidUpdateZoomGestureWithCenter: Func_void_Point_double?, onClick: Func_void_Point?, onDoubleClick: Func_void_Point?, onAppearanceDidChange: Func_void_ColorScheme?, onStopNavigation: Func_void, onAutoDriveEnabled: Func_void?, mapButtons: Array<NitroMapButton>?, headerActions: Array<NitroAction>?, defaultGuidanceBackgroundColor: NitroColor?, panButtonScrollPercentage: Double?, onDidChangePanningInterface: Func_void_bool?): MapTemplateConfig {
|
|
96
|
+
return MapTemplateConfig(id, onWillAppear, onWillDisappear, onDidAppear, onDidDisappear, onPopped, autoDismissMs, visibleTravelEstimate, onDidPan, onDidUpdateZoomGestureWithCenter, onClick, onDoubleClick, onAppearanceDidChange, onStopNavigation, onAutoDriveEnabled, mapButtons, headerActions, defaultGuidanceBackgroundColor, panButtonScrollPercentage, onDidChangePanningInterface)
|
|
94
97
|
}
|
|
95
98
|
}
|
|
96
99
|
}
|
|
@@ -19,7 +19,13 @@ import com.facebook.proguard.annotations.DoNotStrip
|
|
|
19
19
|
data class NitroLoadingManeuver(
|
|
20
20
|
@DoNotStrip
|
|
21
21
|
@Keep
|
|
22
|
-
val isLoading: Boolean
|
|
22
|
+
val isLoading: Boolean,
|
|
23
|
+
@DoNotStrip
|
|
24
|
+
@Keep
|
|
25
|
+
val cardBackgroundColor: NitroColor,
|
|
26
|
+
@DoNotStrip
|
|
27
|
+
@Keep
|
|
28
|
+
val text: String?
|
|
23
29
|
) {
|
|
24
30
|
/* primary constructor */
|
|
25
31
|
|
|
@@ -31,8 +37,8 @@ data class NitroLoadingManeuver(
|
|
|
31
37
|
@Keep
|
|
32
38
|
@Suppress("unused")
|
|
33
39
|
@JvmStatic
|
|
34
|
-
private fun fromCpp(isLoading: Boolean): NitroLoadingManeuver {
|
|
35
|
-
return NitroLoadingManeuver(isLoading)
|
|
40
|
+
private fun fromCpp(isLoading: Boolean, cardBackgroundColor: NitroColor, text: String?): NitroLoadingManeuver {
|
|
41
|
+
return NitroLoadingManeuver(isLoading, cardBackgroundColor, text)
|
|
36
42
|
}
|
|
37
43
|
}
|
|
38
44
|
}
|
|
@@ -64,6 +64,8 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct LaneGuidanc
|
|
|
64
64
|
namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct ListTemplateConfig; }
|
|
65
65
|
// Forward declaration of `Location` to properly resolve imports.
|
|
66
66
|
namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct Location; }
|
|
67
|
+
// Forward declaration of `ManeuverState` to properly resolve imports.
|
|
68
|
+
namespace margelo::nitro::swe::iternio::reactnativeautoplay { enum class ManeuverState; }
|
|
67
69
|
// Forward declaration of `ManeuverType` to properly resolve imports.
|
|
68
70
|
namespace margelo::nitro::swe::iternio::reactnativeautoplay { enum class ManeuverType; }
|
|
69
71
|
// Forward declaration of `MapTemplateConfig` to properly resolve imports.
|
|
@@ -176,6 +178,7 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { enum class ZoomEve
|
|
|
176
178
|
#include "LaneGuidance.hpp"
|
|
177
179
|
#include "ListTemplateConfig.hpp"
|
|
178
180
|
#include "Location.hpp"
|
|
181
|
+
#include "ManeuverState.hpp"
|
|
179
182
|
#include "ManeuverType.hpp"
|
|
180
183
|
#include "MapTemplateConfig.hpp"
|
|
181
184
|
#include "MessageTemplateConfig.hpp"
|
|
@@ -98,6 +98,8 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { enum class Traffic
|
|
|
98
98
|
namespace margelo::nitro::swe::iternio::reactnativeautoplay { enum class ManeuverType; }
|
|
99
99
|
// Forward declaration of `TripConfig` to properly resolve imports.
|
|
100
100
|
namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct TripConfig; }
|
|
101
|
+
// Forward declaration of `ManeuverState` to properly resolve imports.
|
|
102
|
+
namespace margelo::nitro::swe::iternio::reactnativeautoplay { enum class ManeuverState; }
|
|
101
103
|
|
|
102
104
|
#include "MapTemplateConfig.hpp"
|
|
103
105
|
#include <string>
|
|
@@ -148,6 +150,7 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct TripConfig;
|
|
|
148
150
|
#include "TrafficSide.hpp"
|
|
149
151
|
#include "ManeuverType.hpp"
|
|
150
152
|
#include "TripConfig.hpp"
|
|
153
|
+
#include "ManeuverState.hpp"
|
|
151
154
|
|
|
152
155
|
#include "ReactNativeAutoPlay-Swift-Cxx-Umbrella.hpp"
|
|
153
156
|
|
|
@@ -275,6 +278,12 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
|
275
278
|
std::rethrow_exception(__result.error());
|
|
276
279
|
}
|
|
277
280
|
}
|
|
281
|
+
inline void setManeuverState(const std::string& templateId, ManeuverState state) override {
|
|
282
|
+
auto __result = _swiftPart.setManeuverState(templateId, static_cast<int>(state));
|
|
283
|
+
if (__result.hasError()) [[unlikely]] {
|
|
284
|
+
std::rethrow_exception(__result.error());
|
|
285
|
+
}
|
|
286
|
+
}
|
|
278
287
|
|
|
279
288
|
private:
|
|
280
289
|
ReactNativeAutoPlay::HybridMapTemplateSpec_cxx _swiftPart;
|
|
@@ -25,6 +25,7 @@ public protocol HybridMapTemplateSpec_protocol: HybridObject {
|
|
|
25
25
|
func updateManeuvers(templateId: String, maneuvers: NitroManeuver) throws -> Void
|
|
26
26
|
func startNavigation(templateId: String, trip: TripConfig) throws -> Void
|
|
27
27
|
func stopNavigation(templateId: String) throws -> Void
|
|
28
|
+
func setManeuverState(templateId: String, state: ManeuverState) throws -> Void
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
public extension HybridMapTemplateSpec_protocol {
|
|
@@ -308,4 +308,15 @@ open class HybridMapTemplateSpec_cxx {
|
|
|
308
308
|
return bridge.create_Result_void_(__exceptionPtr)
|
|
309
309
|
}
|
|
310
310
|
}
|
|
311
|
+
|
|
312
|
+
@inline(__always)
|
|
313
|
+
public final func setManeuverState(templateId: std.string, state: Int32) -> bridge.Result_void_ {
|
|
314
|
+
do {
|
|
315
|
+
try self.__implementation.setManeuverState(templateId: String(templateId), state: margelo.nitro.swe.iternio.reactnativeautoplay.ManeuverState(rawValue: state)!)
|
|
316
|
+
return bridge.create_Result_void_()
|
|
317
|
+
} catch (let __error) {
|
|
318
|
+
let __exceptionPtr = __error.toCpp()
|
|
319
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
320
|
+
}
|
|
321
|
+
}
|
|
311
322
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ManeuverState.swift
|
|
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
|
+
/**
|
|
9
|
+
* Represents the JS enum `ManeuverState`, backed by a C++ enum.
|
|
10
|
+
*/
|
|
11
|
+
public typealias ManeuverState = margelo.nitro.swe.iternio.reactnativeautoplay.ManeuverState
|
|
12
|
+
|
|
13
|
+
public extension ManeuverState {
|
|
14
|
+
/**
|
|
15
|
+
* Get a ManeuverState for the given String value, or
|
|
16
|
+
* return `nil` if the given value was invalid/unknown.
|
|
17
|
+
*/
|
|
18
|
+
init?(fromString string: String) {
|
|
19
|
+
switch string {
|
|
20
|
+
case "Continue":
|
|
21
|
+
self = .continue
|
|
22
|
+
case "Initial":
|
|
23
|
+
self = .initial
|
|
24
|
+
case "Prepare":
|
|
25
|
+
self = .prepare
|
|
26
|
+
case "Execute":
|
|
27
|
+
self = .execute
|
|
28
|
+
default:
|
|
29
|
+
return nil
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Get the String value this ManeuverState represents.
|
|
35
|
+
*/
|
|
36
|
+
var stringValue: String {
|
|
37
|
+
switch self {
|
|
38
|
+
case .continue:
|
|
39
|
+
return "Continue"
|
|
40
|
+
case .initial:
|
|
41
|
+
return "Initial"
|
|
42
|
+
case .prepare:
|
|
43
|
+
return "Prepare"
|
|
44
|
+
case .execute:
|
|
45
|
+
return "Execute"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -18,7 +18,7 @@ public extension MapTemplateConfig {
|
|
|
18
18
|
/**
|
|
19
19
|
* Create a new instance of `MapTemplateConfig`.
|
|
20
20
|
*/
|
|
21
|
-
init(id: String, onWillAppear: ((_ animated: Bool?) -> Void)?, onWillDisappear: ((_ animated: Bool?) -> Void)?, onDidAppear: ((_ animated: Bool?) -> Void)?, onDidDisappear: ((_ animated: Bool?) -> Void)?, onPopped: (() -> Void)?, autoDismissMs: Double?, visibleTravelEstimate: VisibleTravelEstimate?, onDidPan: ((_ translation: Point, _ velocity: Point?) -> Void)?, onDidUpdateZoomGestureWithCenter: ((_ center: Point, _ scale: Double) -> Void)?, onClick: ((_ center: Point) -> Void)?, onDoubleClick: ((_ center: Point) -> Void)?, onAppearanceDidChange: ((_ colorScheme: ColorScheme) -> Void)?, onStopNavigation: @escaping () -> Void, onAutoDriveEnabled: (() -> Void)?, mapButtons: [NitroMapButton]?, headerActions: [NitroAction]?, panButtonScrollPercentage: Double?, onDidChangePanningInterface: ((_ isPanningInterfaceVisible: Bool) -> Void)?) {
|
|
21
|
+
init(id: String, onWillAppear: ((_ animated: Bool?) -> Void)?, onWillDisappear: ((_ animated: Bool?) -> Void)?, onDidAppear: ((_ animated: Bool?) -> Void)?, onDidDisappear: ((_ animated: Bool?) -> Void)?, onPopped: (() -> Void)?, autoDismissMs: Double?, visibleTravelEstimate: VisibleTravelEstimate?, onDidPan: ((_ translation: Point, _ velocity: Point?) -> Void)?, onDidUpdateZoomGestureWithCenter: ((_ center: Point, _ scale: Double) -> Void)?, onClick: ((_ center: Point) -> Void)?, onDoubleClick: ((_ center: Point) -> Void)?, onAppearanceDidChange: ((_ colorScheme: ColorScheme) -> Void)?, onStopNavigation: @escaping () -> Void, onAutoDriveEnabled: (() -> Void)?, mapButtons: [NitroMapButton]?, headerActions: [NitroAction]?, defaultGuidanceBackgroundColor: NitroColor?, panButtonScrollPercentage: Double?, onDidChangePanningInterface: ((_ isPanningInterfaceVisible: Bool) -> Void)?) {
|
|
22
22
|
self.init(std.string(id), { () -> bridge.std__optional_std__function_void_std__optional_bool_____animated______ in
|
|
23
23
|
if let __unwrappedValue = onWillAppear {
|
|
24
24
|
return bridge.create_std__optional_std__function_void_std__optional_bool_____animated______({ () -> bridge.Func_void_std__optional_bool_ in
|
|
@@ -157,6 +157,12 @@ public extension MapTemplateConfig {
|
|
|
157
157
|
} else {
|
|
158
158
|
return .init()
|
|
159
159
|
}
|
|
160
|
+
}(), { () -> bridge.std__optional_NitroColor_ in
|
|
161
|
+
if let __unwrappedValue = defaultGuidanceBackgroundColor {
|
|
162
|
+
return bridge.create_std__optional_NitroColor_(__unwrappedValue)
|
|
163
|
+
} else {
|
|
164
|
+
return .init()
|
|
165
|
+
}
|
|
160
166
|
}(), { () -> bridge.std__optional_double_ in
|
|
161
167
|
if let __unwrappedValue = panButtonScrollPercentage {
|
|
162
168
|
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
@@ -448,6 +454,11 @@ public extension MapTemplateConfig {
|
|
|
448
454
|
}()
|
|
449
455
|
}
|
|
450
456
|
|
|
457
|
+
@inline(__always)
|
|
458
|
+
var defaultGuidanceBackgroundColor: NitroColor? {
|
|
459
|
+
return self.__defaultGuidanceBackgroundColor.value
|
|
460
|
+
}
|
|
461
|
+
|
|
451
462
|
@inline(__always)
|
|
452
463
|
var panButtonScrollPercentage: Double? {
|
|
453
464
|
return { () -> Double? in
|
|
@@ -18,12 +18,35 @@ public extension NitroLoadingManeuver {
|
|
|
18
18
|
/**
|
|
19
19
|
* Create a new instance of `NitroLoadingManeuver`.
|
|
20
20
|
*/
|
|
21
|
-
init(isLoading: Bool) {
|
|
22
|
-
self.init(isLoading)
|
|
21
|
+
init(isLoading: Bool, cardBackgroundColor: NitroColor, text: String?) {
|
|
22
|
+
self.init(isLoading, cardBackgroundColor, { () -> bridge.std__optional_std__string_ in
|
|
23
|
+
if let __unwrappedValue = text {
|
|
24
|
+
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
25
|
+
} else {
|
|
26
|
+
return .init()
|
|
27
|
+
}
|
|
28
|
+
}())
|
|
23
29
|
}
|
|
24
30
|
|
|
25
31
|
@inline(__always)
|
|
26
32
|
var isLoading: Bool {
|
|
27
33
|
return self.__isLoading
|
|
28
34
|
}
|
|
35
|
+
|
|
36
|
+
@inline(__always)
|
|
37
|
+
var cardBackgroundColor: NitroColor {
|
|
38
|
+
return self.__cardBackgroundColor
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@inline(__always)
|
|
42
|
+
var text: String? {
|
|
43
|
+
return { () -> String? in
|
|
44
|
+
if bridge.has_value_std__optional_std__string_(self.__text) {
|
|
45
|
+
let __unwrapped = bridge.get_std__optional_std__string_(self.__text)
|
|
46
|
+
return String(__unwrapped)
|
|
47
|
+
} else {
|
|
48
|
+
return nil
|
|
49
|
+
}
|
|
50
|
+
}()
|
|
51
|
+
}
|
|
29
52
|
}
|
|
@@ -26,6 +26,7 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
|
26
26
|
prototype.registerHybridMethod("updateManeuvers", &HybridMapTemplateSpec::updateManeuvers);
|
|
27
27
|
prototype.registerHybridMethod("startNavigation", &HybridMapTemplateSpec::startNavigation);
|
|
28
28
|
prototype.registerHybridMethod("stopNavigation", &HybridMapTemplateSpec::stopNavigation);
|
|
29
|
+
prototype.registerHybridMethod("setManeuverState", &HybridMapTemplateSpec::setManeuverState);
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
32
|
|
|
@@ -39,6 +39,8 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroMessag
|
|
|
39
39
|
namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroLoadingManeuver; }
|
|
40
40
|
// Forward declaration of `TripConfig` to properly resolve imports.
|
|
41
41
|
namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct TripConfig; }
|
|
42
|
+
// Forward declaration of `ManeuverState` to properly resolve imports.
|
|
43
|
+
namespace margelo::nitro::swe::iternio::reactnativeautoplay { enum class ManeuverState; }
|
|
42
44
|
|
|
43
45
|
#include "MapTemplateConfig.hpp"
|
|
44
46
|
#include <string>
|
|
@@ -59,6 +61,7 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct TripConfig;
|
|
|
59
61
|
#include "NitroLoadingManeuver.hpp"
|
|
60
62
|
#include <variant>
|
|
61
63
|
#include "TripConfig.hpp"
|
|
64
|
+
#include "ManeuverState.hpp"
|
|
62
65
|
|
|
63
66
|
namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
64
67
|
|
|
@@ -103,6 +106,7 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
|
103
106
|
virtual void updateManeuvers(const std::string& templateId, const std::variant<std::vector<NitroRoutingManeuver>, NitroMessageManeuver, NitroLoadingManeuver>& maneuvers) = 0;
|
|
104
107
|
virtual void startNavigation(const std::string& templateId, const TripConfig& trip) = 0;
|
|
105
108
|
virtual void stopNavigation(const std::string& templateId) = 0;
|
|
109
|
+
virtual void setManeuverState(const std::string& templateId, ManeuverState state) = 0;
|
|
106
110
|
|
|
107
111
|
protected:
|
|
108
112
|
// Hybrid Setup
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ManeuverState.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
|
+
|
|
21
|
+
namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* An enum which can be represented as a JavaScript enum (ManeuverState).
|
|
25
|
+
*/
|
|
26
|
+
enum class ManeuverState {
|
|
27
|
+
CONTINUE SWIFT_NAME(continue) = 0,
|
|
28
|
+
INITIAL SWIFT_NAME(initial) = 1,
|
|
29
|
+
PREPARE SWIFT_NAME(prepare) = 2,
|
|
30
|
+
EXECUTE SWIFT_NAME(execute) = 3,
|
|
31
|
+
} CLOSED_ENUM;
|
|
32
|
+
|
|
33
|
+
} // namespace margelo::nitro::swe::iternio::reactnativeautoplay
|
|
34
|
+
|
|
35
|
+
namespace margelo::nitro {
|
|
36
|
+
|
|
37
|
+
// C++ ManeuverState <> JS ManeuverState (enum)
|
|
38
|
+
template <>
|
|
39
|
+
struct JSIConverter<margelo::nitro::swe::iternio::reactnativeautoplay::ManeuverState> final {
|
|
40
|
+
static inline margelo::nitro::swe::iternio::reactnativeautoplay::ManeuverState fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
41
|
+
int enumValue = JSIConverter<int>::fromJSI(runtime, arg);
|
|
42
|
+
return static_cast<margelo::nitro::swe::iternio::reactnativeautoplay::ManeuverState>(enumValue);
|
|
43
|
+
}
|
|
44
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::swe::iternio::reactnativeautoplay::ManeuverState arg) {
|
|
45
|
+
int enumValue = static_cast<int>(arg);
|
|
46
|
+
return JSIConverter<int>::toJSI(runtime, enumValue);
|
|
47
|
+
}
|
|
48
|
+
static inline bool canConvert(jsi::Runtime&, const jsi::Value& value) {
|
|
49
|
+
if (!value.isNumber()) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
double number = value.getNumber();
|
|
53
|
+
int integer = static_cast<int>(number);
|
|
54
|
+
if (number != integer) {
|
|
55
|
+
// The integer is not the same value as the double - we truncated floating points.
|
|
56
|
+
// Enums are all integers, so the input floating point number is obviously invalid.
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
// Check if we are within the bounds of the enum.
|
|
60
|
+
return integer >= 0 && integer <= 3;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
} // namespace margelo::nitro
|
|
@@ -38,6 +38,8 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { enum class ColorSc
|
|
|
38
38
|
namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroMapButton; }
|
|
39
39
|
// Forward declaration of `NitroAction` to properly resolve imports.
|
|
40
40
|
namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroAction; }
|
|
41
|
+
// Forward declaration of `NitroColor` to properly resolve imports.
|
|
42
|
+
namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroColor; }
|
|
41
43
|
|
|
42
44
|
#include <string>
|
|
43
45
|
#include <optional>
|
|
@@ -48,6 +50,7 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroAction
|
|
|
48
50
|
#include "NitroMapButton.hpp"
|
|
49
51
|
#include <vector>
|
|
50
52
|
#include "NitroAction.hpp"
|
|
53
|
+
#include "NitroColor.hpp"
|
|
51
54
|
|
|
52
55
|
namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
53
56
|
|
|
@@ -73,12 +76,13 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
|
73
76
|
std::optional<std::function<void()>> onAutoDriveEnabled SWIFT_PRIVATE;
|
|
74
77
|
std::optional<std::vector<NitroMapButton>> mapButtons SWIFT_PRIVATE;
|
|
75
78
|
std::optional<std::vector<NitroAction>> headerActions SWIFT_PRIVATE;
|
|
79
|
+
std::optional<NitroColor> defaultGuidanceBackgroundColor SWIFT_PRIVATE;
|
|
76
80
|
std::optional<double> panButtonScrollPercentage SWIFT_PRIVATE;
|
|
77
81
|
std::optional<std::function<void(bool /* isPanningInterfaceVisible */)>> onDidChangePanningInterface SWIFT_PRIVATE;
|
|
78
82
|
|
|
79
83
|
public:
|
|
80
84
|
MapTemplateConfig() = default;
|
|
81
|
-
explicit MapTemplateConfig(std::string id, std::optional<std::function<void(std::optional<bool> /* animated */)>> onWillAppear, std::optional<std::function<void(std::optional<bool> /* animated */)>> onWillDisappear, std::optional<std::function<void(std::optional<bool> /* animated */)>> onDidAppear, std::optional<std::function<void(std::optional<bool> /* animated */)>> onDidDisappear, std::optional<std::function<void()>> onPopped, std::optional<double> autoDismissMs, std::optional<VisibleTravelEstimate> visibleTravelEstimate, std::optional<std::function<void(const Point& /* translation */, const std::optional<Point>& /* velocity */)>> onDidPan, std::optional<std::function<void(const Point& /* center */, double /* scale */)>> onDidUpdateZoomGestureWithCenter, std::optional<std::function<void(const Point& /* center */)>> onClick, std::optional<std::function<void(const Point& /* center */)>> onDoubleClick, std::optional<std::function<void(ColorScheme /* colorScheme */)>> onAppearanceDidChange, std::function<void()> onStopNavigation, std::optional<std::function<void()>> onAutoDriveEnabled, std::optional<std::vector<NitroMapButton>> mapButtons, std::optional<std::vector<NitroAction>> headerActions, std::optional<double> panButtonScrollPercentage, std::optional<std::function<void(bool /* isPanningInterfaceVisible */)>> onDidChangePanningInterface): id(id), onWillAppear(onWillAppear), onWillDisappear(onWillDisappear), onDidAppear(onDidAppear), onDidDisappear(onDidDisappear), onPopped(onPopped), autoDismissMs(autoDismissMs), visibleTravelEstimate(visibleTravelEstimate), onDidPan(onDidPan), onDidUpdateZoomGestureWithCenter(onDidUpdateZoomGestureWithCenter), onClick(onClick), onDoubleClick(onDoubleClick), onAppearanceDidChange(onAppearanceDidChange), onStopNavigation(onStopNavigation), onAutoDriveEnabled(onAutoDriveEnabled), mapButtons(mapButtons), headerActions(headerActions), panButtonScrollPercentage(panButtonScrollPercentage), onDidChangePanningInterface(onDidChangePanningInterface) {}
|
|
85
|
+
explicit MapTemplateConfig(std::string id, std::optional<std::function<void(std::optional<bool> /* animated */)>> onWillAppear, std::optional<std::function<void(std::optional<bool> /* animated */)>> onWillDisappear, std::optional<std::function<void(std::optional<bool> /* animated */)>> onDidAppear, std::optional<std::function<void(std::optional<bool> /* animated */)>> onDidDisappear, std::optional<std::function<void()>> onPopped, std::optional<double> autoDismissMs, std::optional<VisibleTravelEstimate> visibleTravelEstimate, std::optional<std::function<void(const Point& /* translation */, const std::optional<Point>& /* velocity */)>> onDidPan, std::optional<std::function<void(const Point& /* center */, double /* scale */)>> onDidUpdateZoomGestureWithCenter, std::optional<std::function<void(const Point& /* center */)>> onClick, std::optional<std::function<void(const Point& /* center */)>> onDoubleClick, std::optional<std::function<void(ColorScheme /* colorScheme */)>> onAppearanceDidChange, std::function<void()> onStopNavigation, std::optional<std::function<void()>> onAutoDriveEnabled, std::optional<std::vector<NitroMapButton>> mapButtons, std::optional<std::vector<NitroAction>> headerActions, std::optional<NitroColor> defaultGuidanceBackgroundColor, std::optional<double> panButtonScrollPercentage, std::optional<std::function<void(bool /* isPanningInterfaceVisible */)>> onDidChangePanningInterface): id(id), onWillAppear(onWillAppear), onWillDisappear(onWillDisappear), onDidAppear(onDidAppear), onDidDisappear(onDidDisappear), onPopped(onPopped), autoDismissMs(autoDismissMs), visibleTravelEstimate(visibleTravelEstimate), onDidPan(onDidPan), onDidUpdateZoomGestureWithCenter(onDidUpdateZoomGestureWithCenter), onClick(onClick), onDoubleClick(onDoubleClick), onAppearanceDidChange(onAppearanceDidChange), onStopNavigation(onStopNavigation), onAutoDriveEnabled(onAutoDriveEnabled), mapButtons(mapButtons), headerActions(headerActions), defaultGuidanceBackgroundColor(defaultGuidanceBackgroundColor), panButtonScrollPercentage(panButtonScrollPercentage), onDidChangePanningInterface(onDidChangePanningInterface) {}
|
|
82
86
|
|
|
83
87
|
public:
|
|
84
88
|
// MapTemplateConfig is not equatable because these properties are not equatable: onWillAppear, onWillDisappear, onDidAppear, onDidDisappear, onPopped, onDidPan, onDidUpdateZoomGestureWithCenter, onClick, onDoubleClick, onAppearanceDidChange, onStopNavigation, onAutoDriveEnabled, mapButtons, headerActions, onDidChangePanningInterface
|
|
@@ -111,6 +115,7 @@ namespace margelo::nitro {
|
|
|
111
115
|
JSIConverter<std::optional<std::function<void()>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onAutoDriveEnabled"))),
|
|
112
116
|
JSIConverter<std::optional<std::vector<margelo::nitro::swe::iternio::reactnativeautoplay::NitroMapButton>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mapButtons"))),
|
|
113
117
|
JSIConverter<std::optional<std::vector<margelo::nitro::swe::iternio::reactnativeautoplay::NitroAction>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "headerActions"))),
|
|
118
|
+
JSIConverter<std::optional<margelo::nitro::swe::iternio::reactnativeautoplay::NitroColor>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "defaultGuidanceBackgroundColor"))),
|
|
114
119
|
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "panButtonScrollPercentage"))),
|
|
115
120
|
JSIConverter<std::optional<std::function<void(bool)>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onDidChangePanningInterface")))
|
|
116
121
|
);
|
|
@@ -134,6 +139,7 @@ namespace margelo::nitro {
|
|
|
134
139
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "onAutoDriveEnabled"), JSIConverter<std::optional<std::function<void()>>>::toJSI(runtime, arg.onAutoDriveEnabled));
|
|
135
140
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "mapButtons"), JSIConverter<std::optional<std::vector<margelo::nitro::swe::iternio::reactnativeautoplay::NitroMapButton>>>::toJSI(runtime, arg.mapButtons));
|
|
136
141
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "headerActions"), JSIConverter<std::optional<std::vector<margelo::nitro::swe::iternio::reactnativeautoplay::NitroAction>>>::toJSI(runtime, arg.headerActions));
|
|
142
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "defaultGuidanceBackgroundColor"), JSIConverter<std::optional<margelo::nitro::swe::iternio::reactnativeautoplay::NitroColor>>::toJSI(runtime, arg.defaultGuidanceBackgroundColor));
|
|
137
143
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "panButtonScrollPercentage"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.panButtonScrollPercentage));
|
|
138
144
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "onDidChangePanningInterface"), JSIConverter<std::optional<std::function<void(bool)>>>::toJSI(runtime, arg.onDidChangePanningInterface));
|
|
139
145
|
return obj;
|
|
@@ -163,6 +169,7 @@ namespace margelo::nitro {
|
|
|
163
169
|
if (!JSIConverter<std::optional<std::function<void()>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onAutoDriveEnabled")))) return false;
|
|
164
170
|
if (!JSIConverter<std::optional<std::vector<margelo::nitro::swe::iternio::reactnativeautoplay::NitroMapButton>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mapButtons")))) return false;
|
|
165
171
|
if (!JSIConverter<std::optional<std::vector<margelo::nitro::swe::iternio::reactnativeautoplay::NitroAction>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "headerActions")))) return false;
|
|
172
|
+
if (!JSIConverter<std::optional<margelo::nitro::swe::iternio::reactnativeautoplay::NitroColor>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "defaultGuidanceBackgroundColor")))) return false;
|
|
166
173
|
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "panButtonScrollPercentage")))) return false;
|
|
167
174
|
if (!JSIConverter<std::optional<std::function<void(bool)>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onDidChangePanningInterface")))) return false;
|
|
168
175
|
return true;
|
|
@@ -28,9 +28,12 @@
|
|
|
28
28
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
29
|
#endif
|
|
30
30
|
|
|
31
|
+
// Forward declaration of `NitroColor` to properly resolve imports.
|
|
32
|
+
namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroColor; }
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
#include "NitroColor.hpp"
|
|
35
|
+
#include <string>
|
|
36
|
+
#include <optional>
|
|
34
37
|
|
|
35
38
|
namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
36
39
|
|
|
@@ -40,10 +43,12 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
|
40
43
|
struct NitroLoadingManeuver final {
|
|
41
44
|
public:
|
|
42
45
|
bool isLoading SWIFT_PRIVATE;
|
|
46
|
+
NitroColor cardBackgroundColor SWIFT_PRIVATE;
|
|
47
|
+
std::optional<std::string> text SWIFT_PRIVATE;
|
|
43
48
|
|
|
44
49
|
public:
|
|
45
50
|
NitroLoadingManeuver() = default;
|
|
46
|
-
explicit NitroLoadingManeuver(bool isLoading): isLoading(isLoading) {}
|
|
51
|
+
explicit NitroLoadingManeuver(bool isLoading, NitroColor cardBackgroundColor, std::optional<std::string> text): isLoading(isLoading), cardBackgroundColor(cardBackgroundColor), text(text) {}
|
|
47
52
|
|
|
48
53
|
public:
|
|
49
54
|
friend bool operator==(const NitroLoadingManeuver& lhs, const NitroLoadingManeuver& rhs) = default;
|
|
@@ -59,12 +64,16 @@ namespace margelo::nitro {
|
|
|
59
64
|
static inline margelo::nitro::swe::iternio::reactnativeautoplay::NitroLoadingManeuver fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
60
65
|
jsi::Object obj = arg.asObject(runtime);
|
|
61
66
|
return margelo::nitro::swe::iternio::reactnativeautoplay::NitroLoadingManeuver(
|
|
62
|
-
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isLoading")))
|
|
67
|
+
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isLoading"))),
|
|
68
|
+
JSIConverter<margelo::nitro::swe::iternio::reactnativeautoplay::NitroColor>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cardBackgroundColor"))),
|
|
69
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "text")))
|
|
63
70
|
);
|
|
64
71
|
}
|
|
65
72
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::swe::iternio::reactnativeautoplay::NitroLoadingManeuver& arg) {
|
|
66
73
|
jsi::Object obj(runtime);
|
|
67
74
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "isLoading"), JSIConverter<bool>::toJSI(runtime, arg.isLoading));
|
|
75
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "cardBackgroundColor"), JSIConverter<margelo::nitro::swe::iternio::reactnativeautoplay::NitroColor>::toJSI(runtime, arg.cardBackgroundColor));
|
|
76
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "text"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.text));
|
|
68
77
|
return obj;
|
|
69
78
|
}
|
|
70
79
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -76,6 +85,8 @@ namespace margelo::nitro {
|
|
|
76
85
|
return false;
|
|
77
86
|
}
|
|
78
87
|
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isLoading")))) return false;
|
|
88
|
+
if (!JSIConverter<margelo::nitro::swe::iternio::reactnativeautoplay::NitroColor>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cardBackgroundColor")))) return false;
|
|
89
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "text")))) return false;
|
|
79
90
|
return true;
|
|
80
91
|
}
|
|
81
92
|
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { HybridAutoPlay } from '../hybrid/HybridAutoPlay';
|
|
3
|
+
import type { CleanupCallback } from '../types/Event';
|
|
4
|
+
|
|
5
|
+
type Props = { children: React.ReactNode; moduleName: string };
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* renders the passed children when the specified scene/screen appeared
|
|
9
|
+
* this makes sure child hooks are executed only when the map template is ready
|
|
10
|
+
*/
|
|
11
|
+
export default function OnAppearedChildRenderer({ children, moduleName }: Props) {
|
|
12
|
+
const [didAppear, setDidAppear] = useState(false);
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
let remove: CleanupCallback | null = HybridAutoPlay.addListenerRenderState(
|
|
16
|
+
moduleName,
|
|
17
|
+
(renderState) => {
|
|
18
|
+
if (renderState === 'didAppear') {
|
|
19
|
+
remove?.();
|
|
20
|
+
remove = null;
|
|
21
|
+
setDidAppear(true);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
return () => {
|
|
27
|
+
remove?.();
|
|
28
|
+
remove = null;
|
|
29
|
+
};
|
|
30
|
+
}, [moduleName]);
|
|
31
|
+
|
|
32
|
+
if (didAppear) {
|
|
33
|
+
return children;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
TripSelectorCallback,
|
|
5
5
|
VisibleTravelEstimate,
|
|
6
6
|
} from '../templates/MapTemplate';
|
|
7
|
+
import type { ManeuverState } from '../types/Maneuver';
|
|
7
8
|
import type { AutoText } from '../types/Text';
|
|
8
9
|
import type {
|
|
9
10
|
TripConfig,
|
|
@@ -48,4 +49,5 @@ export interface MapTemplate extends HybridObject<{ android: 'kotlin'; ios: 'swi
|
|
|
48
49
|
updateManeuvers(templateId: string, maneuvers: NitroManeuver): void;
|
|
49
50
|
startNavigation(templateId: string, trip: TripConfig): void;
|
|
50
51
|
stopNavigation(templateId: string): void;
|
|
52
|
+
setManeuverState(templateId: string, state: ManeuverState): void;
|
|
51
53
|
}
|