Created
October 20, 2024 19:38
-
-
Save colinfwren/24eb896f728d967cb5fbb489b0aed38b to your computer and use it in GitHub Desktop.
Unchunked Journal Entry List
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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