mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
apply correct tint colors to label modal buttons
This commit is contained in:
parent
5cbfca1fa9
commit
e9589fd7f3
3 changed files with 27 additions and 27 deletions
|
|
@ -18,36 +18,36 @@ struct ApplyLabelsView: View {
|
|||
} else {
|
||||
List {
|
||||
Section(header: Text("Assigned Labels")) {
|
||||
if viewModel.selectedLabels.isEmpty {
|
||||
if viewModel.selectedLabelsForItemInContext.isEmpty {
|
||||
Text("No labels are currently assigned.")
|
||||
}
|
||||
ForEach(viewModel.selectedLabels, id: \.self) { label in
|
||||
ForEach(viewModel.selectedLabelsForItemInContext, id: \.self) { label in
|
||||
HStack {
|
||||
TextChip(feedItemLabel: label)
|
||||
Spacer()
|
||||
Button(
|
||||
action: {
|
||||
withAnimation {
|
||||
viewModel.removeLabel(label)
|
||||
viewModel.removeLabelFromItem(label)
|
||||
}
|
||||
},
|
||||
label: { Image(systemName: "trash") }
|
||||
label: { Image(systemName: "trash").foregroundColor(.appGrayTextContrast) }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Section(header: Text("Available Labels")) {
|
||||
ForEach(viewModel.unselectedLabels, id: \.self) { label in
|
||||
ForEach(viewModel.unselectedLabelsForItemInContext, id: \.self) { label in
|
||||
HStack {
|
||||
TextChip(feedItemLabel: label)
|
||||
Spacer()
|
||||
Button(
|
||||
action: {
|
||||
withAnimation {
|
||||
viewModel.addLabel(label)
|
||||
viewModel.addLabelToItem(label)
|
||||
}
|
||||
},
|
||||
label: { Image(systemName: "plus") }
|
||||
label: { Image(systemName: "plus").foregroundColor(.appGrayTextContrast) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ struct ApplyLabelsView: View {
|
|||
label: {
|
||||
HStack {
|
||||
Image(systemName: "plus.circle.fill").foregroundColor(.green)
|
||||
Text("Create a new Label")
|
||||
Text("Create a new Label").foregroundColor(.appGrayTextContrast)
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
|
|
@ -72,18 +72,18 @@ struct ApplyLabelsView: View {
|
|||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
Button(
|
||||
action: { presentationMode.wrappedValue.dismiss() },
|
||||
label: { Text("Cancel") }
|
||||
label: { Text("Cancel").foregroundColor(.appGrayTextContrast) }
|
||||
)
|
||||
}
|
||||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
Button(
|
||||
action: {
|
||||
viewModel.saveChanges(itemID: item.id, dataService: dataService) { labels in
|
||||
viewModel.saveItemLabelChanges(itemID: item.id, dataService: dataService) { labels in
|
||||
commitLabelChanges(labels)
|
||||
presentationMode.wrappedValue.dismiss()
|
||||
}
|
||||
},
|
||||
label: { Text("Save") }
|
||||
label: { Text("Save").foregroundColor(.appGrayTextContrast) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -93,7 +93,7 @@ struct ApplyLabelsView: View {
|
|||
}
|
||||
}
|
||||
.onAppear {
|
||||
viewModel.load(item: item, dataService: dataService)
|
||||
viewModel.loadLabelForItem(item: item, dataService: dataService)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ struct LabelsView: View {
|
|||
label: {
|
||||
HStack {
|
||||
Image(systemName: "plus.circle.fill").foregroundColor(.green)
|
||||
Text("Create a new Label")
|
||||
Text("Create a new Label").foregroundColor(.appGrayTextContrast)
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ import Views
|
|||
final class LabelsViewModel: ObservableObject {
|
||||
private var hasLoadedInitialLabels = false
|
||||
@Published var isLoading = false
|
||||
@Published var selectedLabels = [FeedItemLabel]()
|
||||
@Published var unselectedLabels = [FeedItemLabel]()
|
||||
@Published var selectedLabelsForItemInContext = [FeedItemLabel]()
|
||||
@Published var unselectedLabelsForItemInContext = [FeedItemLabel]()
|
||||
@Published var labels = [FeedItemLabel]()
|
||||
@Published var showCreateEmailModal = false
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ final class LabelsViewModel: ObservableObject {
|
|||
.store(in: &subscriptions)
|
||||
}
|
||||
|
||||
func load(item: FeedItem, dataService: DataService) {
|
||||
func loadLabelForItem(item: FeedItem, dataService: DataService) {
|
||||
guard !hasLoadedInitialLabels else { return }
|
||||
|
||||
dataService.labelsPublisher().sink(
|
||||
|
|
@ -37,8 +37,8 @@ final class LabelsViewModel: ObservableObject {
|
|||
receiveValue: { [weak self] allLabels in
|
||||
self?.isLoading = false
|
||||
self?.hasLoadedInitialLabels = true
|
||||
self?.selectedLabels = item.labels
|
||||
self?.unselectedLabels = allLabels.filter { !item.labels.contains($0) }
|
||||
self?.selectedLabelsForItemInContext = item.labels
|
||||
self?.unselectedLabelsForItemInContext = allLabels.filter { !item.labels.contains($0) }
|
||||
}
|
||||
)
|
||||
.store(in: &subscriptions)
|
||||
|
|
@ -58,7 +58,7 @@ final class LabelsViewModel: ObservableObject {
|
|||
receiveValue: { [weak self] result in
|
||||
self?.isLoading = false
|
||||
self?.labels.insert(result, at: 0)
|
||||
self?.unselectedLabels.insert(result, at: 0)
|
||||
self?.unselectedLabelsForItemInContext.insert(result, at: 0)
|
||||
self?.showCreateEmailModal = false
|
||||
}
|
||||
)
|
||||
|
|
@ -80,9 +80,9 @@ final class LabelsViewModel: ObservableObject {
|
|||
.store(in: &subscriptions)
|
||||
}
|
||||
|
||||
func saveChanges(itemID: String, dataService: DataService, onComplete: @escaping ([FeedItemLabel]) -> Void) {
|
||||
func saveItemLabelChanges(itemID: String, dataService: DataService, onComplete: @escaping ([FeedItemLabel]) -> Void) {
|
||||
isLoading = true
|
||||
dataService.updateArticleLabelsPublisher(itemID: itemID, labelIDs: selectedLabels.map(\.id)).sink(
|
||||
dataService.updateArticleLabelsPublisher(itemID: itemID, labelIDs: selectedLabelsForItemInContext.map(\.id)).sink(
|
||||
receiveCompletion: { [weak self] _ in
|
||||
self?.isLoading = false
|
||||
},
|
||||
|
|
@ -91,13 +91,13 @@ final class LabelsViewModel: ObservableObject {
|
|||
.store(in: &subscriptions)
|
||||
}
|
||||
|
||||
func addLabel(_ label: FeedItemLabel) {
|
||||
selectedLabels.insert(label, at: 0)
|
||||
unselectedLabels.removeAll { $0.id == label.id }
|
||||
func addLabelToItem(_ label: FeedItemLabel) {
|
||||
selectedLabelsForItemInContext.insert(label, at: 0)
|
||||
unselectedLabelsForItemInContext.removeAll { $0.id == label.id }
|
||||
}
|
||||
|
||||
func removeLabel(_ label: FeedItemLabel) {
|
||||
unselectedLabels.insert(label, at: 0)
|
||||
selectedLabels.removeAll { $0.id == label.id }
|
||||
func removeLabelFromItem(_ label: FeedItemLabel) {
|
||||
unselectedLabelsForItemInContext.insert(label, at: 0)
|
||||
selectedLabelsForItemInContext.removeAll { $0.id == label.id }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue