@iternio/react-native-auto-play 0.0.4 → 0.0.5

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.
Files changed (32) hide show
  1. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAutoPlay.kt +1 -9
  2. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridMapTemplate.kt +42 -22
  3. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/template/AndroidAutoTemplate.kt +21 -0
  4. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/template/Parser.kt +58 -25
  5. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/utils/BitmapCache.kt +60 -0
  6. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/utils/SymbolFont.kt +16 -31
  7. package/ios/hybrid/HybridMapTemplate.swift +25 -16
  8. package/lib/specs/MapTemplate.nitro.d.ts +5 -2
  9. package/lib/templates/MapTemplate.d.ts +4 -6
  10. package/lib/templates/MapTemplate.js +6 -0
  11. package/nitrogen/generated/android/ReactNativeAutoPlayOnLoad.cpp +0 -2
  12. package/nitrogen/generated/android/c++/JHybridMapTemplateSpec.cpp +27 -25
  13. package/nitrogen/generated/android/c++/JHybridMapTemplateSpec.hpp +3 -1
  14. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridMapTemplateSpec.kt +9 -1
  15. package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Bridge.cpp +0 -8
  16. package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Bridge.hpp +0 -34
  17. package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Umbrella.hpp +0 -3
  18. package/nitrogen/generated/ios/c++/HybridMapTemplateSpecSwift.hpp +16 -9
  19. package/nitrogen/generated/ios/swift/HybridMapTemplateSpec.swift +3 -1
  20. package/nitrogen/generated/ios/swift/HybridMapTemplateSpec_cxx.swift +26 -5
  21. package/nitrogen/generated/shared/c++/HybridMapTemplateSpec.cpp +2 -0
  22. package/nitrogen/generated/shared/c++/HybridMapTemplateSpec.hpp +7 -5
  23. package/package.json +1 -1
  24. package/src/specs/MapTemplate.nitro.ts +9 -2
  25. package/src/templates/MapTemplate.ts +9 -5
  26. package/nitrogen/generated/android/c++/JFunc_void_AutoText_std__optional_AutoText_.hpp +0 -82
  27. package/nitrogen/generated/android/c++/JNavigationAlertCallbacks.hpp +0 -91
  28. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_AutoText_std__optional_AutoText_.kt +0 -80
  29. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NavigationAlertCallbacks.kt +0 -45
  30. package/nitrogen/generated/ios/swift/Func_void_AutoText_std__optional_AutoText_.swift +0 -47
  31. package/nitrogen/generated/ios/swift/NavigationAlertCallbacks.swift +0 -74
  32. package/nitrogen/generated/shared/c++/NavigationAlertCallbacks.hpp +0 -82
@@ -55,7 +55,9 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
55
55
  public:
56
56
  // Methods
57
57
  void createMapTemplate(const MapTemplateConfig& config) override;
58
- NavigationAlertCallbacks showNavigationAlert(const std::string& templateId, const NitroNavigationAlert& alert) override;
58
+ void showNavigationAlert(const std::string& templateId, const NitroNavigationAlert& alert) override;
59
+ void updateNavigationAlert(const std::string& templateId, double navigationAlertId, const AutoText& title, const std::optional<AutoText>& subtitle) override;
60
+ void dismissNavigationAlert(const std::string& templateId, double navigationAlertId) override;
59
61
  TripSelectorCallback showTripSelector(const std::string& templateId, const std::vector<TripsConfig>& trips, const std::optional<std::string>& selectedTripId, const TripPreviewTextConfiguration& textConfig, const std::function<void(const std::string& /* tripId */, const std::string& /* routeId */)>& onTripSelected, const std::function<void(const std::string& /* tripId */, const std::string& /* routeId */)>& onTripStarted, const std::function<void()>& onBackPressed, const std::vector<NitroMapButton>& mapButtons) override;
60
62
  void hideTripSelector(const std::string& templateId) override;
61
63
  void setTemplateMapButtons(const std::string& templateId, const std::optional<std::vector<NitroMapButton>>& buttons) override;
@@ -51,7 +51,15 @@ abstract class HybridMapTemplateSpec: HybridObject() {
51
51
 
52
52
  @DoNotStrip
53
53
  @Keep
54
- abstract fun showNavigationAlert(templateId: String, alert: NitroNavigationAlert): NavigationAlertCallbacks
54
+ abstract fun showNavigationAlert(templateId: String, alert: NitroNavigationAlert): Unit
55
+
56
+ @DoNotStrip
57
+ @Keep
58
+ abstract fun updateNavigationAlert(templateId: String, navigationAlertId: Double, title: AutoText, subtitle: AutoText?): Unit
59
+
60
+ @DoNotStrip
61
+ @Keep
62
+ abstract fun dismissNavigationAlert(templateId: String, navigationAlertId: Double): Unit
55
63
 
56
64
  abstract fun showTripSelector(templateId: String, trips: Array<TripsConfig>, selectedTripId: String?, textConfig: TripPreviewTextConfiguration, onTripSelected: (tripId: String, routeId: String) -> Unit, onTripStarted: (tripId: String, routeId: String) -> Unit, onBackPressed: () -> Unit, mapButtons: Array<NitroMapButton>): TripSelectorCallback
57
65
 
@@ -229,14 +229,6 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay::bridge::swift {
229
229
  };
230
230
  }
231
231
 
232
- // pragma MARK: std::function<void(const AutoText& /* title */, const std::optional<AutoText>& /* subtitle */)>
233
- Func_void_AutoText_std__optional_AutoText_ create_Func_void_AutoText_std__optional_AutoText_(void* NON_NULL swiftClosureWrapper) noexcept {
234
- auto swiftClosure = ReactNativeAutoPlay::Func_void_AutoText_std__optional_AutoText_::fromUnsafe(swiftClosureWrapper);
235
- return [swiftClosure = std::move(swiftClosure)](const AutoText& title, const std::optional<AutoText>& subtitle) mutable -> void {
236
- swiftClosure.call(title, subtitle);
237
- };
238
- }
239
-
240
232
  // pragma MARK: std::function<void(AlertDismissalReason /* reason */)>
241
233
  Func_void_AlertDismissalReason create_Func_void_AlertDismissalReason(void* NON_NULL swiftClosureWrapper) noexcept {
242
234
  auto swiftClosure = ReactNativeAutoPlay::Func_void_AlertDismissalReason::fromUnsafe(swiftClosureWrapper);
@@ -56,8 +56,6 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct LaneGuidanc
56
56
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { enum class ManeuverType; }
57
57
  // Forward declaration of `NavigationAlertAction` to properly resolve imports.
58
58
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NavigationAlertAction; }
59
- // Forward declaration of `NavigationAlertCallbacks` to properly resolve imports.
60
- namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NavigationAlertCallbacks; }
61
59
  // Forward declaration of `NitroActionType` to properly resolve imports.
62
60
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { enum class NitroActionType; }
63
61
  // Forward declaration of `NitroAction` to properly resolve imports.
@@ -168,7 +166,6 @@ namespace ReactNativeAutoPlay { class HybridSearchTemplateSpec_cxx; }
168
166
  #include "LaneGuidance.hpp"
169
167
  #include "ManeuverType.hpp"
170
168
  #include "NavigationAlertAction.hpp"
171
- #include "NavigationAlertCallbacks.hpp"
172
169
  #include "NitroAction.hpp"
173
170
  #include "NitroActionType.hpp"
174
171
  #include "NitroAlignment.hpp"
@@ -1134,28 +1131,6 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay::bridge::swift {
1134
1131
  return *optional;
1135
1132
  }
1136
1133
 
1137
- // pragma MARK: std::function<void(const AutoText& /* title */, const std::optional<AutoText>& /* subtitle */)>
1138
- /**
1139
- * Specialized version of `std::function<void(const AutoText&, const std::optional<AutoText>&)>`.
1140
- */
1141
- using Func_void_AutoText_std__optional_AutoText_ = std::function<void(const AutoText& /* title */, const std::optional<AutoText>& /* subtitle */)>;
1142
- /**
1143
- * Wrapper class for a `std::function<void(const AutoText& / * title * /, const std::optional<AutoText>& / * subtitle * /)>`, this can be used from Swift.
1144
- */
1145
- class Func_void_AutoText_std__optional_AutoText__Wrapper final {
1146
- public:
1147
- explicit Func_void_AutoText_std__optional_AutoText__Wrapper(std::function<void(const AutoText& /* title */, const std::optional<AutoText>& /* subtitle */)>&& func): _function(std::make_unique<std::function<void(const AutoText& /* title */, const std::optional<AutoText>& /* subtitle */)>>(std::move(func))) {}
1148
- inline void call(AutoText title, std::optional<AutoText> subtitle) const noexcept {
1149
- _function->operator()(title, subtitle);
1150
- }
1151
- private:
1152
- std::unique_ptr<std::function<void(const AutoText& /* title */, const std::optional<AutoText>& /* subtitle */)>> _function;
1153
- } SWIFT_NONCOPYABLE;
1154
- Func_void_AutoText_std__optional_AutoText_ create_Func_void_AutoText_std__optional_AutoText_(void* NON_NULL swiftClosureWrapper) noexcept;
1155
- inline Func_void_AutoText_std__optional_AutoText__Wrapper wrap_Func_void_AutoText_std__optional_AutoText_(Func_void_AutoText_std__optional_AutoText_ value) noexcept {
1156
- return Func_void_AutoText_std__optional_AutoText__Wrapper(std::move(value));
1157
- }
1158
-
1159
1134
  // pragma MARK: std::optional<AlertActionStyle>
1160
1135
  /**
1161
1136
  * Specialized version of `std::optional<AlertActionStyle>`.
@@ -1501,15 +1476,6 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay::bridge::swift {
1501
1476
  using std__weak_ptr_HybridMapTemplateSpec_ = std::weak_ptr<HybridMapTemplateSpec>;
1502
1477
  inline std__weak_ptr_HybridMapTemplateSpec_ weakify_std__shared_ptr_HybridMapTemplateSpec_(const std::shared_ptr<HybridMapTemplateSpec>& strong) noexcept { return strong; }
1503
1478
 
1504
- // pragma MARK: Result<NavigationAlertCallbacks>
1505
- using Result_NavigationAlertCallbacks_ = Result<NavigationAlertCallbacks>;
1506
- inline Result_NavigationAlertCallbacks_ create_Result_NavigationAlertCallbacks_(const NavigationAlertCallbacks& value) noexcept {
1507
- return Result<NavigationAlertCallbacks>::withValue(value);
1508
- }
1509
- inline Result_NavigationAlertCallbacks_ create_Result_NavigationAlertCallbacks_(const std::exception_ptr& error) noexcept {
1510
- return Result<NavigationAlertCallbacks>::withError(error);
1511
- }
1512
-
1513
1479
  // pragma MARK: Result<TripSelectorCallback>
1514
1480
  using Result_TripSelectorCallback_ = Result<TripSelectorCallback>;
1515
1481
  inline Result_TripSelectorCallback_ create_Result_TripSelectorCallback_(const TripSelectorCallback& value) noexcept {
@@ -70,8 +70,6 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct MapTemplate
70
70
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct MessageTemplateConfig; }
71
71
  // Forward declaration of `NavigationAlertAction` to properly resolve imports.
72
72
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NavigationAlertAction; }
73
- // Forward declaration of `NavigationAlertCallbacks` to properly resolve imports.
74
- namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NavigationAlertCallbacks; }
75
73
  // Forward declaration of `NitroActionType` to properly resolve imports.
76
74
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { enum class NitroActionType; }
77
75
  // Forward declaration of `NitroAction` to properly resolve imports.
@@ -177,7 +175,6 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { enum class ZoomEve
177
175
  #include "MapTemplateConfig.hpp"
178
176
  #include "MessageTemplateConfig.hpp"
179
177
  #include "NavigationAlertAction.hpp"
180
- #include "NavigationAlertCallbacks.hpp"
181
178
  #include "NitroAction.hpp"
182
179
  #include "NitroActionType.hpp"
183
180
  #include "NitroAlignment.hpp"
@@ -38,16 +38,14 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { enum class NitroAc
38
38
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { enum class NitroAlignment; }
39
39
  // Forward declaration of `NitroButtonStyle` to properly resolve imports.
40
40
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { enum class NitroButtonStyle; }
41
- // Forward declaration of `NavigationAlertCallbacks` to properly resolve imports.
42
- namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NavigationAlertCallbacks; }
41
+ // Forward declaration of `NitroNavigationAlert` to properly resolve imports.
42
+ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroNavigationAlert; }
43
43
  // Forward declaration of `AutoText` to properly resolve imports.
44
44
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct AutoText; }
45
45
  // Forward declaration of `Distance` to properly resolve imports.
46
46
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct Distance; }
47
47
  // Forward declaration of `DistanceUnits` to properly resolve imports.
48
48
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { enum class DistanceUnits; }
49
- // Forward declaration of `NitroNavigationAlert` to properly resolve imports.
50
- namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroNavigationAlert; }
51
49
  // Forward declaration of `NavigationAlertAction` to properly resolve imports.
52
50
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NavigationAlertAction; }
53
51
  // Forward declaration of `AlertActionStyle` to properly resolve imports.
@@ -117,11 +115,10 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct TripConfig;
117
115
  #include "NitroActionType.hpp"
118
116
  #include "NitroAlignment.hpp"
119
117
  #include "NitroButtonStyle.hpp"
120
- #include "NavigationAlertCallbacks.hpp"
118
+ #include "NitroNavigationAlert.hpp"
121
119
  #include "AutoText.hpp"
122
120
  #include "Distance.hpp"
123
121
  #include "DistanceUnits.hpp"
124
- #include "NitroNavigationAlert.hpp"
125
122
  #include "NavigationAlertAction.hpp"
126
123
  #include "AlertActionStyle.hpp"
127
124
  #include "AlertDismissalReason.hpp"
@@ -198,13 +195,23 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
198
195
  std::rethrow_exception(__result.error());
199
196
  }
200
197
  }
201
- inline NavigationAlertCallbacks showNavigationAlert(const std::string& templateId, const NitroNavigationAlert& alert) override {
198
+ inline void showNavigationAlert(const std::string& templateId, const NitroNavigationAlert& alert) override {
202
199
  auto __result = _swiftPart.showNavigationAlert(templateId, std::forward<decltype(alert)>(alert));
203
200
  if (__result.hasError()) [[unlikely]] {
204
201
  std::rethrow_exception(__result.error());
205
202
  }
206
- auto __value = std::move(__result.value());
207
- return __value;
203
+ }
204
+ inline void updateNavigationAlert(const std::string& templateId, double navigationAlertId, const AutoText& title, const std::optional<AutoText>& subtitle) override {
205
+ auto __result = _swiftPart.updateNavigationAlert(templateId, std::forward<decltype(navigationAlertId)>(navigationAlertId), std::forward<decltype(title)>(title), subtitle);
206
+ if (__result.hasError()) [[unlikely]] {
207
+ std::rethrow_exception(__result.error());
208
+ }
209
+ }
210
+ inline void dismissNavigationAlert(const std::string& templateId, double navigationAlertId) override {
211
+ auto __result = _swiftPart.dismissNavigationAlert(templateId, std::forward<decltype(navigationAlertId)>(navigationAlertId));
212
+ if (__result.hasError()) [[unlikely]] {
213
+ std::rethrow_exception(__result.error());
214
+ }
208
215
  }
209
216
  inline TripSelectorCallback showTripSelector(const std::string& templateId, const std::vector<TripsConfig>& trips, const std::optional<std::string>& selectedTripId, const TripPreviewTextConfiguration& textConfig, const std::function<void(const std::string& /* tripId */, const std::string& /* routeId */)>& onTripSelected, const std::function<void(const std::string& /* tripId */, const std::string& /* routeId */)>& onTripStarted, const std::function<void()>& onBackPressed, const std::vector<NitroMapButton>& mapButtons) override {
210
217
  auto __result = _swiftPart.showTripSelector(templateId, trips, selectedTripId, std::forward<decltype(textConfig)>(textConfig), onTripSelected, onTripStarted, onBackPressed, mapButtons);
@@ -15,7 +15,9 @@ public protocol HybridMapTemplateSpec_protocol: HybridObject {
15
15
 
16
16
  // Methods
17
17
  func createMapTemplate(config: MapTemplateConfig) throws -> Void
18
- func showNavigationAlert(templateId: String, alert: NitroNavigationAlert) throws -> NavigationAlertCallbacks
18
+ func showNavigationAlert(templateId: String, alert: NitroNavigationAlert) throws -> Void
19
+ func updateNavigationAlert(templateId: String, navigationAlertId: Double, title: AutoText, subtitle: AutoText?) throws -> Void
20
+ func dismissNavigationAlert(templateId: String, navigationAlertId: Double) throws -> Void
19
21
  func showTripSelector(templateId: String, trips: [TripsConfig], selectedTripId: String?, textConfig: TripPreviewTextConfiguration, onTripSelected: @escaping (_ tripId: String, _ routeId: String) -> Void, onTripStarted: @escaping (_ tripId: String, _ routeId: String) -> Void, onBackPressed: @escaping () -> Void, mapButtons: [NitroMapButton]) throws -> TripSelectorCallback
20
22
  func hideTripSelector(templateId: String) throws -> Void
21
23
  func setTemplateMapButtons(templateId: String, buttons: [NitroMapButton]?) throws -> Void
@@ -129,14 +129,35 @@ open class HybridMapTemplateSpec_cxx {
129
129
  }
130
130
 
131
131
  @inline(__always)
132
- public final func showNavigationAlert(templateId: std.string, alert: NitroNavigationAlert) -> bridge.Result_NavigationAlertCallbacks_ {
132
+ public final func showNavigationAlert(templateId: std.string, alert: NitroNavigationAlert) -> bridge.Result_void_ {
133
133
  do {
134
- let __result = try self.__implementation.showNavigationAlert(templateId: String(templateId), alert: alert)
135
- let __resultCpp = __result
136
- return bridge.create_Result_NavigationAlertCallbacks_(__resultCpp)
134
+ try self.__implementation.showNavigationAlert(templateId: String(templateId), alert: alert)
135
+ return bridge.create_Result_void_()
136
+ } catch (let __error) {
137
+ let __exceptionPtr = __error.toCpp()
138
+ return bridge.create_Result_void_(__exceptionPtr)
139
+ }
140
+ }
141
+
142
+ @inline(__always)
143
+ public final func updateNavigationAlert(templateId: std.string, navigationAlertId: Double, title: AutoText, subtitle: bridge.std__optional_AutoText_) -> bridge.Result_void_ {
144
+ do {
145
+ try self.__implementation.updateNavigationAlert(templateId: String(templateId), navigationAlertId: navigationAlertId, title: title, subtitle: subtitle.value)
146
+ return bridge.create_Result_void_()
137
147
  } catch (let __error) {
138
148
  let __exceptionPtr = __error.toCpp()
139
- return bridge.create_Result_NavigationAlertCallbacks_(__exceptionPtr)
149
+ return bridge.create_Result_void_(__exceptionPtr)
150
+ }
151
+ }
152
+
153
+ @inline(__always)
154
+ public final func dismissNavigationAlert(templateId: std.string, navigationAlertId: Double) -> bridge.Result_void_ {
155
+ do {
156
+ try self.__implementation.dismissNavigationAlert(templateId: String(templateId), navigationAlertId: navigationAlertId)
157
+ return bridge.create_Result_void_()
158
+ } catch (let __error) {
159
+ let __exceptionPtr = __error.toCpp()
160
+ return bridge.create_Result_void_(__exceptionPtr)
140
161
  }
141
162
  }
142
163
 
@@ -16,6 +16,8 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
16
16
  registerHybrids(this, [](Prototype& prototype) {
17
17
  prototype.registerHybridMethod("createMapTemplate", &HybridMapTemplateSpec::createMapTemplate);
18
18
  prototype.registerHybridMethod("showNavigationAlert", &HybridMapTemplateSpec::showNavigationAlert);
19
+ prototype.registerHybridMethod("updateNavigationAlert", &HybridMapTemplateSpec::updateNavigationAlert);
20
+ prototype.registerHybridMethod("dismissNavigationAlert", &HybridMapTemplateSpec::dismissNavigationAlert);
19
21
  prototype.registerHybridMethod("showTripSelector", &HybridMapTemplateSpec::showTripSelector);
20
22
  prototype.registerHybridMethod("hideTripSelector", &HybridMapTemplateSpec::hideTripSelector);
21
23
  prototype.registerHybridMethod("setTemplateMapButtons", &HybridMapTemplateSpec::setTemplateMapButtons);
@@ -15,10 +15,10 @@
15
15
 
16
16
  // Forward declaration of `MapTemplateConfig` to properly resolve imports.
17
17
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct MapTemplateConfig; }
18
- // Forward declaration of `NavigationAlertCallbacks` to properly resolve imports.
19
- namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NavigationAlertCallbacks; }
20
18
  // Forward declaration of `NitroNavigationAlert` to properly resolve imports.
21
19
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroNavigationAlert; }
20
+ // Forward declaration of `AutoText` to properly resolve imports.
21
+ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct AutoText; }
22
22
  // Forward declaration of `TripSelectorCallback` to properly resolve imports.
23
23
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct TripSelectorCallback; }
24
24
  // Forward declaration of `TripsConfig` to properly resolve imports.
@@ -39,13 +39,13 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroMessag
39
39
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct TripConfig; }
40
40
 
41
41
  #include "MapTemplateConfig.hpp"
42
- #include "NavigationAlertCallbacks.hpp"
43
42
  #include <string>
44
43
  #include "NitroNavigationAlert.hpp"
44
+ #include "AutoText.hpp"
45
+ #include <optional>
45
46
  #include "TripSelectorCallback.hpp"
46
47
  #include "TripsConfig.hpp"
47
48
  #include <vector>
48
- #include <optional>
49
49
  #include "TripPreviewTextConfiguration.hpp"
50
50
  #include <functional>
51
51
  #include "NitroMapButton.hpp"
@@ -88,7 +88,9 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
88
88
  public:
89
89
  // Methods
90
90
  virtual void createMapTemplate(const MapTemplateConfig& config) = 0;
91
- virtual NavigationAlertCallbacks showNavigationAlert(const std::string& templateId, const NitroNavigationAlert& alert) = 0;
91
+ virtual void showNavigationAlert(const std::string& templateId, const NitroNavigationAlert& alert) = 0;
92
+ virtual void updateNavigationAlert(const std::string& templateId, double navigationAlertId, const AutoText& title, const std::optional<AutoText>& subtitle) = 0;
93
+ virtual void dismissNavigationAlert(const std::string& templateId, double navigationAlertId) = 0;
92
94
  virtual TripSelectorCallback showTripSelector(const std::string& templateId, const std::vector<TripsConfig>& trips, const std::optional<std::string>& selectedTripId, const TripPreviewTextConfiguration& textConfig, const std::function<void(const std::string& /* tripId */, const std::string& /* routeId */)>& onTripSelected, const std::function<void(const std::string& /* tripId */, const std::string& /* routeId */)>& onTripStarted, const std::function<void()>& onBackPressed, const std::vector<NitroMapButton>& mapButtons) = 0;
93
95
  virtual void hideTripSelector(const std::string& templateId) = 0;
94
96
  virtual void setTemplateMapButtons(const std::string& templateId, const std::optional<std::vector<NitroMapButton>>& buttons) = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iternio/react-native-auto-play",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Android Auto and Apple CarPlay for react-native",
5
5
  "main": "lib/index",
6
6
  "module": "lib/index",
@@ -1,10 +1,10 @@
1
1
  import type { HybridObject } from 'react-native-nitro-modules';
2
2
  import type {
3
- NavigationAlertCallbacks,
4
3
  NitroMapTemplateConfig,
5
4
  TripSelectorCallback,
6
5
  VisibleTravelEstimate,
7
6
  } from '../templates/MapTemplate';
7
+ import type { AutoText } from '../types/Text';
8
8
  import type {
9
9
  TripConfig,
10
10
  TripPoint,
@@ -20,7 +20,14 @@ interface MapTemplateConfig extends NitroTemplateConfig, NitroMapTemplateConfig
20
20
 
21
21
  export interface MapTemplate extends HybridObject<{ android: 'kotlin'; ios: 'swift' }> {
22
22
  createMapTemplate(config: MapTemplateConfig): void;
23
- showNavigationAlert(templateId: string, alert: NitroNavigationAlert): NavigationAlertCallbacks;
23
+ showNavigationAlert(templateId: string, alert: NitroNavigationAlert): void;
24
+ updateNavigationAlert(
25
+ templateId: string,
26
+ navigationAlertId: number,
27
+ title: AutoText,
28
+ subtitle?: AutoText
29
+ ): void;
30
+ dismissNavigationAlert(templateId: string, navigationAlertId: number): void;
24
31
  showTripSelector(
25
32
  templateId: string,
26
33
  trips: Array<TripsConfig>,
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { AppRegistry, Platform } from 'react-native';
3
3
  import { NitroModules } from 'react-native-nitro-modules';
4
- import { type AutoText, type CleanupCallback, HybridAutoPlay } from '..';
4
+ import { type AutoText, HybridAutoPlay } from '..';
5
5
  import { MapTemplateProvider } from '../components/MapTemplateContext';
6
6
  import { SafeAreaInsetsProvider } from '../components/SafeAreaInsetsContext';
7
7
  import type { MapTemplate as NitroMapTemplate } from '../specs/MapTemplate.nitro';
@@ -32,10 +32,6 @@ export type Point = { x: number; y: number };
32
32
  export type VisibleTravelEstimate = 'first' | 'last';
33
33
 
34
34
  export type HeaderActionsAndroidMap<T> = Array<ActionButtonAndroid<T>> & { length: 1 | 2 | 3 | 4 };
35
- export interface NavigationAlertCallbacks {
36
- dismiss: CleanupCallback;
37
- update: (title: AutoText, subtitle?: AutoText) => void;
38
- }
39
35
 
40
36
  export interface NitroMapTemplateConfig extends TemplateConfig, NitroBaseMapTemplateConfig {
41
37
  /**
@@ -219,6 +215,14 @@ export class MapTemplate extends Template<MapTemplateConfig, MapTemplateConfig['
219
215
  return HybridMapTemplate.showNavigationAlert(this.id, NitroAlertUtil.convert(alert));
220
216
  }
221
217
 
218
+ public updateAlert(alertId: number, title: AutoText, subtitle?: AutoText) {
219
+ HybridMapTemplate.updateNavigationAlert(this.id, alertId, title, subtitle);
220
+ }
221
+
222
+ public dismissAlert(alertId: number) {
223
+ HybridMapTemplate.dismissNavigationAlert(this.id, alertId);
224
+ }
225
+
222
226
  /**
223
227
  * @namespace Android brings up a custom trip selector mimicking the CarPlay trip selector as close as possible
224
228
  * @namespace iOS brings up the stock CarPlay trip selector
@@ -1,82 +0,0 @@
1
- ///
2
- /// JFunc_void_AutoText_std__optional_AutoText_.hpp
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
6
- ///
7
-
8
- #pragma once
9
-
10
- #include <fbjni/fbjni.h>
11
- #include <functional>
12
-
13
- #include "AutoText.hpp"
14
- #include <optional>
15
- #include <functional>
16
- #include "JAutoText.hpp"
17
- #include <string>
18
- #include "Distance.hpp"
19
- #include "JDistance.hpp"
20
- #include "DistanceUnits.hpp"
21
- #include "JDistanceUnits.hpp"
22
-
23
- namespace margelo::nitro::swe::iternio::reactnativeautoplay {
24
-
25
- using namespace facebook;
26
-
27
- /**
28
- * Represents the Java/Kotlin callback `(title: AutoText, subtitle: AutoText?) -> Unit`.
29
- * This can be passed around between C++ and Java/Kotlin.
30
- */
31
- struct JFunc_void_AutoText_std__optional_AutoText_: public jni::JavaClass<JFunc_void_AutoText_std__optional_AutoText_> {
32
- public:
33
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_AutoText_std__optional_AutoText_;";
34
-
35
- public:
36
- /**
37
- * Invokes the function this `JFunc_void_AutoText_std__optional_AutoText_` instance holds through JNI.
38
- */
39
- void invoke(const AutoText& title, const std::optional<AutoText>& subtitle) const {
40
- static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JAutoText> /* title */, jni::alias_ref<JAutoText> /* subtitle */)>("invoke");
41
- method(self(), JAutoText::fromCpp(title), subtitle.has_value() ? JAutoText::fromCpp(subtitle.value()) : nullptr);
42
- }
43
- };
44
-
45
- /**
46
- * An implementation of Func_void_AutoText_std__optional_AutoText_ that is backed by a C++ implementation (using `std::function<...>`)
47
- */
48
- struct JFunc_void_AutoText_std__optional_AutoText__cxx final: public jni::HybridClass<JFunc_void_AutoText_std__optional_AutoText__cxx, JFunc_void_AutoText_std__optional_AutoText_> {
49
- public:
50
- static jni::local_ref<JFunc_void_AutoText_std__optional_AutoText_::javaobject> fromCpp(const std::function<void(const AutoText& /* title */, const std::optional<AutoText>& /* subtitle */)>& func) {
51
- return JFunc_void_AutoText_std__optional_AutoText__cxx::newObjectCxxArgs(func);
52
- }
53
-
54
- public:
55
- /**
56
- * Invokes the C++ `std::function<...>` this `JFunc_void_AutoText_std__optional_AutoText__cxx` instance holds.
57
- */
58
- void invoke_cxx(jni::alias_ref<JAutoText> title, jni::alias_ref<JAutoText> subtitle) {
59
- _func(title->toCpp(), subtitle != nullptr ? std::make_optional(subtitle->toCpp()) : std::nullopt);
60
- }
61
-
62
- public:
63
- [[nodiscard]]
64
- inline const std::function<void(const AutoText& /* title */, const std::optional<AutoText>& /* subtitle */)>& getFunction() const {
65
- return _func;
66
- }
67
-
68
- public:
69
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_AutoText_std__optional_AutoText__cxx;";
70
- static void registerNatives() {
71
- registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_AutoText_std__optional_AutoText__cxx::invoke_cxx)});
72
- }
73
-
74
- private:
75
- explicit JFunc_void_AutoText_std__optional_AutoText__cxx(const std::function<void(const AutoText& /* title */, const std::optional<AutoText>& /* subtitle */)>& func): _func(func) { }
76
-
77
- private:
78
- friend HybridBase;
79
- std::function<void(const AutoText& /* title */, const std::optional<AutoText>& /* subtitle */)> _func;
80
- };
81
-
82
- } // namespace margelo::nitro::swe::iternio::reactnativeautoplay
@@ -1,91 +0,0 @@
1
- ///
2
- /// JNavigationAlertCallbacks.hpp
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
6
- ///
7
-
8
- #pragma once
9
-
10
- #include <fbjni/fbjni.h>
11
- #include "NavigationAlertCallbacks.hpp"
12
-
13
- #include "AutoText.hpp"
14
- #include "Distance.hpp"
15
- #include "DistanceUnits.hpp"
16
- #include "JAutoText.hpp"
17
- #include "JDistance.hpp"
18
- #include "JDistanceUnits.hpp"
19
- #include "JFunc_void.hpp"
20
- #include "JFunc_void_AutoText_std__optional_AutoText_.hpp"
21
- #include <functional>
22
- #include <optional>
23
- #include <string>
24
-
25
- namespace margelo::nitro::swe::iternio::reactnativeautoplay {
26
-
27
- using namespace facebook;
28
-
29
- /**
30
- * The C++ JNI bridge between the C++ struct "NavigationAlertCallbacks" and the the Kotlin data class "NavigationAlertCallbacks".
31
- */
32
- struct JNavigationAlertCallbacks final: public jni::JavaClass<JNavigationAlertCallbacks> {
33
- public:
34
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/swe/iternio/reactnativeautoplay/NavigationAlertCallbacks;";
35
-
36
- public:
37
- /**
38
- * Convert this Java/Kotlin-based struct to the C++ struct NavigationAlertCallbacks by copying all values to C++.
39
- */
40
- [[maybe_unused]]
41
- [[nodiscard]]
42
- NavigationAlertCallbacks toCpp() const {
43
- static const auto clazz = javaClassStatic();
44
- static const auto fieldDismiss = clazz->getField<JFunc_void::javaobject>("dismiss");
45
- jni::local_ref<JFunc_void::javaobject> dismiss = this->getFieldValue(fieldDismiss);
46
- static const auto fieldUpdate = clazz->getField<JFunc_void_AutoText_std__optional_AutoText_::javaobject>("update");
47
- jni::local_ref<JFunc_void_AutoText_std__optional_AutoText_::javaobject> update = this->getFieldValue(fieldUpdate);
48
- return NavigationAlertCallbacks(
49
- [&]() -> std::function<void()> {
50
- if (dismiss->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] {
51
- auto downcast = jni::static_ref_cast<JFunc_void_cxx::javaobject>(dismiss);
52
- return downcast->cthis()->getFunction();
53
- } else {
54
- auto dismissRef = jni::make_global(dismiss);
55
- return [dismissRef]() -> void {
56
- return dismissRef->invoke();
57
- };
58
- }
59
- }(),
60
- [&]() -> std::function<void(const AutoText& /* title */, const std::optional<AutoText>& /* subtitle */)> {
61
- if (update->isInstanceOf(JFunc_void_AutoText_std__optional_AutoText__cxx::javaClassStatic())) [[likely]] {
62
- auto downcast = jni::static_ref_cast<JFunc_void_AutoText_std__optional_AutoText__cxx::javaobject>(update);
63
- return downcast->cthis()->getFunction();
64
- } else {
65
- auto updateRef = jni::make_global(update);
66
- return [updateRef](AutoText title, std::optional<AutoText> subtitle) -> void {
67
- return updateRef->invoke(title,subtitle);
68
- };
69
- }
70
- }()
71
- );
72
- }
73
-
74
- public:
75
- /**
76
- * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
77
- */
78
- [[maybe_unused]]
79
- static jni::local_ref<JNavigationAlertCallbacks::javaobject> fromCpp(const NavigationAlertCallbacks& value) {
80
- using JSignature = JNavigationAlertCallbacks(jni::alias_ref<JFunc_void::javaobject>, jni::alias_ref<JFunc_void_AutoText_std__optional_AutoText_::javaobject>);
81
- static const auto clazz = javaClassStatic();
82
- static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
83
- return create(
84
- clazz,
85
- JFunc_void_cxx::fromCpp(value.dismiss),
86
- JFunc_void_AutoText_std__optional_AutoText__cxx::fromCpp(value.update)
87
- );
88
- }
89
- };
90
-
91
- } // namespace margelo::nitro::swe::iternio::reactnativeautoplay
@@ -1,80 +0,0 @@
1
- ///
2
- /// Func_void_AutoText_std__optional_AutoText_.kt
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
6
- ///
7
-
8
- package com.margelo.nitro.swe.iternio.reactnativeautoplay
9
-
10
- import androidx.annotation.Keep
11
- import com.facebook.jni.HybridData
12
- import com.facebook.proguard.annotations.DoNotStrip
13
- import dalvik.annotation.optimization.FastNative
14
-
15
-
16
- /**
17
- * Represents the JavaScript callback `(title: struct, subtitle: optional) => void`.
18
- * This can be either implemented in C++ (in which case it might be a callback coming from JS),
19
- * or in Kotlin/Java (in which case it is a native callback).
20
- */
21
- @DoNotStrip
22
- @Keep
23
- @Suppress("ClassName", "RedundantUnitReturnType")
24
- fun interface Func_void_AutoText_std__optional_AutoText_: (AutoText, AutoText?) -> Unit {
25
- /**
26
- * Call the given JS callback.
27
- * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
28
- */
29
- @DoNotStrip
30
- @Keep
31
- override fun invoke(title: AutoText, subtitle: AutoText?): Unit
32
- }
33
-
34
- /**
35
- * Represents the JavaScript callback `(title: struct, subtitle: optional) => void`.
36
- * This is implemented in C++, via a `std::function<...>`.
37
- * The callback might be coming from JS.
38
- */
39
- @DoNotStrip
40
- @Keep
41
- @Suppress(
42
- "KotlinJniMissingFunction", "unused",
43
- "RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
44
- "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
45
- )
46
- class Func_void_AutoText_std__optional_AutoText__cxx: Func_void_AutoText_std__optional_AutoText_ {
47
- @DoNotStrip
48
- @Keep
49
- private val mHybridData: HybridData
50
-
51
- @DoNotStrip
52
- @Keep
53
- private constructor(hybridData: HybridData) {
54
- mHybridData = hybridData
55
- }
56
-
57
- @DoNotStrip
58
- @Keep
59
- override fun invoke(title: AutoText, subtitle: AutoText?): Unit
60
- = invoke_cxx(title,subtitle)
61
-
62
- @FastNative
63
- private external fun invoke_cxx(title: AutoText, subtitle: AutoText?): Unit
64
- }
65
-
66
- /**
67
- * Represents the JavaScript callback `(title: struct, subtitle: optional) => void`.
68
- * This is implemented in Java/Kotlin, via a `(AutoText, AutoText?) -> Unit`.
69
- * The callback is always coming from native.
70
- */
71
- @DoNotStrip
72
- @Keep
73
- @Suppress("ClassName", "RedundantUnitReturnType", "unused")
74
- class Func_void_AutoText_std__optional_AutoText__java(private val function: (AutoText, AutoText?) -> Unit): Func_void_AutoText_std__optional_AutoText_ {
75
- @DoNotStrip
76
- @Keep
77
- override fun invoke(title: AutoText, subtitle: AutoText?): Unit {
78
- return this.function(title, subtitle)
79
- }
80
- }