From 3e3f7108b7a48c0d51cdf70894de68f30d2f38ca Mon Sep 17 00:00:00 2001 From: Fredrik Karlsson Date: Fri, 30 Mar 2018 01:40:30 +0200 Subject: [PATCH 1/4] Draw slight left/right lanes --- MapboxNavigation/LaneView.swift | 53 +++++++++++++++--- MapboxNavigationTests/LaneTests.swift | 11 +++- .../testSlightRight_iPhone11_2_0x0@3x.png | Bin 0 -> 1562 bytes 3 files changed, 54 insertions(+), 10 deletions(-) create mode 100644 MapboxNavigationTests/ReferenceImages_64/MapboxNavigationTests.LaneTests/testSlightRight_iPhone11_2_0x0@3x.png diff --git a/MapboxNavigation/LaneView.swift b/MapboxNavigation/LaneView.swift index 6cdd46c18c7..5b3aa1028e1 100644 --- a/MapboxNavigation/LaneView.swift +++ b/MapboxNavigation/LaneView.swift @@ -39,12 +39,20 @@ open class LaneView: UIView { if lane.indications.isSuperset(of: [.straightAhead, .sharpRight]) || lane.indications.isSuperset(of: [.straightAhead, .right]) || lane.indications.isSuperset(of: [.straightAhead, .slightRight]) { flipLane = false if !isValid { - LanesStyleKit.drawLane_straight_right(primaryColor: appropriatePrimaryColor) + if lane.indications == .slightRight { + LanesStyleKit.drawLane_slight_right(primaryColor: appropriatePrimaryColor) + } else { + LanesStyleKit.drawLane_straight_right(primaryColor: appropriatePrimaryColor) + } alpha = invalidAlpha } else if maneuverDirection == .straightAhead { LanesStyleKit.drawLane_straight_only(primaryColor: appropriatePrimaryColor, secondaryColor: secondaryColor) } else if maneuverDirection == .sharpLeft || maneuverDirection == .left || maneuverDirection == .slightLeft { - LanesStyleKit.drawLane_right_h(primaryColor: appropriatePrimaryColor) + if lane.indications == .slightLeft { + LanesStyleKit.drawLane_slight_right(primaryColor: appropriatePrimaryColor) + } else { + LanesStyleKit.drawLane_right_h(primaryColor: appropriatePrimaryColor) + } flipLane = true } else { LanesStyleKit.drawLane_right_only(primaryColor: appropriatePrimaryColor, secondaryColor: secondaryColor) @@ -52,13 +60,21 @@ open class LaneView: UIView { } else if lane.indications.isSuperset(of: [.straightAhead, .sharpLeft]) || lane.indications.isSuperset(of: [.straightAhead, .left]) || lane.indications.isSuperset(of: [.straightAhead, .slightLeft]) { flipLane = true if !isValid { - LanesStyleKit.drawLane_straight_right(primaryColor: appropriatePrimaryColor) + if lane.indications == .slightLeft { + LanesStyleKit.drawLane_slight_right(primaryColor: appropriatePrimaryColor) + } else { + LanesStyleKit.drawLane_straight_right(primaryColor: appropriatePrimaryColor) + } + alpha = invalidAlpha } else if maneuverDirection == .straightAhead { LanesStyleKit.drawLane_straight_only(primaryColor: appropriatePrimaryColor, secondaryColor: secondaryColor) - } else if maneuverDirection == .sharpRight || maneuverDirection == .right || maneuverDirection == .slightRight { + } else if maneuverDirection == .sharpRight || maneuverDirection == .right { LanesStyleKit.drawLane_right_h(primaryColor: appropriatePrimaryColor) flipLane = false + } else if maneuverDirection == .slightRight { + LanesStyleKit.drawLane_slight_right(primaryColor: appropriatePrimaryColor) + flipLane = false } else { LanesStyleKit.drawLane_right_only(primaryColor: appropriatePrimaryColor, secondaryColor: secondaryColor) } @@ -67,20 +83,31 @@ open class LaneView: UIView { // Account for a configuation where there is no straight lane // but there are at least 2 indications. // In this situation, just draw a left/right arrow - if maneuverDirection == .sharpRight || maneuverDirection == .right || maneuverDirection == .slightRight { + if maneuverDirection == .sharpRight || maneuverDirection == .right { LanesStyleKit.drawLane_right_h(primaryColor: appropriatePrimaryColor) flipLane = false + } else if maneuverDirection == .slightRight { + LanesStyleKit.drawLane_slight_right(primaryColor: appropriatePrimaryColor) + flipLane = false } else { LanesStyleKit.drawLane_right_h(primaryColor: appropriatePrimaryColor) flipLane = true } alpha = isValid ? 1 : invalidAlpha } else if lane.indications.isSuperset(of: [.sharpRight]) || lane.indications.isSuperset(of: [.right]) || lane.indications.isSuperset(of: [.slightRight]) { - LanesStyleKit.drawLane_right_h(primaryColor: appropriatePrimaryColor) + if lane.indications == .slightRight { + LanesStyleKit.drawLane_slight_right(primaryColor: appropriatePrimaryColor) + } else { + LanesStyleKit.drawLane_right_h(primaryColor: appropriatePrimaryColor) + } flipLane = false alpha = isValid ? 1 : invalidAlpha } else if lane.indications.isSuperset(of: [.sharpLeft]) || lane.indications.isSuperset(of: [.left]) || lane.indications.isSuperset(of: [.slightLeft]) { - LanesStyleKit.drawLane_right_h(primaryColor: appropriatePrimaryColor) + if lane.indications == .slightLeft { + LanesStyleKit.drawLane_slight_right(primaryColor: appropriatePrimaryColor) + } else { + LanesStyleKit.drawLane_right_h(primaryColor: appropriatePrimaryColor) + } flipLane = true alpha = isValid ? 1 : invalidAlpha } else if lane.indications.isSuperset(of: [.straightAhead]) { @@ -95,10 +122,18 @@ open class LaneView: UIView { // If the lane indication is `none` and the maneuver modifier has a turn in it, // show the turn in the lane image. if maneuverDirection == .sharpRight || maneuverDirection == .right || maneuverDirection == .slightRight { - LanesStyleKit.drawLane_right_h(primaryColor: appropriatePrimaryColor) + if maneuverDirection == .slightRight { + LanesStyleKit.drawLane_slight_right(primaryColor: appropriatePrimaryColor) + } else { + LanesStyleKit.drawLane_right_h(primaryColor: appropriatePrimaryColor) + } flipLane = false } else if maneuverDirection == .sharpLeft || maneuverDirection == .left || maneuverDirection == .slightLeft { - LanesStyleKit.drawLane_right_h(primaryColor: appropriatePrimaryColor) + if maneuverDirection == .slightLeft { + LanesStyleKit.drawLane_slight_right(primaryColor: appropriatePrimaryColor) + } else { + LanesStyleKit.drawLane_right_h(primaryColor: appropriatePrimaryColor) + } flipLane = true } else { LanesStyleKit.drawLane_straight(primaryColor: appropriatePrimaryColor) diff --git a/MapboxNavigationTests/LaneTests.swift b/MapboxNavigationTests/LaneTests.swift index 19e65d89093..7d63a8129a5 100644 --- a/MapboxNavigationTests/LaneTests.swift +++ b/MapboxNavigationTests/LaneTests.swift @@ -1,6 +1,6 @@ import XCTest import FBSnapshotTestCase -import MapboxDirections +@testable import MapboxDirections @testable import MapboxNavigation @testable import MapboxCoreNavigation @@ -43,4 +43,13 @@ class LaneTests: FBSnapshotTestCase { func testRightNone() { assertLanes(step: steps[1]) } + + func testSlightRight() { + let view = LaneView(frame: CGRect(origin: .zero, size: CGSize(width: 30, height: 30))) + view.backgroundColor = .white + view.lane = Lane(indications: [.slightRight]) + view.maneuverDirection = .slightRight + view.isValid = true + FBSnapshotVerifyView(view) + } } diff --git a/MapboxNavigationTests/ReferenceImages_64/MapboxNavigationTests.LaneTests/testSlightRight_iPhone11_2_0x0@3x.png b/MapboxNavigationTests/ReferenceImages_64/MapboxNavigationTests.LaneTests/testSlightRight_iPhone11_2_0x0@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..ae0507e625c9ff8b0d23045553fc51cf0c54b0f1 GIT binary patch literal 1562 zcmV+#2IcvQP)Px#32;bRa{vG#H~;`4H~~eLF<<}y032yVPgDQ^00IC20000004)Fj04M+e04)Fj z04)Fj1PaMUgr)!h1J+4IK~#7F?Al8xJy9G7@avh9N2KJrKuJkS5(_DX6-l9#k`fCG z#fqH;#X{Mj6pCWwRURu+vLOkPSWqY;@_v2wo0{AF{qJM$+;h&IY39^z#+~z+^O>J> z&zu<>tRzIhCZrXs5m?ZIg1~~dpalsCYQ~Ca3tEtXpk}Oywx9(G2x`WPXbW19fS_hf z7twcjcQ`sa!ut9;rl+SdI5>!|t}Zk+HKC%S0{Qv*NJ&Y-;^HFHOJI2D&(BX>US48% zcNZ%wE0~y=Kwn=UIyyQ~Utf>X(o$q+XCpp79zj7tu-R;?K37*)=7D~Ac);xJEJj8~ z(B0jQ*49>3S68E`s0bMu8HkRKhM%9GDmb;klrJqUjVUr!rt63mM1ngmN_z2 zsOvFW*<*^b%F0Ua(Op$lrEHejzG0x{9&c=HAU8Lc8~DJ$fZP<*t>K`l_dh>Bn3|eG zVqzk5@SU97Wq@;w0u~esFp$`rY z5EmE66q@cnc_l+aFE1~1nP0E1t?_a;&h$f)83OwI`x`ASE!>dlqS3M{&!l_kkB<-3*4A=GCg_EQ1)k3O9;07gUQkw6 z#vPf~wCTwU&!pRkzQ4bRsP*W~%uJrfQ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aZU6uP literal 0 HcmV?d00001 From 064defc149c08c012bf0d847b0a4fe3e1b3e752d Mon Sep 17 00:00:00 2001 From: Bobby Sudekum Date: Mon, 2 Apr 2018 13:19:46 -0700 Subject: [PATCH 2/4] Update test --- Cartfile | 2 +- Cartfile.resolved | 2 +- MapboxNavigationTests/LaneTests.swift | 2 +- .../testSlightRight_iPhone11_3_0x0@3x.png | Bin 0 -> 1562 bytes 4 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 MapboxNavigationTests/ReferenceImages_64/MapboxNavigationTests.LaneTests/testSlightRight_iPhone11_3_0x0@3x.png diff --git a/Cartfile b/Cartfile index 279bd0f6562..9f6ef11ec73 100644 --- a/Cartfile +++ b/Cartfile @@ -1,5 +1,5 @@ binary "https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json" ~> 3.7 -github "mapbox/MapboxDirections.swift" ~> 0.19.0 +github "mapbox/MapboxDirections.swift" "public-lane" github "mapbox/turf-swift" ~> 0.0.3 github "mapbox/mapbox-events-ios" ~> 0.3 github "ceeK/Solar" ~> 2.1.0 diff --git a/Cartfile.resolved b/Cartfile.resolved index 9e8bc3adc73..6ef2191ebf3 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,6 +1,6 @@ binary "https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json" "3.7.6" github "ceeK/Solar" "2.1.0" -github "mapbox/MapboxDirections.swift" "v0.19.0" +github "mapbox/MapboxDirections.swift" "c5b4a45dd44fae16f0db80b07d2e5a30c5af1601" github "mapbox/mapbox-events-ios" "v0.3.1" github "mapbox/mapbox-voice-swift" "v0.0.1" github "mapbox/turf-swift" "v0.0.4" diff --git a/MapboxNavigationTests/LaneTests.swift b/MapboxNavigationTests/LaneTests.swift index 7d63a8129a5..35b9aad4aa8 100644 --- a/MapboxNavigationTests/LaneTests.swift +++ b/MapboxNavigationTests/LaneTests.swift @@ -1,6 +1,6 @@ import XCTest import FBSnapshotTestCase -@testable import MapboxDirections +import MapboxDirections @testable import MapboxNavigation @testable import MapboxCoreNavigation diff --git a/MapboxNavigationTests/ReferenceImages_64/MapboxNavigationTests.LaneTests/testSlightRight_iPhone11_3_0x0@3x.png b/MapboxNavigationTests/ReferenceImages_64/MapboxNavigationTests.LaneTests/testSlightRight_iPhone11_3_0x0@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..ae0507e625c9ff8b0d23045553fc51cf0c54b0f1 GIT binary patch literal 1562 zcmV+#2IcvQP)Px#32;bRa{vG#H~;`4H~~eLF<<}y032yVPgDQ^00IC20000004)Fj04M+e04)Fj z04)Fj1PaMUgr)!h1J+4IK~#7F?Al8xJy9G7@avh9N2KJrKuJkS5(_DX6-l9#k`fCG z#fqH;#X{Mj6pCWwRURu+vLOkPSWqY;@_v2wo0{AF{qJM$+;h&IY39^z#+~z+^O>J> z&zu<>tRzIhCZrXs5m?ZIg1~~dpalsCYQ~Ca3tEtXpk}Oywx9(G2x`WPXbW19fS_hf z7twcjcQ`sa!ut9;rl+SdI5>!|t}Zk+HKC%S0{Qv*NJ&Y-;^HFHOJI2D&(BX>US48% zcNZ%wE0~y=Kwn=UIyyQ~Utf>X(o$q+XCpp79zj7tu-R;?K37*)=7D~Ac);xJEJj8~ z(B0jQ*49>3S68E`s0bMu8HkRKhM%9GDmb;klrJqUjVUr!rt63mM1ngmN_z2 zsOvFW*<*^b%F0Ua(Op$lrEHejzG0x{9&c=HAU8Lc8~DJ$fZP<*t>K`l_dh>Bn3|eG zVqzk5@SU97Wq@;w0u~esFp$`rY z5EmE66q@cnc_l+aFE1~1nP0E1t?_a;&h$f)83OwI`x`ASE!>dlqS3M{&!l_kkB<-3*4A=GCg_EQ1)k3O9;07gUQkw6 z#vPf~wCTwU&!pRkzQ4bRsP*W~%uJrfQr)_QzP`RjR#q01NDc`Jaa&JwbF=xN&(6+} znwshs$K9-h{u>St5Apo`jKab~m-S6fPMQmPe}A9J-5x!VeSd$q<1H;Mxr9DHKey-Q zwWFJ%V{2=R$)l^hygX@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use 0.19.1 --- Cartfile | 2 +- Cartfile.resolved | 2 +- MapboxCoreNavigation.podspec | 2 +- MapboxNavigation-Documentation.podspec | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cartfile b/Cartfile index 9f6ef11ec73..767064e274d 100644 --- a/Cartfile +++ b/Cartfile @@ -1,5 +1,5 @@ binary "https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json" ~> 3.7 -github "mapbox/MapboxDirections.swift" "public-lane" +github "mapbox/MapboxDirections.swift" ~> 0.19.1 github "mapbox/turf-swift" ~> 0.0.3 github "mapbox/mapbox-events-ios" ~> 0.3 github "ceeK/Solar" ~> 2.1.0 diff --git a/Cartfile.resolved b/Cartfile.resolved index 6ef2191ebf3..c27ad3c9bc8 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,6 +1,6 @@ binary "https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json" "3.7.6" github "ceeK/Solar" "2.1.0" -github "mapbox/MapboxDirections.swift" "c5b4a45dd44fae16f0db80b07d2e5a30c5af1601" +github "mapbox/MapboxDirections.swift" "v0.19.1" github "mapbox/mapbox-events-ios" "v0.3.1" github "mapbox/mapbox-voice-swift" "v0.0.1" github "mapbox/turf-swift" "v0.0.4" diff --git a/MapboxCoreNavigation.podspec b/MapboxCoreNavigation.podspec index 9bc4fa889ba..e8900a87d0f 100644 --- a/MapboxCoreNavigation.podspec +++ b/MapboxCoreNavigation.podspec @@ -40,7 +40,7 @@ Pod::Spec.new do |s| s.requires_arc = true s.module_name = "MapboxCoreNavigation" - s.dependency "MapboxDirections.swift", "~> 0.19.0" + s.dependency "MapboxDirections.swift", "~> 0.19.1" s.dependency "MapboxMobileEvents", "~> 0.3" s.dependency "Turf", "~> 0.0.4" diff --git a/MapboxNavigation-Documentation.podspec b/MapboxNavigation-Documentation.podspec index 8e840660c2c..e4a0bf7aa28 100644 --- a/MapboxNavigation-Documentation.podspec +++ b/MapboxNavigation-Documentation.podspec @@ -43,7 +43,7 @@ Pod::Spec.new do |s| s.requires_arc = true s.module_name = "MapboxNavigation" - s.dependency "MapboxDirections.swift", "~> 0.19.0" + s.dependency "MapboxDirections.swift", "~> 0.19.1" s.dependency "Mapbox-iOS-SDK", "~> 3.6" s.dependency "MapboxMobileEvents", "~> 0.3" s.dependency "Solar", "~> 2.1" From c42228022787b740fb3943e31c5bc67346748b8a Mon Sep 17 00:00:00 2001 From: Bobby Sudekum Date: Wed, 4 Apr 2018 13:23:24 -0700 Subject: [PATCH 4/4] changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad36046770f..004782ec4b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## master +### User Interface + +* Draws slight right and left turn icons for slight turns in the turn lane view. [#1270](https://github.com/mapbox/mapbox-navigation-ios/pull/1270) + ### Core Navigation * Fixed a crash that was caused by check the edit distance of an empty string. [#1281](https://github.com/mapbox/mapbox-navigation-ios/pull/1281/)