39 lines
826 B
Swift
39 lines
826 B
Swift
import SwiftUI
|
|
|
|
private let df: DateFormatter = {
|
|
let df = DateFormatter()
|
|
df.dateStyle = .short
|
|
df.timeStyle = .medium
|
|
return df
|
|
}()
|
|
|
|
struct DayView: View {
|
|
|
|
let dateIndex: Int
|
|
|
|
@EnvironmentObject
|
|
var storage: TemperatureStorage
|
|
|
|
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)
|
|
.environmentObject(TemperatureStorage.mock)
|
|
}
|
|
}
|