2023-06-14 17:52:43 +02:00
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
private let df: DateFormatter = {
|
|
|
|
let df = DateFormatter()
|
|
|
|
df.dateStyle = .short
|
|
|
|
df.timeStyle = .medium
|
|
|
|
return df
|
|
|
|
}()
|
|
|
|
|
2023-08-09 17:13:53 +02:00
|
|
|
private let dateFormatter: DateFormatter = {
|
|
|
|
let df = DateFormatter()
|
|
|
|
df.dateStyle = .medium
|
|
|
|
df.timeStyle = .none
|
|
|
|
return df
|
|
|
|
}()
|
|
|
|
|
2023-06-14 17:52:43 +02:00
|
|
|
struct DayView: View {
|
|
|
|
|
|
|
|
let dateIndex: Int
|
|
|
|
|
|
|
|
@EnvironmentObject
|
2023-07-02 17:29:39 +02:00
|
|
|
var storage: PersistentStorage
|
2023-06-14 17:52:43 +02:00
|
|
|
|
|
|
|
var entries: [TemperatureMeasurement] {
|
|
|
|
storage.loadMeasurements(for: dateIndex)
|
|
|
|
}
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
TemperatureDayOverview(points: entries)
|
|
|
|
List(entries) { entry in
|
|
|
|
HStack {
|
|
|
|
Text(df.string(from: entry.date))
|
|
|
|
Spacer()
|
|
|
|
Text(entry.displayText)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct DayView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
DayView(dateIndex: Date.now.dateIndex)
|
2023-07-02 17:29:39 +02:00
|
|
|
.environmentObject(PersistentStorage.mock)
|
2023-06-14 17:52:43 +02:00
|
|
|
}
|
|
|
|
}
|