//
// DataListView.swift
// ScrollableCardView
//
// Created by WilliamJiamin on 2024/7/2.
//
import SwiftUI
struct DataListView: View {
// let dateFormatter: DateFormatter = {
// let formatter = DateFormatter()
// formatter.dateFormat = "MM/dd"
// return formatter
// }()
@State private var isShowingAddDataView = false
var context: SelectionContext
var body: some View {
List(0..<32) { i in
HStack {
// Text(dateFormatter.string(from: Date()))
Text(Date(),format: .dateTime.year().month().day())
Spacer()
Text("\(i)")
}
}
.navigationTitle(context.title)
.sheet(isPresented: $isShowingAddDataView) {
addDataView
}
.toolbar {
Button("Add Data Manually", systemImage: "plus.diamond") {
isShowingAddDataView = true
}
}
}
var addDataView: some View {
NavigationStack {
Form {
}
.navigationTitle(context.title)
.toolbar{
ToolbarItem(placement: .topBarLeading){
Button("Forget About It") {
isShowingAddDataView = false
}
}
ToolbarItem(placement: .topBarTrailing) {
Button("Confirm") {
print("A new data has been confirmed")
}
}
}
}
}
}
#Preview {
DataListView(context: .calories)
}