Просмотр исходного кода

refactor: rename Group => Category

Sam Jaffe 2 недель назад
Родитель
Сommit
ecb661219c

+ 2 - 2
Todos/Model/Group.swift

@@ -1,5 +1,5 @@
 //
-//  Group.swift
+//  Category.swift
 //  Todos
 //
 //  Created by Sam Jaffe on 3/2/26.
@@ -99,7 +99,7 @@ extension Color: @retroactive Codable {
   }
 }
 
-final class Group : Identifiable, Codable {
+final class Category : Identifiable, Codable {
   var name: String = ""
   var color: Color = Color(.gray)
   

+ 4 - 4
Todos/View/Settings/CategoryGroupView.swift

@@ -8,11 +8,11 @@
 import SwiftUI
 
 struct CategoryGroupView: View {
-  @State var allGroups = [Group]()
-  @State var active = Group()
+  @State var allGroups = [Category]()
+  @State var active = Category()
   
   var body: some View {
-    Table(of: Binding<Group>.self) {
+    Table(of: Binding<Category>.self) {
       TableColumn("Color") { group in
         ColorPicker("", selection: group.color, supportsOpacity: false)
       }
@@ -40,7 +40,7 @@ struct CategoryGroupView: View {
   private func addGroup() {
     if active.valid {
       allGroups.append(active)
-      active = Group()
+      active = Category()
     }
   }
 }

+ 1 - 1
Todos/View/SettingsView.swift

@@ -10,7 +10,7 @@ import SwiftUI
 struct SettingsView: View {
   var body: some View {
     TabView {
-      Tab("Group", systemImage: "link") {
+      Tab("Category", systemImage: "folder") {
         CategoryGroupView()
       }
       Tab("URL Hints", systemImage: "link") {

+ 3 - 3
Todos/ViewModel/URLHintArray.swift

@@ -9,7 +9,7 @@ import Foundation
 import SwiftData
 internal import Combine
 
-typealias URLHintArray = [URLHint]
+typealias CodableArray = [URLHint]
 
 /**
  * @brief Provides a UserDefaults-compatibiliy layer for Array<URLHint> that
@@ -23,10 +23,10 @@ typealias URLHintArray = [URLHint]
  * The \@retroactive guards against the Swift developers changing Array<T> to
  * comply w/ RawRepresentable in the future
  */
-extension URLHintArray : @retroactive RawRepresentable {
+extension CodableArray : @retroactive RawRepresentable {
   public init?(rawValue: String) {
     guard let data = rawValue.data(using: .utf8),
-          let result = try? JSONDecoder().decode(URLHintArray.self, from: data)
+          let result = try? JSONDecoder().decode(CodableArray.self, from: data)
     else {
       return nil
     }