Skip to content

Instantly share code, notes, and snippets.

@toddhopkinson
Created September 2, 2023 19:24
Show Gist options
  • Save toddhopkinson/9b3af91fd5b0899ae05b8e2338ecaf0d to your computer and use it in GitHub Desktop.
Save toddhopkinson/9b3af91fd5b0899ae05b8e2338ecaf0d to your computer and use it in GitHub Desktop.
enum ActiveSheet: Identifiable {
case first, second
var id: Int {
hashValue
}
}
struct YourView: View {
@State var activeSheet: ActiveSheet?
var body: some View {
VStack {
Button {
activeSheet = .first
} label: {
Text("Activate first sheet")
}
Button {
activeSheet = .second
} label: {
Text("Activate second sheet")
}
}
.sheet(item: $activeSheet) { item in
switch item {
case .first:
FirstView()
case .second:
SecondView()
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment