mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Fix labels layout on iOS
This commit is contained in:
parent
4c16810048
commit
ce711dd354
3 changed files with 78 additions and 80 deletions
|
|
@ -98,7 +98,9 @@ public struct EditLabelsSheet: View {
|
|||
}
|
||||
.listStyle(.plain)
|
||||
.background(Color.extensionBackground)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
}.frame(maxHeight: .infinity)
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
|
|
|
|||
|
|
@ -64,49 +64,60 @@ struct ApplyLabelsView: View {
|
|||
}
|
||||
|
||||
List {
|
||||
Section {
|
||||
ForEach(viewModel.labels.applySearchFilter(viewModel.labelSearchFilter), id: \.self) { label in
|
||||
Button(
|
||||
action: {
|
||||
if isSelected(label) {
|
||||
if let idx = viewModel.selectedLabels.firstIndex(of: label) {
|
||||
viewModel.selectedLabels.remove(at: idx)
|
||||
}
|
||||
} else {
|
||||
viewModel.labelSearchFilter = ZWSP
|
||||
viewModel.selectedLabels.append(label)
|
||||
ForEach(viewModel.labels.applySearchFilter(viewModel.labelSearchFilter), id: \.self) { label in
|
||||
Button(
|
||||
action: {
|
||||
if isSelected(label) {
|
||||
if let idx = viewModel.selectedLabels.firstIndex(of: label) {
|
||||
viewModel.selectedLabels.remove(at: idx)
|
||||
}
|
||||
},
|
||||
label: {
|
||||
HStack {
|
||||
TextChip(feedItemLabel: label).allowsHitTesting(false)
|
||||
Spacer()
|
||||
if isSelected(label) {
|
||||
Image(systemName: "checkmark")
|
||||
}
|
||||
}
|
||||
.contentShape(Rectangle())
|
||||
} else {
|
||||
viewModel.labelSearchFilter = ZWSP
|
||||
viewModel.selectedLabels.append(label)
|
||||
}
|
||||
)
|
||||
.padding(.vertical, 5)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
#if os(macOS)
|
||||
.buttonStyle(PlainButtonStyle())
|
||||
#endif
|
||||
}
|
||||
},
|
||||
label: {
|
||||
HStack {
|
||||
TextChip(feedItemLabel: label).allowsHitTesting(false)
|
||||
Spacer()
|
||||
if isSelected(label) {
|
||||
Image(systemName: "checkmark")
|
||||
}
|
||||
}
|
||||
.contentShape(Rectangle())
|
||||
}
|
||||
)
|
||||
.padding(.vertical, 5)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
#if os(macOS)
|
||||
.buttonStyle(PlainButtonStyle())
|
||||
#endif
|
||||
}
|
||||
if !viewModel.labelSearchFilter.isEmpty, viewModel.labelSearchFilter != ZWSP {
|
||||
createLabelButton
|
||||
}
|
||||
}
|
||||
.listStyle(.plain)
|
||||
.background(Color.extensionBackground)
|
||||
|
||||
Spacer()
|
||||
.frame(maxHeight: .infinity)
|
||||
}
|
||||
.navigationTitle(mode.navTitle)
|
||||
.background(Color.extensionBackground)
|
||||
.sheet(isPresented: $viewModel.showCreateLabelModal) {
|
||||
CreateLabelView(viewModel: viewModel, newLabelName: viewModel.labelSearchFilter)
|
||||
}
|
||||
.onAppear {
|
||||
Task {
|
||||
switch mode {
|
||||
case let .item(feedItem):
|
||||
await viewModel.loadLabels(dataService: dataService, item: feedItem)
|
||||
case let .highlight(highlight):
|
||||
await viewModel.loadLabels(dataService: dataService, highlight: highlight)
|
||||
case let .list(labels):
|
||||
await viewModel.loadLabels(dataService: dataService, initiallySelectedLabels: labels)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var createLabelButton: some View {
|
||||
|
|
@ -160,43 +171,29 @@ struct ApplyLabelsView: View {
|
|||
}
|
||||
|
||||
var body: some View {
|
||||
Group {
|
||||
#if os(iOS)
|
||||
NavigationView {
|
||||
innerBody
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
cancelButton
|
||||
}
|
||||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
saveItemChangesButton
|
||||
}
|
||||
}
|
||||
}
|
||||
#elseif os(macOS)
|
||||
#if os(iOS)
|
||||
NavigationView {
|
||||
innerBody
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar {
|
||||
ToolbarItemGroup {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
cancelButton
|
||||
}
|
||||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
saveItemChangesButton
|
||||
}
|
||||
}
|
||||
.frame(minWidth: 400, minHeight: 600)
|
||||
#endif
|
||||
}
|
||||
.onAppear {
|
||||
Task {
|
||||
switch mode {
|
||||
case let .item(feedItem):
|
||||
await viewModel.loadLabels(dataService: dataService, item: feedItem)
|
||||
case let .highlight(highlight):
|
||||
await viewModel.loadLabels(dataService: dataService, highlight: highlight)
|
||||
case let .list(labels):
|
||||
await viewModel.loadLabels(dataService: dataService, initiallySelectedLabels: labels)
|
||||
}
|
||||
}
|
||||
}
|
||||
#elseif os(macOS)
|
||||
innerBody
|
||||
.toolbar {
|
||||
ToolbarItemGroup {
|
||||
cancelButton
|
||||
saveItemChangesButton
|
||||
}
|
||||
}
|
||||
.frame(minWidth: 400, minHeight: 600)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -126,6 +126,8 @@ public struct LabelsEntryView: View {
|
|||
.frame(width: textWidth)
|
||||
.padding(.trailing, 5)
|
||||
.padding(.vertical, 5)
|
||||
.padding(EdgeInsets(top: 0, leading: 6, bottom: 0, trailing: 6))
|
||||
.cornerRadius(5)
|
||||
.accentColor(.blue)
|
||||
.font(Font.system(size: 14))
|
||||
.multilineTextAlignment(.leading)
|
||||
|
|
@ -162,8 +164,7 @@ public struct LabelsEntryView: View {
|
|||
}
|
||||
#endif
|
||||
}
|
||||
.submitScope()
|
||||
)
|
||||
.submitScope())
|
||||
|
||||
#if os(macOS)
|
||||
if #available(macOS 14.0, *) {
|
||||
|
|
@ -187,23 +188,21 @@ public struct LabelsEntryView: View {
|
|||
}
|
||||
|
||||
public var body: some View {
|
||||
Form {
|
||||
VStack {
|
||||
GeometryReader { geometry in
|
||||
self.generateLabelsContent(in: geometry)
|
||||
}
|
||||
}.padding(0)
|
||||
.frame(height: totalHeight)
|
||||
.background(Color.extensionPanelBackground)
|
||||
.cornerRadius(8)
|
||||
.onAppear {
|
||||
textFieldFocused = true
|
||||
}
|
||||
.onTapGesture {
|
||||
textFieldFocused = true
|
||||
}
|
||||
.onChange(of: textFieldFocused) { self.isFocused = $0 }
|
||||
}
|
||||
VStack {
|
||||
GeometryReader { geometry in
|
||||
self.generateLabelsContent(in: geometry)
|
||||
}
|
||||
}.padding(0)
|
||||
.frame(height: totalHeight)
|
||||
.background(Color.extensionPanelBackground)
|
||||
.cornerRadius(8)
|
||||
.onAppear {
|
||||
textFieldFocused = true
|
||||
}
|
||||
.onTapGesture {
|
||||
textFieldFocused = true
|
||||
}
|
||||
.onChange(of: textFieldFocused) { self.isFocused = $0 }
|
||||
}
|
||||
|
||||
var partialMatches: [LinkedItemLabel] {
|
||||
|
|
|
|||
Loading…
Reference in a new issue