@complexify/expo-mapbox-navigation 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,15 @@
|
|
1
|
-
import
|
1
|
+
import Foundation
|
2
|
+
import MapboxMaps
|
3
|
+
import MapboxNavigationUIKit
|
2
4
|
import UIKit
|
3
5
|
|
4
|
-
class
|
5
|
-
var
|
6
|
-
var
|
7
|
-
var
|
8
|
-
var
|
9
|
-
var
|
10
|
-
var
|
6
|
+
class CustomDayStyle: StandardDayStyle {
|
7
|
+
var customSpeedLimitTextColor: UIColor?
|
8
|
+
var customSpeedLimitBackgroundColor: UIColor?
|
9
|
+
var customSpeedLimitBorderColor: UIColor?
|
10
|
+
var customBottomBannerBackgroundColor: UIColor?
|
11
|
+
var customWayNameTextColor: UIColor?
|
12
|
+
var customWayNameBackgroundColor: UIColor?
|
11
13
|
|
12
14
|
required init() {
|
13
15
|
super.init()
|
@@ -17,28 +19,30 @@ class CustomNavigationStyle: DayStyle {
|
|
17
19
|
override func apply() {
|
18
20
|
super.apply()
|
19
21
|
|
22
|
+
let traitCollection = UIScreen.main.traitCollection
|
23
|
+
|
20
24
|
// Speed limit customization
|
21
|
-
if let textColor =
|
22
|
-
SpeedLimitView.appearance().textColor = textColor
|
25
|
+
if let textColor = customSpeedLimitTextColor {
|
26
|
+
SpeedLimitView.appearance(for: traitCollection).textColor = textColor
|
23
27
|
}
|
24
|
-
if let bgColor =
|
25
|
-
SpeedLimitView.appearance().signBackColor = bgColor
|
28
|
+
if let bgColor = customSpeedLimitBackgroundColor {
|
29
|
+
SpeedLimitView.appearance(for: traitCollection).signBackColor = bgColor
|
26
30
|
}
|
27
|
-
if let borderColor =
|
28
|
-
SpeedLimitView.appearance().regulatoryBorderColor = borderColor
|
31
|
+
if let borderColor = customSpeedLimitBorderColor {
|
32
|
+
SpeedLimitView.appearance(for: traitCollection).regulatoryBorderColor = borderColor
|
29
33
|
}
|
30
34
|
|
31
35
|
// Bottom banner customization
|
32
|
-
if let bottomBannerBg =
|
33
|
-
BottomBannerView.appearance().backgroundColor = bottomBannerBg
|
36
|
+
if let bottomBannerBg = customBottomBannerBackgroundColor {
|
37
|
+
BottomBannerView.appearance(for: traitCollection).backgroundColor = bottomBannerBg
|
34
38
|
}
|
35
39
|
|
36
40
|
// Way name customization
|
37
|
-
if let textColor =
|
38
|
-
WayNameView.appearance().textColor = textColor
|
41
|
+
if let textColor = customWayNameTextColor {
|
42
|
+
WayNameView.appearance(for: traitCollection).textColor = textColor
|
39
43
|
}
|
40
|
-
if let bgColor =
|
41
|
-
WayNameView.appearance().backgroundColor = bgColor.withAlphaComponent(0.8)
|
44
|
+
if let bgColor = customWayNameBackgroundColor {
|
45
|
+
WayNameView.appearance(for: traitCollection).backgroundColor = bgColor.withAlphaComponent(0.8)
|
42
46
|
}
|
43
47
|
}
|
44
|
-
}
|
48
|
+
}
|
@@ -18,7 +18,8 @@ class ExpoMapboxNavigationView: ExpoView {
|
|
18
18
|
|
19
19
|
let controller = ExpoMapboxNavigationViewController()
|
20
20
|
|
21
|
-
let
|
21
|
+
let customDayStyle = CustomDayStyle()
|
22
|
+
let customNightStyle = CustomNightStyle()
|
22
23
|
|
23
24
|
required init(appContext: AppContext? = nil) {
|
24
25
|
super.init(appContext: appContext)
|
@@ -258,7 +259,7 @@ class ExpoMapboxNavigationViewController: UIViewController {
|
|
258
259
|
}
|
259
260
|
|
260
261
|
func setBottomBannerBackgroundColor(hexColor: String) {
|
261
|
-
|
262
|
+
customDayStyle.customBottomBannerBackgroundColor = UIColor(hex: hexColor)
|
262
263
|
update()
|
263
264
|
}
|
264
265
|
|
@@ -298,22 +299,22 @@ class ExpoMapboxNavigationViewController: UIViewController {
|
|
298
299
|
}
|
299
300
|
|
300
301
|
func setSpeedLimitBackgroundColor(hexColor: String) {
|
301
|
-
|
302
|
+
customDayStyle.customSpeedLimitBackgroundColor = UIColor(hex: hexColor)
|
302
303
|
update()
|
303
304
|
}
|
304
305
|
|
305
306
|
func setSpeedLimitTextColor(hexColor: String) {
|
306
|
-
|
307
|
+
customDayStyle.customSpeedLimitTextColor = UIColor(hex: hexColor)
|
307
308
|
update()
|
308
309
|
}
|
309
310
|
|
310
311
|
func setWayNameViewBackgroundColor(hexColor: String) {
|
311
|
-
|
312
|
+
customDayStyle.customWayNameBackgroundColor = UIColor(hex: hexColor)
|
312
313
|
update()
|
313
314
|
}
|
314
315
|
|
315
316
|
func setWayNameViewTextColor(hexColor: String) {
|
316
|
-
|
317
|
+
customDayStyle.customWayNameTextColor = UIColor(hex: hexColor)
|
317
318
|
update()
|
318
319
|
}
|
319
320
|
|
@@ -328,7 +329,7 @@ class ExpoMapboxNavigationViewController: UIViewController {
|
|
328
329
|
}
|
329
330
|
|
330
331
|
func setSpeedLimitBorderColor(hexColor: String) {
|
331
|
-
|
332
|
+
customDayStyle.customSpeedLimitBorderColor = UIColor(hex: hexColor)
|
332
333
|
update()
|
333
334
|
}
|
334
335
|
|
@@ -437,7 +438,7 @@ class ExpoMapboxNavigationViewController: UIViewController {
|
|
437
438
|
}
|
438
439
|
|
439
440
|
let navigationOptions = NavigationOptions(
|
440
|
-
styles: [
|
441
|
+
styles: [customDayStyle, customNightStyle],
|
441
442
|
mapboxNavigation: self.mapboxNavigation!,
|
442
443
|
voiceController: ExpoMapboxNavigationViewController.navigationProvider.routeVoiceController,
|
443
444
|
eventsManager: ExpoMapboxNavigationViewController.navigationProvider.eventsManager(),
|