Skip to content

Instantly share code, notes, and snippets.

@colinfwren
Created October 20, 2024 19:38
Show Gist options
  • Save colinfwren/24eb896f728d967cb5fbb489b0aed38b to your computer and use it in GitHub Desktop.
Save colinfwren/24eb896f728d967cb5fbb489b0aed38b to your computer and use it in GitHub Desktop.
Unchunked Journal Entry List
import SwiftUI
import SwiftData
struct EntryListView: View {
@Query(sort: \Entry.created, order: .reverse) private var entries: [Entry]
let entryDateFormatter = DateFormatter()
init() {
entryDateFormatter.dateFormat = "EEEE, dd MMM yyyy"
}
var body: some View {
List {
ForEach(entries) { entry in
VStack(alignment: .leading, spacing: 4) {
Text(entry.text)
Text(entryDateFormatter.string(from: entry.created))
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment