import SwiftUI
import SFSafeSymbols

private let df: DateFormatter = {
    let df = DateFormatter()
    df.dateStyle = .short
    df.timeStyle = .short
    df.doesRelativeDateFormatting = true
    return df
}()

struct HistoryListRow: View {

    let item: HistoryItem

    private var entryTime: String {
        df.string(from: item.startDate)
    }

    var body: some View {
        VStack(alignment: .leading) {
            HStack {
                Image(systemSymbol: item.response.symbol)
                Text(item.response.description)
                    .font(.headline)
                    .foregroundColor(.primary)
                Spacer()
            }
            Text(entryTime)
                .font(.footnote)
                .foregroundColor(.accentColor)

        }

    }
}

struct HistoryListRow_Previews: PreviewProvider {
    static var previews: some View {
        HistoryListRow(item: .mock)
    }
}
