Sesame-iOS/Sesame-Watch Watch App/HistoryView.swift

38 lines
841 B
Swift
Raw Normal View History

2023-08-07 15:57:09 +02:00
import SwiftUI
struct HistoryView: View {
2023-08-09 16:29:18 +02:00
let history: HistoryManagerProtocol
@State
private var items: [HistoryItem] = []
2023-08-07 15:57:09 +02:00
var body: some View {
2023-08-09 16:29:18 +02:00
NavigationStack {
List(items) { item in
NavigationLink {
HistoryItemDetail(item: item)
} label: {
HistoryListRow(item: item)
}
}
.navigationTitle("History")
}.onAppear(perform: loadItems)
}
private func loadItems() {
Task {
let entries = history.loadEntries()
DispatchQueue.main.async {
items = entries
}
}
2023-08-07 15:57:09 +02:00
}
}
struct HistoryView_Previews: PreviewProvider {
static var previews: some View {
2023-08-09 16:29:18 +02:00
HistoryView(history: HistoryManagerMock())
2023-08-07 15:57:09 +02:00
}
}