From 9e32966e1b434c4a633f3feca58787fd9190c4c7 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Thu, 6 Jul 2023 15:45:08 -0700 Subject: [PATCH] Improve label item layout, remove label outline in dark mode --- .../Views/FeedItem/LabelsFlowLayout.swift | 20 +++++++++---------- .../Views/FeedItem/LibraryItemCard.swift | 3 +-- .../Views/FeedItem/LibraryItemLabelView.swift | 2 +- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/apple/OmnivoreKit/Sources/Views/FeedItem/LabelsFlowLayout.swift b/apple/OmnivoreKit/Sources/Views/FeedItem/LabelsFlowLayout.swift index 6c6b5c8c7..424641247 100644 --- a/apple/OmnivoreKit/Sources/Views/FeedItem/LabelsFlowLayout.swift +++ b/apple/OmnivoreKit/Sources/Views/FeedItem/LabelsFlowLayout.swift @@ -29,10 +29,10 @@ struct LabelsFlowLayout: View { var height = CGFloat.zero return ZStack(alignment: .topLeading) { - ForEach(Array(self.labelItems.enumerated()), id: \.offset) { index, label in + ForEach(Array(self.labelItems.enumerated()), id: \.offset) { _, label in self.item(for: label) - .padding(.horizontal, index == 0 ? 0 : 3) - .padding(.vertical, 5) + .padding(.trailing, 5) + .padding(.bottom, 5) .alignmentGuide(.leading, computeValue: { dim in if abs(width - dim.width) > geom.size.width { width = 0 @@ -54,21 +54,19 @@ struct LabelsFlowLayout: View { return result }) } - } - .background(viewHeightReader($totalHeight)) + }.background(viewCalculator()) } private func item(for item: LinkedItemLabel) -> some View { LibraryItemLabelView(text: item.name!, color: Color(hex: item.color!)!) } - private func viewHeightReader(_ binding: Binding) -> some View { - GeometryReader { geometry -> Color in - let rect = geometry.frame(in: .local) - DispatchQueue.main.async { - binding.wrappedValue = rect.size.height + func viewCalculator() -> some View { + GeometryReader { geometry in + Color.clear.onAppear { + let rect = geometry.frame(in: .local) + self.totalHeight = rect.size.height } - return .clear } } } diff --git a/apple/OmnivoreKit/Sources/Views/FeedItem/LibraryItemCard.swift b/apple/OmnivoreKit/Sources/Views/FeedItem/LibraryItemCard.swift index a81272123..d64a4236b 100644 --- a/apple/OmnivoreKit/Sources/Views/FeedItem/LibraryItemCard.swift +++ b/apple/OmnivoreKit/Sources/Views/FeedItem/LibraryItemCard.swift @@ -36,7 +36,7 @@ public struct LibraryItemCard: View { labels } } - .padding(.bottom, 5) + .padding(.bottom, 0) .draggableItem(item: item) } @@ -199,6 +199,5 @@ public struct LibraryItemCard: View { var labels: some View { LabelsFlowLayout(labels: item.sortedLabels) - .padding(.top, 0) } } diff --git a/apple/OmnivoreKit/Sources/Views/FeedItem/LibraryItemLabelView.swift b/apple/OmnivoreKit/Sources/Views/FeedItem/LibraryItemLabelView.swift index 4de34b2e4..aab046607 100644 --- a/apple/OmnivoreKit/Sources/Views/FeedItem/LibraryItemLabelView.swift +++ b/apple/OmnivoreKit/Sources/Views/FeedItem/LibraryItemLabelView.swift @@ -28,7 +28,7 @@ public struct LibraryItemLabelView: View { .cornerRadius(5) .overlay( RoundedRectangle(cornerRadius: 5) - .stroke(Color.themeLabelOutline, lineWidth: 1) + .stroke(Color.isDarkMode ? Color.themeLabelBackground : Color.themeLabelOutline, lineWidth: 1) ) } }