How to dismiss two views in SwiftUI

Viewed 418

I have three views in my App: MenuViewModel -> MainActionsViewModel -> SummaryViewModel and I would like to after click Button 'Back to menu' in SummaryViewModel back to the MenuViewModel. I've tried something like this - in struct SummaryViewModel added:

@Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>

and in Button action also added:

self.presentationMode.wrappedValue.dismiss()

but after on click this button I go back to MainActionsViewModel, not to MenuViewModel. Is in SwiftUI possible to close 2 or more Views?

0 Answers
Related