-
Notifications
You must be signed in to change notification settings - Fork 19
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
SwiftUI NavigationLink #101
Comments
Copying text over from another Issue: I want SwiftUI to have launch styles like UIKit so I can put my stuff in a navigation view. I'd like something like: WorkflowLauncher(isLaunched: .constant(true))
.launchStyle(.navigationStack)
.thenProceed(with: WorkflowItem(FR1.self).launchStyle(.modal())) Describe alternatives you've consideredFor Modals, I can embed them myself in sheets and share the binding with the WorkflowLauncher or set it on the view. For navigation stacks, I'm not sure what I can do. |
We are spiking on ways to handle navigation when the WorkflowLauncher is part of (or contains) a NavigationView. We think that we may be able to create a hidden NavigationLink that can be invoked when our lifecycle methods are called (eg. proceedInWorkflow) |
EOD: The spiking continues. Currently we are spiking it out without the context of a user defined launchStyle and instead with an assumed what would be |
Today we got a little bit closer. The desired behavior can now be observed when setting the WorkflowViewModel body as the destination for the NavigationLink. Currently, I am experimenting with ways to introduce the wrapping NavigationView to the first ModifiedWorkflowView in a sequence. |
|
Had spotty connection issues most of the day today. Spent some time looking at Combine types trying to figure out how to filter out false values from WorkflowViewModel
ModifiedWorkflowView
When the NavigationLink gets a false value from
But still poking around the Combine docs to figure out the how. |
So flip the concept on its head. In a typical SwiftUI view, when you set up a In SwiftCurrent land, it's similar but essentially opposite. You have no clue what will come next, so rather than PROBLEM: SwiftUI has a bug if There are some .... interesting? workarounds posed in the SO answer that we have validated do in fact, work. Now we're trying to continue this concept of defaulting |
We're still spinning on this. The big problem we're trying to solve is the conundrum that when you create a FR1 (with This happens when you are recursing back from FR3, FR3 told FR2 to have a This is all grossly simplified but covers the basic issue we're battling. |
Unfortunate reality: SwiftUI NavigationViews have some odd behavior. Let me start with the good news:
Now the bad
What that means:
Next steps:
|
There are two spike branches to see the work we did today: |
We solved it and it is so easy.... We just need to fundamentally change how fluent stuff works so that the typing is reversed. Right now we have: With that one change Modals and navigation links and everything is just stupid simple. See: |
By "solved" he means we conceptually proved it, we have no idea how to fundamentally change how the fluent stuff works. |
Tomato/Potato |
It turns out Richard and I are not smart enough to change the fundamental rules of Swift (honestly, we may be up against just computer science issues regardless of language). SO we came up with the next best thing. Notice that SwiftUI has the desired effect with its views, it does this by composition and wrapping. Example: VStack {
VStack {
Text("First")
}
} Creates a type of WorkflowView(FR1.self) {
thenProceed(with: FR2.self) {
thenProceed(with: FR3.self) {
thenProceed(with: FR4.self)
}
}
} This creates the exact type structure we want. It just has the unfortunate side-effect of looking god-awful and creating a pyramid of doom. Turns out we can be a little bit smarter with autoclosures WorkflowView(content: FR1.self)
.thenProceed(with: workflowItem(FR2.self)
.thenProceed(with: workflowItem(FR3.self)
.thenProceed(with: workflowItem(FR4.self)))) The advantage is that this is very close to our current API. The disadvantage is the parenthesis hell at the end (LISP, anyone?) and the formatting XCode wants to do forces it right back into pyramid shape. HOWEVER this gives us extremely important capabilities with both nav stacks and modals. Like they were seriously trivial once we had the type information flowing the correct direction. Ultimately while you may not like the aesthetics as much we care about functionality over aesthetics. If anybody feels brave I encourage them to try to do better, Richard and I have spent at least 15 hours on this so far and this is the best we could do. |
Crappy Alternatives Considered:So the premise is that you just need the types in the correct order:
WorkflowLauncher(isLaunched: .constant(true))
.thenProceed(with: WorkflowItem(FR4.self))
.thenProceed(with: WorkflowItem(FR3.self))
.thenProceed(with: WorkflowItem(FR2.self))
.thenProceed(with: WorkflowItem(FR1.self))
func reverseTypes<C1, C2, C3>(backwardsWorkflow: ModifiedWorkflowViewOLD<ModifiedWorkflowViewOLD<ModifiedWorkflowViewOLD<Never, C1>, C2>, C3>) -> ModifiedWorkflowViewOLD<ModifiedWorkflowViewOLD<ModifiedWorkflowViewOLD<Never, C3>, C2>, C1> {
return ModifiedWorkflowViewOLD<ModifiedWorkflowViewOLD<ModifiedWorkflowViewOLD<Never, C3>, C2>, C1>()
}
|
Our efforts to get to the preferred solution can be found in branch |
Then @Tyler-Keith-Thompson came back and now we have mostly working view swapping. The API is still not re-implemented, but we have gotten closer to getting SwiftUIExample back up and running. |
#111 Is required to enable this issue, but it is a step on the way. |
Because #111 changed the API to enable this issue, a new discussion was made to track that: Update to the SwiftUI API for the sake of NavigationLinks |
add support for NavLinks as launchStyle on WorkflowView and WorkflowItem
Add 10 screen test, beginning to end and back. don't forget to test wiggle/oscillation between 2 screens in the navigation view. what happens if someone hits back on nav view?
test abandoning
The text was updated successfully, but these errors were encountered: