I'm using a ZStack with viewA() and a toast viewB(). I present a FullScreenView() using .fullScreenCover(isPresented:).
ZStack {
viewA()
viewB() // toast view
}
.fullScreenCover(isPresented: $isPresented) {
FullScreenView()
}
I want viewB (the toast) to appear above both viewA and the FullScreenView. I only found this approach works but it has duplicate code.
ZStack {
viewA()
viewB() // toast view
}
.fullScreenCover(isPresented: $isPresented) {
ZStack {
FullScreenModalView()
viewB() // toast view
}
}
What are all possible approaches to achieve this in SwiftUI? Any advice or code samples would be appreciated!
Have you considered using a system component like an action sheet or an Alert instead of a custom component?