mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Merge pull request #560 from omnivore-app/fix/card-label-display-issues
This commit is contained in:
commit
b3d699e679
5 changed files with 11 additions and 10 deletions
|
|
@ -22,7 +22,7 @@ import Views
|
|||
dataService.viewContext.performAndWait {
|
||||
self.labels = labelIDs.compactMap { dataService.viewContext.object(with: $0) as? LinkedItemLabel }
|
||||
}
|
||||
let selLabels = initiallySelectedLabels ?? item?.labels.asArray(of: LinkedItemLabel.self) ?? []
|
||||
let selLabels = initiallySelectedLabels ?? item?.sortedLabels ?? []
|
||||
for label in labels {
|
||||
if selLabels.contains(label) {
|
||||
selectedLabels.append(label)
|
||||
|
|
|
|||
|
|
@ -58,6 +58,12 @@ public extension LinkedItem {
|
|||
return URL(string: pageURLString ?? "")
|
||||
}
|
||||
|
||||
var sortedLabels: [LinkedItemLabel] {
|
||||
labels.asArray(of: LinkedItemLabel.self).sorted {
|
||||
($0.name ?? "").lowercased() < ($1.name ?? "").lowercased()
|
||||
}
|
||||
}
|
||||
|
||||
var labelsJSONString: String {
|
||||
let labels = self.labels.asArray(of: LinkedItemLabel.self).map { label in
|
||||
[
|
||||
|
|
|
|||
|
|
@ -151,12 +151,11 @@ public struct GridCard: View {
|
|||
// Category Labels
|
||||
ScrollView(.horizontal, showsIndicators: false) {
|
||||
HStack {
|
||||
ForEach(item.labels.asArray(of: LinkedItemLabel.self), id: \.self) {
|
||||
ForEach(item.sortedLabels, id: \.self) {
|
||||
TextChip(feedItemLabel: $0)
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
.frame(height: 30)
|
||||
.padding(.horizontal)
|
||||
.padding(.bottom, 8)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public struct FeedCard: View {
|
|||
// Category Labels
|
||||
ScrollView(.horizontal, showsIndicators: false) {
|
||||
HStack {
|
||||
ForEach(item.labels.asArray(of: LinkedItemLabel.self), id: \.self) {
|
||||
ForEach(item.sortedLabels, id: \.self) {
|
||||
TextChip(feedItemLabel: $0)
|
||||
}
|
||||
Spacer()
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ public struct TextChip: View {
|
|||
|
||||
let text: String
|
||||
let color: Color
|
||||
let cornerRadius = 20.0
|
||||
|
||||
public var body: some View {
|
||||
Text(text)
|
||||
|
|
@ -26,8 +25,7 @@ public struct TextChip: View {
|
|||
.font(.appFootnote)
|
||||
.foregroundColor(color.isDark ? .white : .black)
|
||||
.lineLimit(1)
|
||||
.background(color)
|
||||
.cornerRadius(cornerRadius)
|
||||
.background(Capsule().fill(color))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -86,7 +84,6 @@ public struct TextChipButton: View {
|
|||
let color: Color
|
||||
let onTap: () -> Void
|
||||
let actionType: ActionType
|
||||
let cornerRadius = 20.0
|
||||
let foregroundColor: Color
|
||||
|
||||
public var body: some View {
|
||||
|
|
@ -102,8 +99,7 @@ public struct TextChipButton: View {
|
|||
.font(.appFootnote)
|
||||
.foregroundColor(foregroundColor)
|
||||
.lineLimit(1)
|
||||
.background(color)
|
||||
.cornerRadius(cornerRadius)
|
||||
.background(Capsule().fill(color))
|
||||
|
||||
Color.clear.contentShape(Rectangle()).frame(height: 15)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue