22 questions
0
votes
1
answer
63
views
Why do we need to inject the same object into the environment twice in SwiftUI? [duplicate]
I am trying to create a centralized router for my SwiftUI app and was hoping to take advantage of the @Environment feature for this.
While this might not be the best design pattern, I am trying to ...
1
vote
1
answer
277
views
Enum based alternative to type-erased NavigationPath for NavigationStack
After realizing the lookup and editing limitations of the built-in, type-erased NavigationPath, I'm exploring an enum-based solution. With this approach, I can inspect and edit the path much easier ...
2
votes
1
answer
144
views
.navigationBarBackButtonHidden is delayed when using NavigationStack.count
Can someone help me understand the behavior of 'NavigationStack.count'. I don't understand how/when it's updated. In this example, I use the count to disable back navigation. But as you can see, ...
0
votes
1
answer
405
views
SwiftUI: How to correctly navigate in TabView and NavigationStack using NavigationPath?
I'm experiencing a problem using programmatic navigation using TabView and NavigationStack.
I have a TabView with a $selection pointing to a NavigationPath in an environmentObject. I also have two ...
0
votes
1
answer
463
views
NavigationStack with NavigationPath triggers multiple init/deinit of views in stack
I've stumbled upon what I think is a bug in SwiftUI, but there might be an explanation for it, which I cannot to figure out. So here's the "bug". Perhaps any of you know it.
In short
I found ...
1
vote
0
answers
335
views
NavigationStack -> navigationDestination infinite loop
In a project where each view has a ViewModel object that I was using in my .navigationDestination(...). Caused an infinite loop sometimes, not every time.
This code is causing infinite loop ...
0
votes
0
answers
134
views
Is it wise to have a single state as an environment object for the whole SwiftUI app?
I've been looking at different ways to build in deeplinking capabilities for a SwiftUI app using NavigationSatck. Some articles suggest having the navigation state injected as an environment object ...
-3
votes
1
answer
382
views
NavigationPath(_items: SwiftUI.NavigationPath.(unknown context at $7ff84b690a28) Representation.eager([SwiftUI.(unknown context at $7ff84b6907f0).C
I tried to use navigationstack, and it works. but couldn't print the path, and with the message: " NavigationPath(_items: SwiftUI.NavigationPath.(unknown context at $7ff84b690a28).Representation....
0
votes
3
answers
2k
views
How to get the last two items from the stack of a NavigationPath() object
I am facing a challenge in SwiftUI and would appreciate some guidance. In my code, I'm working with a NavigationPath() object and need to obtain the last two items from the stack. Specifically, this ...
0
votes
0
answers
157
views
SwiftUI List Causes "No `navigationDestination(for: <Hashable>.self) { … }` was found among the views on the path" Error
I've been trying to understand for the past several weeks why my app has been crashing at times when I save my app's NavigationPath.CodableRepresentation to core data (as a Binary Data type), ...
1
vote
0
answers
306
views
How to properly manage view focus while pushing multiple views to NavigationStack path in SwiftUI iOS 17+
I'm trying to save the state of my NavigationPath for my NavigationStack in SwiftUI by pushing all the views to the stack at once. That way if the user taps the Back button, they will still see the ...
0
votes
1
answer
817
views
How to figure out what navigationpath you came from to append to it?
I have several navigation paths using the same enum so that I'm able to clear that path and bring the user back to the main tab view for that item. This works great when I am using navigationLink(...
3
votes
1
answer
785
views
SwiftUI navigation router issues
I have a simple navigation router:
@Observable class BaseRouter {
var path = NavigationPath()
var isEmpty: Bool {
return path.isEmpty
}
func navigateBack() {
path....
2
votes
0
answers
154
views
SwiftUI, prevent the subview to inherit parent's animation
I've been playing with the NavigationPath for some time. I first figured that when a view is inserted into the path (full code is on this answer), the inserted page doesn't have standard navigation ...
1
vote
0
answers
656
views
NavigationStack's path are being emptied when NavigationStack disappears
In the executable code below I try to implement the main navigation view for an (iPadOS) app. The expected behaviour is as follows:
A NavigationSplitView is used to present a sidebar to the user ...