Skip to content

Commit 0c36340

Browse files
committed
refactor: 각 레이어별 모델 사용처 명확화
1 parent d8d5918 commit 0c36340

26 files changed

Lines changed: 411 additions & 282 deletions
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// TodoCategoryPreference.swift
3+
// DevLog
4+
//
5+
// Created by opfic on 3/30/26.
6+
//
7+
8+
import Foundation
9+
10+
struct TodoCategoryPreference: Equatable {
11+
let category: TodoCategory
12+
var isVisible: Bool
13+
}

DevLog/Domain/Entity/TodoReference.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
struct TodoReference: Equatable {
10+
struct TodoReference {
1111
let id: String
1212
let title: String
1313
let category: TodoCategory

DevLog/Presentation/Extension/TodoCategory+Presentation.swift

Lines changed: 0 additions & 61 deletions
This file was deleted.

DevLog/Presentation/Extension/UserTodoCategory+Presentation.swift

Lines changed: 0 additions & 25 deletions
This file was deleted.

DevLog/Presentation/Structure/PushNotificationItem.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,12 @@ struct PushNotificationItem: Identifiable, Hashable {
2525
self.todoId = notification.todoId
2626
self.todoCategory = notification.todoCategory
2727
}
28+
29+
static func == (lhs: PushNotificationItem, rhs: PushNotificationItem) -> Bool {
30+
lhs.id == rhs.id
31+
}
32+
33+
func hash(into hasher: inout Hasher) {
34+
hasher.combine(id)
35+
}
2836
}

DevLog/Presentation/Structure/RecentTodoItem.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,12 @@ struct RecentTodoItem: Identifiable, Hashable {
2525
self.tags = todo.tags
2626
self.category = todo.category
2727
}
28+
29+
static func == (lhs: RecentTodoItem, rhs: RecentTodoItem) -> Bool {
30+
lhs.id == rhs.id
31+
}
32+
33+
func hash(into hasher: inout Hasher) {
34+
hasher.combine(id)
35+
}
2836
}

DevLog/Presentation/Extension/SystemTodoCategory+Presentation.swift renamed to DevLog/Presentation/Structure/SystemTodoCategoryItem.swift

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
//
2-
// SystemTodoCategory+Presentation.swift
2+
// SystemTodoCategoryItem.swift
33
// DevLog
44
//
5-
// Created by opfic on 3/29/26.
5+
// Created by opfic on 3/30/26.
66
//
77

88
import SwiftUI
99

10-
extension SystemTodoCategory: Identifiable {
11-
var id: String { rawValue }
12-
}
10+
struct SystemTodoCategoryItem: Identifiable, Hashable {
11+
let systemTodoCategory: SystemTodoCategory
1312

14-
extension SystemTodoCategory: Hashable {
15-
func hash(into hasher: inout Hasher) {
16-
hasher.combine(rawValue)
13+
init(from systemTodoCategory: SystemTodoCategory) {
14+
self.systemTodoCategory = systemTodoCategory
1715
}
18-
}
1916

20-
extension SystemTodoCategory {
17+
var id: String { systemTodoCategory.rawValue }
18+
2119
var symbolName: String {
22-
switch self {
20+
switch systemTodoCategory {
2321
case .issue: return "exclamationmark.triangle"
2422
case .feature: return "sparkles"
2523
case .improvement: return "arrow.triangle.2.circlepath"
@@ -32,7 +30,7 @@ extension SystemTodoCategory {
3230
}
3331

3432
var localizedName: String {
35-
switch self {
33+
switch systemTodoCategory {
3634
case .issue: return NSLocalizedString("todo_category_issue", comment: "Todo category: Issue")
3735
case .feature: return NSLocalizedString("todo_category_feature", comment: "Todo category: Feature")
3836
case .improvement: return NSLocalizedString("todo_category_improvement", comment: "Todo category: Improvement")
@@ -45,7 +43,7 @@ extension SystemTodoCategory {
4543
}
4644

4745
var color: Color {
48-
switch self {
46+
switch systemTodoCategory {
4947
case .issue: return .red
5048
case .feature: return .green
5149
case .improvement: return .cyan

DevLog/Presentation/Structure/TodayTodoItem.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,12 @@ struct TodayTodoItem: Identifiable, Hashable {
2727
self.dueDate = todo.dueDate
2828
self.category = todo.category
2929
}
30+
31+
static func == (lhs: TodayTodoItem, rhs: TodayTodoItem) -> Bool {
32+
lhs.id == rhs.id
33+
}
34+
35+
func hash(into hasher: inout Hasher) {
36+
hasher.combine(id)
37+
}
3038
}

DevLog/Presentation/Structure/TodoCategoryPreference.swift

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
//
2+
// TodoCategoryPreferenceItem.swift
3+
// DevLog
4+
//
5+
// Created by opfic on 3/30/26.
6+
//
7+
8+
import SwiftUI
9+
10+
struct TodoCategoryPreferenceItem: Identifiable, Hashable {
11+
var category: TodoCategory
12+
var isVisible: Bool
13+
14+
init(from preference: TodoCategoryPreference) {
15+
self.category = preference.category
16+
self.isVisible = preference.isVisible
17+
}
18+
19+
init(
20+
from category: TodoCategory,
21+
isVisible: Bool = true
22+
) {
23+
self.category = category
24+
self.isVisible = isVisible
25+
}
26+
27+
var id: String { category.storageValue }
28+
29+
var todoCategory: TodoCategory { category }
30+
31+
var preference: TodoCategoryPreference {
32+
TodoCategoryPreference(
33+
category: category,
34+
isVisible: isVisible
35+
)
36+
}
37+
38+
var isUserCategory: Bool {
39+
if case .user = category {
40+
return true
41+
}
42+
43+
return false
44+
}
45+
46+
var symbolName: String {
47+
switch category {
48+
case .system(let systemTodoCategory):
49+
return SystemTodoCategoryItem(from: systemTodoCategory).symbolName
50+
case .user(let userTodoCategory):
51+
return UserTodoCategoryItem(from: userTodoCategory).symbolName
52+
}
53+
}
54+
55+
var localizedName: String {
56+
switch category {
57+
case .system(let systemTodoCategory):
58+
return SystemTodoCategoryItem(from: systemTodoCategory).localizedName
59+
case .user(let userTodoCategory):
60+
return UserTodoCategoryItem(from: userTodoCategory).localizedName
61+
}
62+
}
63+
64+
var color: Color {
65+
switch category {
66+
case .system(let systemTodoCategory):
67+
return SystemTodoCategoryItem(from: systemTodoCategory).color
68+
case .user(let userTodoCategory):
69+
return UserTodoCategoryItem(from: userTodoCategory).color
70+
}
71+
}
72+
73+
static func == (lhs: TodoCategoryPreferenceItem, rhs: TodoCategoryPreferenceItem) -> Bool {
74+
lhs.category == rhs.category && lhs.isVisible == rhs.isVisible
75+
}
76+
77+
func hash(into hasher: inout Hasher) {
78+
hasher.combine(id)
79+
80+
switch category {
81+
case .system(let systemTodoCategory):
82+
hasher.combine(systemTodoCategory.rawValue)
83+
case .user(let userTodoCategory):
84+
hasher.combine(userTodoCategory.name)
85+
hasher.combine(userTodoCategory.colorHex)
86+
}
87+
88+
hasher.combine(isVisible)
89+
}
90+
}

0 commit comments

Comments
 (0)