-
Notifications
You must be signed in to change notification settings - Fork 87
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
NavigationStack stops functioning once I open a fullScreenCover #49
Comments
I tried to stop using fullScreenCover and just using NavigationStack to display the messages but then another issue appeared. It seems that If i aim getting any environmentObject from swift, it will do the same thing. Slightly slide to the right and come back. |
Hi @ch05enOne would you be able to provide me with a small example of the issue? So that I can copy-paste it on Xcode and try to debug and solve it. Thanks. |
Sure @matteopuc. Just to give you a better prespective, I wrote an issue on here under the name ch05en when I tried to log out the user. You quickly solved that for me. Thanks! This problem has to Do with me using snapshotListeners from Firebase Firestore. Once i log out the app, I want to remove all the snapshotListeners. This isn't a problem though. I have figured this part out. This is the manager where I add and remove the snapshotListeners. `class StatusManager: ObservableObject{
}` I pass this as an environment object for all the views to use in my App.swift file. The basic functionality is that once I initialize the snapshotListener, I append it to the listeners array. This is the View where I list all the contacts. I use a button to toggle a boolean variable. I use that bool for the PushView. `
` This is the MessageView, the view that is causing the error. Once I click on the button which pushes to this view, It actually triggers the onAppear() method but comes back right away. `struct MessageView{
var body: some View{ VStack{
ScrollView{ ForEach(messagesArray, id: .self){ message in //Displays all messages
// Initialize listener // Initialize listener // THIS causes the bug. If I remove this, everything display wise works perfectly. Otherwise, the bug persists.
}` |
Sorry man but I just couldn't get the formatting right. Hope this helps. |
Unfortunately I can't manage to make your example compile, I miss too many things. It would be really great to have a minimum viable example that reproduces the issue. I'm trying to create it, but I'm not experiencing the problem. For example, take a look at the following (you can copy paste it in your Xcode and try it yourself): // this is the entry point file
import SwiftUI
import NavigationStack
@main
struct SwiftUIExamplesApp: App {
var body: some Scene {
WindowGroup {
NavigationStackView {
ContentView()
}
.environmentObject(StatusManager())
}
}
}
class StatusManager: ObservableObject{
@Published var listeners: [Int] = []
}
struct ContentView: View {
@EnvironmentObject var statusManager: StatusManager
var body: some View {
VStack {
Text("TOP BAR")
Spacer()
ForEach(statusManager.listeners, id: \.self) { listener in
Text("\(listener)")
}
Spacer()
PushView(destination: ChildView()) {
Text("PUSH")
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color.red)
}
}
struct ChildView: View {
@EnvironmentObject var statusManager: StatusManager
var body: some View {
VStack {
Text("asd")
PopView {
Text("POP")
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color.green)
.onAppear {
statusManager.listeners.append(10)
}
}
} Since you told me that the issue is due to these two lines: statusManager.listeners.append(messageGetterListener)
statusManager.listeners.append(isReadListener) I tried to do something similar in the |
Will do @matteopuc . Thank you |
@matteopuc This similar library has a similar issue. reopening to see if it helps. https://github.com/rebeloper/NavigationKit/issues/6 I looked at ur injection above for the environment object btw. Not sure if this makes a change, but instead of using .environmentObject(StatusManager()), I initialized a @StateObject variable and injected that into the environment. |
Hi @ch05enOne, if you can use
Then you can access and use the
Let me know if you manage to solve your issue. |
@matteopuc I had the same issue and can confirm that using a |
I have this chat tab on my app which uses a fullScreenCover. The problem is, after I open that fullScreenCover, all the Push functions of the navigationStack stop working. They animate but done push to anything, its like it is sliding itself on top of it.
The text was updated successfully, but these errors were encountered: