There are two ways to show LoginView in my code
- In A view, use navigationLink
NavigationLink(destination: LoginView()) {
Text(“To login")
}
- In B view, use .sheet
.sheet(isPresented: $viewModel.isShowingSheet) {
LoginView()
}
and in LoginView, I want to show my Banner if LoginView is presented as sheet, so I used presentationMode.
struct LoginView: View {
@Environment(\.presentationMode) var presentationMode
var body: some View {
if presentationMode.wrappedValue.isPresented {
Banner()
}
}
}
But Banner is shown in both cases (navigation link and sheet)
Is it any good way to check if view is presented by sheet? Or do I have to inject presentation style using my own property?