@complexify/expo-mapbox-navigation 1.0.6 → 1.0.8
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.
@@ -137,71 +137,6 @@ public class ExpoMapboxNavigationModule: Module {
|
|
137
137
|
view.controller.setBottomBannerArrivalTimeTextColor(hexColor: hexColor)
|
138
138
|
}
|
139
139
|
}
|
140
|
-
|
141
|
-
// Information Stack
|
142
|
-
Prop("informationStackBackgroundColor") { (view: ExpoMapboxNavigationView, color: String?) in
|
143
|
-
if let hexColor = color {
|
144
|
-
view.controller.setInformationStackBackgroundColor(hexColor: hexColor)
|
145
|
-
}
|
146
|
-
}
|
147
|
-
|
148
|
-
Prop("informationStackTextColor") { (view: ExpoMapboxNavigationView, color: String?) in
|
149
|
-
if let hexColor = color {
|
150
|
-
view.controller.setInformationStackTextColor(hexColor: hexColor)
|
151
|
-
}
|
152
|
-
}
|
153
|
-
|
154
|
-
// Resume Button
|
155
|
-
Prop("resumeButtonBackgroundColor") { (view: ExpoMapboxNavigationView, color: String?) in
|
156
|
-
if let hexColor = color {
|
157
|
-
view.controller.setResumeButtonBackgroundColor(hexColor: hexColor)
|
158
|
-
}
|
159
|
-
}
|
160
|
-
|
161
|
-
Prop("resumeButtonTextColor") { (view: ExpoMapboxNavigationView, color: String?) in
|
162
|
-
if let hexColor = color {
|
163
|
-
view.controller.setResumeButtonTextColor(hexColor: hexColor)
|
164
|
-
}
|
165
|
-
}
|
166
|
-
|
167
|
-
// Speed Limit
|
168
|
-
Prop("speedLimitBackgroundColor") { (view: ExpoMapboxNavigationView, color: String?) in
|
169
|
-
if let hexColor = color {
|
170
|
-
view.controller.setSpeedLimitBackgroundColor(hexColor: hexColor)
|
171
|
-
}
|
172
|
-
}
|
173
|
-
|
174
|
-
Prop("speedLimitTextColor") { (view: ExpoMapboxNavigationView, color: String?) in
|
175
|
-
if let hexColor = color {
|
176
|
-
view.controller.setSpeedLimitTextColor(hexColor: hexColor)
|
177
|
-
}
|
178
|
-
}
|
179
|
-
|
180
|
-
// Floating Stack
|
181
|
-
Prop("floatingStackBackgroundColor") { (view: ExpoMapboxNavigationView, color: String?) in
|
182
|
-
if let hexColor = color {
|
183
|
-
view.controller.setFloatingStackBackgroundColor(hexColor: hexColor)
|
184
|
-
}
|
185
|
-
}
|
186
|
-
|
187
|
-
Prop("floatingButtonsBackgroundColor") { (view: ExpoMapboxNavigationView, color: String?) in
|
188
|
-
if let hexColor = color {
|
189
|
-
view.controller.setFloatingButtonsBackgroundColor(hexColor: hexColor)
|
190
|
-
}
|
191
|
-
}
|
192
|
-
|
193
|
-
// Way Name View
|
194
|
-
Prop("wayNameViewBackgroundColor") { (view: ExpoMapboxNavigationView, color: String?) in
|
195
|
-
if let hexColor = color {
|
196
|
-
view.controller.setWayNameViewBackgroundColor(hexColor: hexColor)
|
197
|
-
}
|
198
|
-
}
|
199
|
-
|
200
|
-
Prop("wayNameViewTextColor") { (view: ExpoMapboxNavigationView, color: String?) in
|
201
|
-
if let hexColor = color {
|
202
|
-
view.controller.setWayNameViewTextColor(hexColor: hexColor)
|
203
|
-
}
|
204
|
-
}
|
205
140
|
}
|
206
141
|
}
|
207
|
-
}
|
142
|
+
}
|
@@ -73,27 +73,16 @@ class ExpoMapboxNavigationViewController: UIViewController {
|
|
73
73
|
var currentTraversedRouteColor: UIColor?
|
74
74
|
var currentManeuverArrowColor: UIColor?
|
75
75
|
|
76
|
-
var
|
77
|
-
var
|
78
|
-
var
|
79
|
-
var
|
80
|
-
var
|
81
|
-
|
82
|
-
var
|
83
|
-
var
|
84
|
-
var
|
85
|
-
var
|
86
|
-
|
87
|
-
var informationStackBackgroundColor: UIColor?
|
88
|
-
var informationStackTextColor: UIColor?
|
89
|
-
var resumeButtonBackgroundColor: UIColor?
|
90
|
-
var resumeButtonTextColor: UIColor?
|
91
|
-
var speedLimitBackgroundColor: UIColor?
|
92
|
-
var speedLimitTextColor: UIColor?
|
93
|
-
var floatingStackBackgroundColor: UIColor?
|
94
|
-
var floatingButtonsBackgroundColor: UIColor?
|
95
|
-
var wayNameViewBackgroundColor: UIColor?
|
96
|
-
var wayNameViewTextColor: UIColor?
|
76
|
+
var currentTopBannerBackgroundColor: UIColor?
|
77
|
+
var currentTopBannerPrimaryTextColor: UIColor?
|
78
|
+
var currentTopBannerSecondaryTextColor: UIColor?
|
79
|
+
var currentTopBannerDistanceTextColor: UIColor?
|
80
|
+
var currentTopBannerSeparatorColor: UIColor?
|
81
|
+
|
82
|
+
var currentBottomBannerBackgroundColor: UIColor?
|
83
|
+
var currentBottomBannerTimeRemainingTextColor: UIColor?
|
84
|
+
var currentBottomBannerDistanceRemainingTextColor: UIColor?
|
85
|
+
var currentBottomBannerArrivalTimeTextColor: UIColor?
|
97
86
|
|
98
87
|
init() {
|
99
88
|
super.init(nibName: nil, bundle: nil)
|
@@ -235,98 +224,39 @@ class ExpoMapboxNavigationViewController: UIViewController {
|
|
235
224
|
}
|
236
225
|
|
237
226
|
func setTopBannerBackgroundColor(hexColor: String) {
|
238
|
-
|
239
|
-
update()
|
227
|
+
currentTopBannerBackgroundColor = UIColor(hex: hexColor)
|
240
228
|
}
|
241
229
|
|
242
230
|
func setTopBannerPrimaryTextColor(hexColor: String) {
|
243
|
-
|
244
|
-
update()
|
231
|
+
currentTopBannerPrimaryTextColor = UIColor(hex: hexColor)
|
245
232
|
}
|
246
233
|
|
247
234
|
func setTopBannerSecondaryTextColor(hexColor: String) {
|
248
|
-
|
249
|
-
update()
|
235
|
+
currentTopBannerSecondaryTextColor = UIColor(hex: hexColor)
|
250
236
|
}
|
251
237
|
|
252
238
|
func setTopBannerDistanceTextColor(hexColor: String) {
|
253
|
-
|
254
|
-
update()
|
239
|
+
currentTopBannerDistanceTextColor = UIColor(hex: hexColor)
|
255
240
|
}
|
256
241
|
|
257
242
|
func setTopBannerSeparatorColor(hexColor: String) {
|
258
|
-
|
259
|
-
update()
|
243
|
+
currentTopBannerSeparatorColor = UIColor(hex: hexColor)
|
260
244
|
}
|
261
245
|
|
262
246
|
func setBottomBannerBackgroundColor(hexColor: String) {
|
263
|
-
|
264
|
-
update()
|
247
|
+
currentBottomBannerBackgroundColor = UIColor(hex: hexColor)
|
265
248
|
}
|
266
249
|
|
267
250
|
func setBottomBannerTimeRemainingTextColor(hexColor: String) {
|
268
|
-
|
269
|
-
update()
|
251
|
+
currentBottomBannerTimeRemainingTextColor = UIColor(hex: hexColor)
|
270
252
|
}
|
271
253
|
|
272
254
|
func setBottomBannerDistanceRemainingTextColor(hexColor: String) {
|
273
|
-
|
274
|
-
update()
|
255
|
+
currentBottomBannerDistanceRemainingTextColor = UIColor(hex: hexColor)
|
275
256
|
}
|
276
257
|
|
277
258
|
func setBottomBannerArrivalTimeTextColor(hexColor: String) {
|
278
|
-
|
279
|
-
update()
|
280
|
-
}
|
281
|
-
|
282
|
-
func setInformationStackBackgroundColor(hexColor: String) {
|
283
|
-
informationStackBackgroundColor = UIColor(hex: hexColor)
|
284
|
-
update()
|
285
|
-
}
|
286
|
-
|
287
|
-
func setInformationStackTextColor(hexColor: String) {
|
288
|
-
informationStackTextColor = UIColor(hex: hexColor)
|
289
|
-
update()
|
290
|
-
}
|
291
|
-
|
292
|
-
func setResumeButtonBackgroundColor(hexColor: String) {
|
293
|
-
resumeButtonBackgroundColor = UIColor(hex: hexColor)
|
294
|
-
update()
|
295
|
-
}
|
296
|
-
|
297
|
-
func setResumeButtonTextColor(hexColor: String) {
|
298
|
-
resumeButtonTextColor = UIColor(hex: hexColor)
|
299
|
-
update()
|
300
|
-
}
|
301
|
-
|
302
|
-
func setSpeedLimitBackgroundColor(hexColor: String) {
|
303
|
-
speedLimitBackgroundColor = UIColor(hex: hexColor)
|
304
|
-
update()
|
305
|
-
}
|
306
|
-
|
307
|
-
func setSpeedLimitTextColor(hexColor: String) {
|
308
|
-
speedLimitTextColor = UIColor(hex: hexColor)
|
309
|
-
update()
|
310
|
-
}
|
311
|
-
|
312
|
-
func setFloatingStackBackgroundColor(hexColor: String) {
|
313
|
-
floatingStackBackgroundColor = UIColor(hex: hexColor)
|
314
|
-
update()
|
315
|
-
}
|
316
|
-
|
317
|
-
func setFloatingButtonsBackgroundColor(hexColor: String) {
|
318
|
-
floatingButtonsBackgroundColor = UIColor(hex: hexColor)
|
319
|
-
update()
|
320
|
-
}
|
321
|
-
|
322
|
-
func setWayNameViewBackgroundColor(hexColor: String) {
|
323
|
-
wayNameViewBackgroundColor = UIColor(hex: hexColor)
|
324
|
-
update()
|
325
|
-
}
|
326
|
-
|
327
|
-
func setWayNameViewTextColor(hexColor: String) {
|
328
|
-
wayNameViewTextColor = UIColor(hex: hexColor)
|
329
|
-
update()
|
259
|
+
currentBottomBannerArrivalTimeTextColor = UIColor(hex: hexColor)
|
330
260
|
}
|
331
261
|
|
332
262
|
func update(){
|
@@ -392,28 +322,53 @@ class ExpoMapboxNavigationViewController: UIViewController {
|
|
392
322
|
onCancelNavigation?()
|
393
323
|
}
|
394
324
|
|
395
|
-
func onRoutesCalculated(navigationRoutes: NavigationRoutes)
|
325
|
+
func onRoutesCalculated(navigationRoutes: NavigationRoutes){
|
396
326
|
onRoutesLoaded?()
|
397
327
|
|
398
328
|
let topBanner = TopBannerViewController()
|
399
|
-
topBanner.view.backgroundColor = topBannerBackgroundColor ?? UIColor(hex: "#FFFFFF")
|
400
|
-
topBanner.instructionsBannerView.backgroundColor = topBannerBackgroundColor ?? UIColor(hex: "#FFFFFF")
|
401
329
|
topBanner.instructionsBannerView.distanceFormatter.locale = currentLocale
|
330
|
+
|
331
|
+
// Apply top banner colors
|
332
|
+
if let backgroundColor = currentTopBannerBackgroundColor {
|
333
|
+
topBanner.view.backgroundColor = backgroundColor
|
334
|
+
}
|
335
|
+
if let primaryTextColor = currentTopBannerPrimaryTextColor {
|
336
|
+
topBanner.instructionsBannerView.primaryLabel.textColor = primaryTextColor
|
337
|
+
}
|
338
|
+
if let secondaryTextColor = currentTopBannerSecondaryTextColor {
|
339
|
+
topBanner.instructionsBannerView.secondaryLabel.textColor = secondaryTextColor
|
340
|
+
}
|
341
|
+
if let distanceTextColor = currentTopBannerDistanceTextColor {
|
342
|
+
topBanner.instructionsBannerView.distanceLabel.textColor = distanceTextColor
|
343
|
+
}
|
344
|
+
if let separatorColor = currentTopBannerSeparatorColor {
|
345
|
+
topBanner.instructionsBannerView.separatorView.backgroundColor = separatorColor
|
346
|
+
}
|
402
347
|
|
403
348
|
let bottomBanner = BottomBannerViewController()
|
404
|
-
bottomBanner.view.backgroundColor = bottomBannerBackgroundColor ?? UIColor(hex: "#FFFFFF")
|
405
349
|
bottomBanner.distanceFormatter.locale = currentLocale
|
406
350
|
bottomBanner.dateFormatter.locale = currentLocale
|
407
351
|
|
352
|
+
// Apply bottom banner colors
|
353
|
+
if let backgroundColor = currentBottomBannerBackgroundColor {
|
354
|
+
bottomBanner.view.backgroundColor = backgroundColor
|
355
|
+
}
|
356
|
+
if let timeRemainingColor = currentBottomBannerTimeRemainingTextColor {
|
357
|
+
bottomBanner.timeRemainingLabel.textColor = timeRemainingColor
|
358
|
+
}
|
359
|
+
if let distanceRemainingColor = currentBottomBannerDistanceRemainingTextColor {
|
360
|
+
bottomBanner.distanceRemainingLabel.textColor = distanceRemainingColor
|
361
|
+
}
|
362
|
+
if let arrivalTimeColor = currentBottomBannerArrivalTimeTextColor {
|
363
|
+
bottomBanner.arrivalTimeLabel.textColor = arrivalTimeColor
|
364
|
+
}
|
365
|
+
|
408
366
|
let navigationOptions = NavigationOptions(
|
409
367
|
mapboxNavigation: self.mapboxNavigation!,
|
410
368
|
voiceController: ExpoMapboxNavigationViewController.navigationProvider.routeVoiceController,
|
411
369
|
eventsManager: ExpoMapboxNavigationViewController.navigationProvider.eventsManager(),
|
412
|
-
styles: nil,
|
413
370
|
topBanner: topBanner,
|
414
|
-
bottomBanner: bottomBanner
|
415
|
-
predictiveCacheManager: nil,
|
416
|
-
navigationMapView: nil
|
371
|
+
bottomBanner: bottomBanner
|
417
372
|
)
|
418
373
|
|
419
374
|
let navigationViewController = NavigationViewController(
|
@@ -421,17 +376,8 @@ class ExpoMapboxNavigationViewController: UIViewController {
|
|
421
376
|
navigationOptions: navigationOptions
|
422
377
|
)
|
423
378
|
|
424
|
-
topBanner.instructionsBannerView.primaryLabel.textColor = topBannerPrimaryTextColor ?? UIColor(hex: "#000000")
|
425
|
-
topBanner.instructionsBannerView.secondaryLabel.textColor = topBannerSecondaryTextColor ?? UIColor(hex: "#666666")
|
426
|
-
topBanner.instructionsBannerView.distanceLabel.textColor = topBannerDistanceTextColor ?? UIColor(hex: "#666666")
|
427
|
-
topBanner.instructionsBannerView.separatorView.backgroundColor = topBannerSeparatorColor ?? UIColor(hex: "#EEEEEE")
|
428
|
-
|
429
|
-
bottomBanner.timeRemainingLabel.textColor = bottomBannerTimeRemainingTextColor ?? UIColor(hex: "#000000")
|
430
|
-
bottomBanner.distanceRemainingLabel.textColor = bottomBannerDistanceRemainingTextColor ?? UIColor(hex: "#666666")
|
431
|
-
bottomBanner.arrivalTimeLabel.textColor = bottomBannerArrivalTimeTextColor ?? UIColor(hex: "#666666")
|
432
|
-
|
433
379
|
let navigationMapView = navigationViewController.navigationMapView
|
434
|
-
navigationMapView
|
380
|
+
navigationMapView!.puckType = .puck2D(.navigationDefault)
|
435
381
|
|
436
382
|
let style = currentMapStyle != nil ? StyleURI(rawValue: currentMapStyle!) : StyleURI.streets
|
437
383
|
navigationMapView!.mapView.mapboxMap.loadStyle(style!, completion: { _ in
|
@@ -440,9 +386,10 @@ class ExpoMapboxNavigationViewController: UIViewController {
|
|
440
386
|
try navigationMapView!.mapView.mapboxMap.localizeLabels(into: self.currentLocale)
|
441
387
|
} catch {}
|
442
388
|
})
|
389
|
+
|
443
390
|
|
444
|
-
let cancelButton = navigationView.bottomBannerContainerView.findViews(subclassOf: CancelButton.self)
|
445
|
-
cancelButton
|
391
|
+
let cancelButton = navigationViewController.navigationView.bottomBannerContainerView.findViews(subclassOf: CancelButton.self)[0]
|
392
|
+
cancelButton.addTarget(self, action: #selector(cancelButtonClicked), for: .touchUpInside)
|
446
393
|
|
447
394
|
navigationViewController.delegate = self
|
448
395
|
addChild(navigationViewController)
|
@@ -454,9 +401,9 @@ class ExpoMapboxNavigationViewController: UIViewController {
|
|
454
401
|
navigationViewController.view.topAnchor.constraint(equalTo: view.topAnchor, constant: 0),
|
455
402
|
navigationViewController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 0),
|
456
403
|
])
|
457
|
-
|
404
|
+
didMove(toParent: self)
|
458
405
|
mapboxNavigation!.tripSession().startActiveGuidance(with: navigationRoutes, startLegIndex: 0)
|
459
|
-
|
406
|
+
|
460
407
|
// Apply custom colors if set
|
461
408
|
if let routeColor = currentRouteColor {
|
462
409
|
navigationMapView?.routeColor = routeColor
|
@@ -476,41 +423,6 @@ class ExpoMapboxNavigationViewController: UIViewController {
|
|
476
423
|
if let arrowColor = currentManeuverArrowColor {
|
477
424
|
navigationMapView?.maneuverArrowColor = arrowColor
|
478
425
|
}
|
479
|
-
|
480
|
-
// 2. Information Stack
|
481
|
-
let infoStack = navigationViewController.navigationView.informationStackView
|
482
|
-
infoStack.backgroundColor = informationStackBackgroundColor ?? UIColor(hex: "#FFFFFF")
|
483
|
-
for view in infoStack.arrangedSubviews {
|
484
|
-
if let label = view as? UILabel {
|
485
|
-
label.textColor = informationStackTextColor ?? UIColor(hex: "#000000")
|
486
|
-
}
|
487
|
-
}
|
488
|
-
|
489
|
-
// 4. Resume Button
|
490
|
-
let resumeButton = navigationViewController.navigationView.resumeButton
|
491
|
-
resumeButton.backgroundColor = resumeButtonBackgroundColor ?? UIColor(hex: "#FFFFFF")
|
492
|
-
resumeButton.setTitleColor(resumeButtonTextColor ?? UIColor(hex: "#000000"), for: UIControl.State.normal)
|
493
|
-
|
494
|
-
// 5. Speed Limit View
|
495
|
-
let speedLimitView = navigationViewController.navigationView.speedLimitView
|
496
|
-
speedLimitView.backgroundColor = speedLimitBackgroundColor ?? UIColor(hex: "#FFFFFF")
|
497
|
-
if let speedLabel = speedLimitView.subviews.first as? UILabel {
|
498
|
-
speedLabel.textColor = speedLimitTextColor ?? UIColor(hex: "#000000")
|
499
|
-
}
|
500
|
-
|
501
|
-
// 6. Floating Stack
|
502
|
-
let floatingStack = navigationViewController.navigationView.floatingStackView
|
503
|
-
floatingStack.backgroundColor = floatingStackBackgroundColor ?? UIColor(hex: "#FFFFFF")
|
504
|
-
for button in floatingStack.arrangedSubviews {
|
505
|
-
if let floatingButton = button as? UIButton {
|
506
|
-
floatingButton.backgroundColor = floatingButtonsBackgroundColor ?? UIColor(hex: "#FFFFFF")
|
507
|
-
}
|
508
|
-
}
|
509
|
-
|
510
|
-
// 8. Way Name Label
|
511
|
-
let wayNameView = navigationViewController.navigationView.wayNameView
|
512
|
-
wayNameView.backgroundColor = wayNameViewBackgroundColor ?? UIColor(hex: "#FFFFFF")
|
513
|
-
wayNameView.label.textColor = wayNameViewTextColor ?? UIColor(hex: "#000000")
|
514
426
|
}
|
515
427
|
}
|
516
428
|
extension ExpoMapboxNavigationViewController: NavigationViewControllerDelegate {
|
@@ -547,4 +459,4 @@ extension UIColor {
|
|
547
459
|
|
548
460
|
self.init(red: r, green: g, blue: b, alpha: 1.0)
|
549
461
|
}
|
550
|
-
}
|
462
|
+
}
|