Sesame-iOS/Sesame-Watch Watch App/HistoryView.swift
2023-08-09 16:29:18 +02:00

38 lines
841 B
Swift

import SwiftUI
struct HistoryView: View {
let history: HistoryManagerProtocol
@State
private var items: [HistoryItem] = []
var body: some View {
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
}
}
}
}
struct HistoryView_Previews: PreviewProvider {
static var previews: some View {
HistoryView(history: HistoryManagerMock())
}
}