Код: Выделить всё
struct ContentView: View {
@State private var navigationPath = NavigationPath()
@State private var presentingSheet: Bool = false
@State private var presentingFullScreen: Bool = false
@State private var selectedItem: String?
var body: some View {
NavigationStack(path: $navigationPath) {
VStack {
/*Button("Push to Detail") {
navigationPath.append("Detail")
}*/
Button("Present as Sheet") {
selectedItem = "Detail"
presentingSheet = true
}
Button("Present as FullScreen") {
selectedItem = "Detail"
presentingFullScreen = true
}
}
/*.navigationDestination(for: String.self) { value in
DetailView(value: value)
}*/
.sheet(isPresented: $presentingSheet) {
if let selectedItem {
DetailView(value: selectedItem)
}
}
.fullScreenCover(isPresented: $presentingFullScreen) {
if let selectedItem {
DetailView(value: selectedItem)
}
}
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... eet-or-ful