Skip to content

Instantly share code, notes, and snippets.

@alpennec
Created February 26, 2023 16:33
Show Gist options
  • Save alpennec/f56cdc845f7c21a3f0118951b03a98c5 to your computer and use it in GitHub Desktop.
Save alpennec/f56cdc845f7c21a3f0118951b03a98c5 to your computer and use it in GitHub Desktop.
import SwiftUI
struct ContentView: View {
@State private var isPresentingA: Bool = false
@State private var isPresentingB: Bool = false
var body: some View {
NavigationStack {
Text("Hello, World!")
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button("A") {
isPresentingA = true
}
}
ToolbarItem(placement: .confirmationAction) {
Button("B") {
isPresentingB = true
}
}
}
.sheet(isPresented: $isPresentingA) {
NavigationStack {
Text("A")
}
}
.sheet(isPresented: $isPresentingB) {
NavigationStack {
Text("B")
}
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment