Created
September 2, 2023 19:24
-
-
Save toddhopkinson/9b3af91fd5b0899ae05b8e2338ecaf0d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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