Files
workoutsplus/WorkoutsPlus/Debug/ExampleView.swift

86 lines
2.0 KiB
Swift

//
// ExampleView.swift
// WorkoutsPlus
//
// Created by Felix Förtsch on 07.09.24.
//
import SwiftUI
struct ExampleView: View {
@State private var isSheetPresented = false
@State private var isFullScreenCoverPresented = false
@State private var isAlertPresented = false
@State private var isPopoverPresented = false
@State private var showPopoverSource: Bool = false
var body: some View {
NavigationStack {
List {
NavigationLink(destination: Text("Detail View")) {
Text("NavigationLink")
}
Button(action: {
isSheetPresented.toggle()
}) {
Text("Sheet")
}
.sheet(isPresented: $isSheetPresented) {
Text("This is a sheet")
.presentationDetents([.medium, .large])
}
Button(action: {
isFullScreenCoverPresented.toggle()
}) {
Text("FullScreenCover")
}
.fullScreenCover(isPresented: $isFullScreenCoverPresented) {
Text("This is a full-screen modal")
Button(action: { isFullScreenCoverPresented = false }) {
Text("Close")
}
}
Button(action: {
isAlertPresented.toggle()
}) {
Text("Alert")
}
.alert(isPresented: $isAlertPresented) {
Alert(title: Text("This is an alert"))
}
Button(action: {
showPopoverSource = true
}) {
Text("Popover")
}
.popover(isPresented: $showPopoverSource) {
Text("This is a popover")
}
Text("ContextMenu")
.contextMenu {
Button(action: {
print("Context menu action")
}) {
Text("Action")
Image(systemName: "star")
}
}
NavigationLink(destination: Text("Tab View Example")) {
Text("TabView")
}
}
.navigationTitle("View Presentations")
}
}
}
#Preview {
ExampleView()
}