leganto-apple/Leganto/FeedViewCell.swift

49 lines
1.4 KiB
Swift
Raw Permalink Normal View History

//
// FeedViewCell.swift
// Leganto
//
// Created by Louis Hollingworth on 2023-05-23.
//
import SwiftUI
struct FeedViewCell: View {
let title: String
let author: String
let date: Date
let content: String
var body: some View {
VStack(alignment: .leading) {
Text(title)
.font(.title)
HStack {
Text(author)
Spacer()
Text(date, formatter: dateFormatter)
}
.font(.footnote)
Text(content)
.font(.body)
}
.multilineTextAlignment(.leading)
}
}
private let dateFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateStyle = .short
formatter.timeStyle = .short
return formatter
}()
struct FeedViewCell_Previews: PreviewProvider {
static var previews: some View {
FeedViewCell(
title: "Test", author: "Test Author", date: Date(),
content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
)
}
}