Bläddra i källkod

refactor: fix category color notice, simplify focus marking

Sam Jaffe 2 veckor sedan
förälder
incheckning
e87c52e3eb
3 ändrade filer med 8 tillägg och 18 borttagningar
  1. 2 3
      Todos/View/ProjectPanelView.swift
  2. 2 5
      Todos/View/SubTaskView.swift
  3. 4 10
      Todos/View/TaskView.swift

+ 2 - 3
Todos/View/ProjectPanelView.swift

@@ -29,9 +29,8 @@ struct ProjectPanelView: View {
         .padding(.trailing, 10)
     }
     HStack {
-      if !item.category.isEmpty {
-        let grp = $allGroups.first(where: { $0.name.wrappedValue == item.category })
-        ColorPicker("", selection: grp!.color).disabled(true).scaledToFit()
+      if let grp = $allGroups.first(where: { $0.name.wrappedValue == item.category }) {
+        ColorPicker("", selection: grp.color).disabled(true).scaledToFit()
       }
       Picker("", selection: $item.category) {
         Text(empty.name).tag("")

+ 2 - 5
Todos/View/SubTaskView.swift

@@ -33,18 +33,15 @@ struct SubTaskView: View {
         TextField("Task Name", text: $task.name)
           .focused($isFocused)
       }
-            
+
       if isFocused || !(hideNotes || task.notes.isEmpty){
         HStack {
           TextField("Notes", text: $task.notes)
             .font(.footnote)
-            .focused($isFocused)
             .padding(.leading, 30)
           VisibilityTapper(hideToggle: $hideNotes)
-            .focused($isFocused)
-        }
+        }.focused($isFocused)
       }
-      
     }
   }
 }

+ 4 - 10
Todos/View/TaskView.swift

@@ -22,9 +22,8 @@ struct TaskView: View {
   var body: some View {
     VStack {
       HStack {
-        if !task.category.isEmpty {
-          let grp = $allGroups.first(where: { $0.name.wrappedValue == task.category })
-          ColorPicker("", selection: grp!.color).disabled(true).scaledToFit()
+        if let grp = $allGroups.first(where: { $0.name.wrappedValue == task.category }) {
+          ColorPicker("", selection: grp.color).disabled(true).scaledToFit()
         }
         Image(systemName: task.status.label)
           .frame(width: 20)
@@ -55,10 +54,8 @@ struct TaskView: View {
         HStack {
           TagBarView(task: $task)
             .font(.footnote)
-            .focused($isFocused)
             .padding(.leading, 30)
           VisibilityTapper(hideToggle: $hideTags)
-            .focused($isFocused)
           if isFocused {
             Picker("", selection: $task.category) {
               Text(empty.name).tag("")
@@ -67,20 +64,17 @@ struct TaskView: View {
               }
             }
             .fixedSize(horizontal: true, vertical: false)
-            .focused($isFocused)
           }
-        }
+        }.focused($isFocused)
       }
       
       if isFocused || !(hideNotes || task.notes.isEmpty) {
         HStack {
           TextField("Notes", text: $task.notes, axis: .vertical)
             .font(.footnote)
-            .focused($isFocused)
             .padding(.leading, 30)
           VisibilityTapper(hideToggle: $hideNotes)
-            .focused($isFocused)
-        }
+        }.focused($isFocused)
       }
       
       VStack {