- Documented mobile-first responsive design as REQUIRED standard - Added web development tech preferences (Next.js, Tailwind, etc.) - Created memory/project-standards.md for coding guidelines
34 lines
980 B
Swift
34 lines
980 B
Swift
import SwiftUI
|
|
import SwiftData
|
|
|
|
struct HistoryView: View {
|
|
@Query private var sessions: [Session]
|
|
@Environment(\.modelContext) private var modelContext
|
|
|
|
var body: some View {
|
|
NavigationStack {
|
|
List(sessions) { session in
|
|
VStack(alignment: .leading) {
|
|
Text(session.date.formatted(.dateTime.month().day().hour().minute()))
|
|
Text("Duration: \(Int(session.duration / 60)) min")
|
|
.foregroundStyle(.secondary)
|
|
}
|
|
}
|
|
.navigationTitle("Sessions")
|
|
.toolbar {
|
|
ToolbarItem(placement: .topBarTrailing) {
|
|
Button("Clear All") {
|
|
sessions.forEach { modelContext.delete($0) }
|
|
try? modelContext.save()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
HistoryView()
|
|
.modelContainer(for: Session.self)
|
|
}
|