Browse Source

feat: notify the user when popover settings are active

Sam Jaffe 2 tuần trước cách đây
mục cha
commit
eb30d3532c
2 tập tin đã thay đổi với 28 bổ sung0 xóa
  1. 18 0
      Todos/View/ProjectPanelView.swift
  2. 10 0
      Todos/ViewModel/StatusList.swift

+ 18 - 0
Todos/View/ProjectPanelView.swift

@@ -31,6 +31,24 @@ struct ProjectPanelView: View {
       }
       .help("New Task")
       .padding(.trailing, 10)
+      if move {
+        Label("", systemImage: "arrow.up.arrow.down")
+          .foregroundStyle(.red)
+          .font(.title2)
+          .help("Re-ordering mode is enabled, text fields will be unresponsive")
+      }
+      if !taskFilter.isEmpty {
+        Label("", systemImage: "text.magnifyingglass")
+          .foregroundStyle(.blue)
+          .font(.title2)
+          .help("Only showing text matching '\(taskFilter)'")
+      }
+      if !statuses.all {
+        Label("", systemImage: "exclamationmark.magnifyingglass")
+          .foregroundStyle(.blue)
+          .font(.title2)
+          .help(statuses.description)
+      }
       Button {
         showDialogue = !showDialogue
       } label: {

+ 10 - 0
Todos/ViewModel/StatusList.swift

@@ -19,6 +19,16 @@ final class StatusList {
   
   init() {}
   
+  var all: Bool {
+    Status.allCases.map({ test($0) }).allSatisfy({ $0 })
+  }
+  
+  var description: String {
+    let unset = Status.allCases.filter({ !test($0) })
+    return "Hiding status\(unset.count == 1 ? "" : "es"): " +
+      unset.map(\.description).joined(separator: ", ")
+  }
+
   func test(_ index: Status) -> Bool {
     switch (index) {
     case .todo: return todo