-
Notifications
You must be signed in to change notification settings - Fork 313
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
Refactor instructions banner #1093
Conversation
8a92bce
to
534b4ac
Compare
I wonder if let viewModel = InstructionsBannerViewModel { (viewModel, state) in
v.maneuverView.step = state.maneuverViewStep
v.primaryLabel.instruction = state.primaryInstruction
v.secondaryLabel.instruction = state.secondaryInstruction
v.distanceLabel.text = String(state.distanceRemaining)
} Is still a lot of domain knowledge for the developer to manage. Could this be simplified even further? |
It's actually a pretty common design pattern. As long as we provide examples, I don't think our power users using the custom UI would struggle with this. Not sure how we could simplify this further. 🤔 |
Hmm, I'm not sure I see the benefit of this. It is a more formal pattern, but I don't see why we need to have a formal view model, instead of just offering two methods on InstructionsBannerView.
If we had multiple routing services, each with their own model schema, then I could totally see the use-case for formalized view-models. But as our codebase stands right now, it just seems like overkill, and tedious overkill at that. Is there an architectural flaw in #1085 that necessitates this PR? |
In addition to @JThramer, I feel like the amount of code + knowledge added here is pretty high. @frederoni what do you think the drawbacks are to #1085? What I like about #1085 is the simplicity. |
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.
Going to mark this "Request Changes" until we pow-wow about this PR's fate.
This is another take on #1085 using a View Model approach. It also fixes #792
An
InstructionsBannerViewModel
that handles the logic and anInstructionsBannerViewState
which encapsulates the state has been added.Using a custom instructions banner could look something like:
DistanceLabel
to the view modelInstructionPresenter
from Hides delimiters in banner when surrounded by loaded shield images #1046 /cc @akitchen@mapbox/navigation-ios