mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Improve label item layout, remove label outline in dark mode
This commit is contained in:
parent
e4b86ecf34
commit
9e32966e1b
3 changed files with 11 additions and 14 deletions
|
|
@ -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<CGFloat>) -> 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue