TempTrack-iOS/TempTrack/Views/LogView.swift

39 lines
891 B
Swift
Raw Normal View History

2023-06-14 16:16:56 +02:00
import SwiftUI
2023-06-14 17:52:43 +02:00
private let df: DateFormatter = {
let df = DateFormatter()
df.dateStyle = .short
df.timeStyle = .medium
return df
}()
2023-06-14 16:16:56 +02:00
struct LogView: View {
@EnvironmentObject
var log: Log
var body: some View {
NavigationView {
List(log.logEntries) { entry in
VStack(alignment: .leading) {
HStack {
Text(entry.level.description)
Spacer()
Text(df.string(from: entry.date))
}.font(.footnote)
Text(entry.message)
}
2023-06-14 16:16:56 +02:00
}
.navigationTitle("Log")
.navigationBarTitleDisplayMode(.large)
2023-06-14 16:16:56 +02:00
}
}
}
struct LogView_Previews: PreviewProvider {
static var previews: some View {
LogView()
.environmentObject(Log())
}
}