diff --git a/App/Entity/Tag.swift b/App/Entity/Tag.swift index 043fc7c8..390c2023 100644 --- a/App/Entity/Tag.swift +++ b/App/Entity/Tag.swift @@ -23,3 +23,9 @@ extension Tag { @NSManaged dynamic var label: String @NSManaged dynamic var slug: String } + +extension Tag: Comparable { + static func < (lhs: Tag, rhs: Tag) -> Bool { + lhs.label < rhs.label + } +} diff --git a/App/Features/Entry/EntryRowView.swift b/App/Features/Entry/EntryRowView.swift index dd7673a5..6e608df1 100644 --- a/App/Features/Entry/EntryRowView.swift +++ b/App/Features/Entry/EntryRowView.swift @@ -25,6 +25,25 @@ struct EntryRowView: View { .font(.footnote) Spacer() } + ScrollView(.horizontal) { + HStack { + ForEach(entry.tags.sorted(by: >)) { tag in + HStack(spacing: 2) { + Image(systemName: "tag") + Text(tag.label) + } + .foregroundStyle(Color.primary) + .padding(4) + .background( + Capsule() + .fill(Color.gray.quaternary) + .clipped() + ) + .clipShape(Capsule()) + .font(.footnote) + } + } + } } } }