Skip to content

Commit

Permalink
Add tag in entries list
Browse files Browse the repository at this point in the history
  • Loading branch information
bourvill committed Feb 8, 2024
1 parent 1639f1f commit 8851be4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions App/Entity/Tag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
19 changes: 19 additions & 0 deletions App/Features/Entry/EntryRowView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
}
}
}
Expand Down

0 comments on commit 8851be4

Please sign in to comment.