-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ios] pull down InstructionView handle to show remaining steps #276
Merged
+618
−89
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
dc60c64
[iOS] Pull down cue sheet shows remaining steps
michaelkirk 8815b49
Move test factories and mark them internal
ianthetechie 1fb29b7
Make expanded properties bindings
ianthetechie a941753
Add TODO for discussion
ianthetechie d0dfc82
fixup! Make expanded properties bindings
michaelkirk 1015d92
More small cleanup
ianthetechie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/// Various helpers that generate views for previews. | ||
|
||
import FerrostarCoreFFI | ||
import Foundation | ||
|
||
protocol TestFixtureFactory { | ||
associatedtype Output | ||
func build(_ n: Int) -> Output | ||
} | ||
|
||
extension TestFixtureFactory { | ||
func buildMany(_ n: Int) -> [Output] { | ||
(0 ... n).map { build($0) } | ||
} | ||
} | ||
|
||
struct VisualInstructionContentFactory: TestFixtureFactory { | ||
public init() {} | ||
|
||
public var textBuilder: (Int) -> String = { n in RoadNameFactory().build(n) } | ||
public func text(_ builder: @escaping (Int) -> String) -> Self { | ||
var copy = self | ||
copy.textBuilder = builder | ||
return copy | ||
} | ||
|
||
public func build(_ n: Int = 0) -> VisualInstructionContent { | ||
VisualInstructionContent( | ||
text: textBuilder(n), | ||
maneuverType: .turn, | ||
maneuverModifier: .left, | ||
roundaboutExitDegrees: nil | ||
) | ||
} | ||
} | ||
|
||
struct VisualInstructionFactory: TestFixtureFactory { | ||
public init() {} | ||
|
||
public var primaryContentBuilder: (Int) -> VisualInstructionContent = { n in | ||
VisualInstructionContentFactory().build(n) | ||
} | ||
|
||
public var secondaryContentBuilder: (Int) -> VisualInstructionContent? = { _ in nil } | ||
|
||
public func secondaryContent(_ builder: @escaping (Int) -> VisualInstructionContent) -> Self { | ||
var copy = self | ||
copy.secondaryContentBuilder = builder | ||
return copy | ||
} | ||
|
||
public func build(_ n: Int = 0) -> VisualInstruction { | ||
VisualInstruction( | ||
primaryContent: primaryContentBuilder(n), | ||
secondaryContent: secondaryContentBuilder(n), | ||
triggerDistanceBeforeManeuver: 42.0 | ||
) | ||
} | ||
} | ||
|
||
struct RouteStepFactory: TestFixtureFactory { | ||
public init() {} | ||
public var visualInstructionBuilder: (Int) -> VisualInstruction = { n in VisualInstructionFactory().build(n) } | ||
public var roadNameBuilder: (Int) -> String = { n in RoadNameFactory().build(n) } | ||
|
||
public func build(_ n: Int = 0) -> RouteStep { | ||
RouteStep( | ||
geometry: [], | ||
distance: 100, | ||
duration: 99, | ||
roadName: roadNameBuilder(n), | ||
instruction: "Walk west on \(roadNameBuilder(n))", | ||
visualInstructions: [visualInstructionBuilder(n)], | ||
spokenInstructions: [], | ||
annotations: nil | ||
) | ||
} | ||
} | ||
|
||
struct RoadNameFactory: TestFixtureFactory { | ||
public init() {} | ||
public var baseNameBuilder: (Int) -> String = { _ in "Ave" } | ||
|
||
public func baseName(_ builder: @escaping (Int) -> String) -> Self { | ||
var copy = self | ||
copy.baseNameBuilder = builder | ||
return copy | ||
} | ||
|
||
public func build(_ n: Int = 0) -> String { | ||
let numberFormatter = NumberFormatter() | ||
numberFormatter.numberStyle = .ordinal | ||
return "\(numberFormatter.string(from: NSNumber(value: n + 1))!) \(baseNameBuilder(n))" | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The layout changes here are non-trivial.
We want to be able to expand the instruction view over top of the other content when it's expanded. But when it's not expanded, we want it to behave as if it's in a vstack with the NavigationInnerGridView.
My solution was to put the InstructionView in a ZStack above the grid, and then plumb out the InstructionView's "unexpanded height" to push down the NavigatingInnerGridView.
I struggled a bit with implementing this layout in SwiftUI. It's something I think would be natural to express in old school iOS layout constraints. Maybe there's a better way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'm not aware of a better way offhand either. It's one of the areas where SwiftUI and others struggle compared to springs-and-struts or auto layout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few conflicts unfortunately with the main branch since @Archdoog just cleaned up a bunch of stuff to clean up the pattern matching mess 😅