Well I can't edit post anymore and I will add it here
struct ContentView: View { enum Sheet: String, Identifiable { var id: String { rawValue } case one, two } @State var isFullScreenPresented: Bool = false @State var isSheetPresented: Bool = false @State var isItemSheetPresented: Sheet? var body: some View { VStack { HStack { Button(action: {isFullScreenPresented.toggle()}, label: { Text("fullScreen") .padding() .foregroundColor(.red)
.background(Rectangle()) }) Button(action: {isSheetPresented.toggle()}, label: { Text("sheet") .padding() .foregroundColor(.red)
.background(Rectangle()) })
} HStack { Button(action: {isItemSheetPresented = .one}, label: { Text("one") .padding() .foregroundColor(.red) .background(Rectangle()) }) Button(action: {isItemSheetPresented = .two}, label: { Text("two") .padding() .foregroundColor(.red)
.background(Rectangle()) }) } HStack { Text(isFullScreenPresented.description) Text(isSheetPresented.description) } Text(isItemSheetPresented.debugDescription) Spacer() } .sheet(item: $isItemSheetPresented, onDismiss: {isItemSheetPresented = nil}, content: {item in Text(item.id) }) .sheet(isPresented: $isSheetPresented, onDismiss: { isSheetPresented = false}, content: { Text("sheet") }) .fullScreenCover(isPresented: $isFullScreenPresented, onDismiss: {isFullScreenPresented = false }, content: {FullScreenContent()}) }}
struct FullScreenContent: View { @Environment(\.presentationMode) var dismiss var body: some View { VStack { Button("close", action: {dismiss.wrappedValue.dismiss()}) Spacer() } }}```
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: