Page MenuHomeMusing Studio

PostCellView.swift
No OneTemporary

PostCellView.swift

import SwiftUI
struct PostCellView: View {
@ObservedObject var post: WFAPost
var body: some View {
HStack {
VStack(alignment: .leading) {
Text(post.title)
.font(.headline)
.lineLimit(1)
Text(buildDateString(from: post.createdDate ?? Date()))
.font(.caption)
.lineLimit(1)
}
Spacer()
PostStatusBadgeView(post: post)
}
.padding(5)
}
func buildDateString(from date: Date) -> String {
let dateFormatter = DateFormatter()
dateFormatter.dateStyle = .long
dateFormatter.timeStyle = .short
return dateFormatter.string(from: date)
}
}
struct PostCell_Previews: PreviewProvider {
static var previews: some View {
let context = LocalStorageManager.persistentContainer.viewContext
let testPost = WFAPost(context: context)
testPost.title = "Test Post Title"
testPost.body = "Here's some cool sample body text."
testPost.createdDate = Date()
return PostCellView(post: testPost)
.environment(\.managedObjectContext, context)
}
}

File Metadata

Mime Type
text/x-c
Expires
Sat, Jan 31, 2:16 PM (22 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3612487

Event Timeline