fix apply labels view for macos app

This commit is contained in:
Satindar Dhillon 2022-06-27 21:27:05 -07:00
parent 39df22f4bf
commit 1ea4b63f54

View file

@ -73,6 +73,9 @@ struct ApplyLabelsView: View {
}
}
)
#if os(macOS)
.buttonStyle(PlainButtonStyle())
#endif
}
}
}
@ -81,24 +84,17 @@ struct ApplyLabelsView: View {
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .navigationBarLeading) {
Button(
action: { presentationMode.wrappedValue.dismiss() },
label: { Text("Cancel").foregroundColor(.appGrayTextContrast) }
)
cancelButton
}
ToolbarItem(placement: .navigationBarTrailing) {
Button(
action: {
switch mode {
case let .item(feedItem):
viewModel.saveItemLabelChanges(itemID: feedItem.unwrappedID, dataService: dataService)
case .list:
onSave?(viewModel.selectedLabels)
}
presentationMode.wrappedValue.dismiss()
},
label: { Text(mode.confirmButtonText).foregroundColor(.appGrayTextContrast) }
)
saveItemChangesButton
}
}
#else
.toolbar {
ToolbarItemGroup {
cancelButton
saveItemChangesButton
}
}
#endif
@ -107,21 +103,46 @@ struct ApplyLabelsView: View {
}
}
var saveItemChangesButton: some View {
Button(
action: {
switch mode {
case let .item(feedItem):
viewModel.saveItemLabelChanges(itemID: feedItem.unwrappedID, dataService: dataService)
case .list:
onSave?(viewModel.selectedLabels)
}
presentationMode.wrappedValue.dismiss()
},
label: { Text(mode.confirmButtonText).foregroundColor(.appGrayTextContrast) }
)
}
var cancelButton: some View {
Button(
action: { presentationMode.wrappedValue.dismiss() },
label: { Text("Cancel").foregroundColor(.appGrayTextContrast) }
)
}
var body: some View {
NavigationView {
if viewModel.isLoading {
EmptyView()
} else {
#if os(iOS)
innerBody
.searchable(
text: $viewModel.labelSearchFilter,
placement: .navigationBarDrawer(displayMode: .always)
)
#else
innerBody
#endif
}
Group {
#if os(iOS)
NavigationView {
if viewModel.isLoading {
EmptyView()
} else {
innerBody
.searchable(
text: $viewModel.labelSearchFilter,
placement: .navigationBarDrawer(displayMode: .always)
)
}
}
#elseif os(macOS)
innerBody
.frame(minWidth: 400, minHeight: 400)
#endif
}
.task {
switch mode {