diff --git a/apple/OmnivoreKit/Sources/App/Views/Labels/LabelsViewModel.swift b/apple/OmnivoreKit/Sources/App/Views/Labels/LabelsViewModel.swift index 92aa9df2a..e0a7aa062 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Labels/LabelsViewModel.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Labels/LabelsViewModel.swift @@ -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) diff --git a/apple/OmnivoreKit/Sources/Models/DataModels/FeedItem.swift b/apple/OmnivoreKit/Sources/Models/DataModels/FeedItem.swift index 1e1fd0363..c6b8421a3 100644 --- a/apple/OmnivoreKit/Sources/Models/DataModels/FeedItem.swift +++ b/apple/OmnivoreKit/Sources/Models/DataModels/FeedItem.swift @@ -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 [ diff --git a/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift b/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift index f9e5c49ba..bd1f03cd1 100644 --- a/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift +++ b/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift @@ -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) } diff --git a/apple/OmnivoreKit/Sources/Views/FeedItem/HomeFeedCardView.swift b/apple/OmnivoreKit/Sources/Views/FeedItem/HomeFeedCardView.swift index 9bf95af7d..afb3f2916 100644 --- a/apple/OmnivoreKit/Sources/Views/FeedItem/HomeFeedCardView.swift +++ b/apple/OmnivoreKit/Sources/Views/FeedItem/HomeFeedCardView.swift @@ -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() diff --git a/apple/OmnivoreKit/Sources/Views/TextChip.swift b/apple/OmnivoreKit/Sources/Views/TextChip.swift index f318d7902..4e0ada9c4 100644 --- a/apple/OmnivoreKit/Sources/Views/TextChip.swift +++ b/apple/OmnivoreKit/Sources/Views/TextChip.swift @@ -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) }