Skip to content

Commit 4f5915d

Browse files
author
현수빈
committed
[Fix] #72 - 메인 화면 리스트별 다른 컬러 적용
1 parent 06b7f28 commit 4f5915d

File tree

12 files changed

+174
-27
lines changed

12 files changed

+174
-27
lines changed

Projects/Feature/Home/Sources/DetailChecklist/DetailChecklistStore.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public struct DetailChecklistStore {
1717

1818
@ObservableState
1919
public struct State {
20+
var index: Int
2021
var card: Card
2122
var isPresentDeleteCheckBoxAlert: Bool = false
2223
var willDeleteCheckBox: CheckBox?

Projects/Feature/Home/Sources/DetailChecklist/DetailChecklistView.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ import ComposableArchitecture
1414

1515
struct DetailChecklistView: View {
1616
@Bindable private var store: StoreOf<DetailChecklistStore>
17+
private let colorType: ChecklistColorType
1718

1819
init(store: StoreOf<DetailChecklistStore>) {
1920
self.store = store
21+
self.colorType = ChecklistColorType(index: store.index)
2022
}
2123

2224
var body: some View {
@@ -48,6 +50,7 @@ struct DetailChecklistView: View {
4850
DetailColorChecklistCellView(
4951
title: checkBox.label,
5052
isSelected: checkBox.isCompleted,
53+
colorType: colorType,
5154
onToggle: {
5255
store.send(.didTapChecklistCompleteButton(checkBox: checkBox))
5356
},

Projects/Feature/Home/Sources/Home/HomeStore.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public struct HomeStore {
8383

8484
// MARK: - Delegate Actions(parent)
8585

86-
case onNaviagteToDetailChecklist(card: Card)
86+
case onNaviagteToDetailChecklist(card: Card, index: Int)
8787
case onRouteToHistoryScreen
8888

8989
// MARK: - Scope Actions(child)
@@ -141,7 +141,9 @@ public struct HomeStore {
141141
return .none
142142

143143
case .didTapNavigateToDetailChecklist(let card):
144-
return .send(.onNaviagteToDetailChecklist(card: card))
144+
guard let index = state.cards.firstIndex(of: card)
145+
else { return .none }
146+
return .send(.onNaviagteToDetailChecklist(card: card, index: index))
145147

146148
case .fetchData:
147149
return .run { send in

Projects/Feature/Home/Sources/Home/Views/Checklist/CardProgressView.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,19 @@
77

88
import SwiftUI
99

10+
import SharedDesignSystem
11+
1012
struct CardProgressView: View {
1113
private let progress: CGFloat
1214
private let isSelected: Bool
15+
private let colorType: ChecklistColorType
1316

1417
init(
18+
colorType: ChecklistColorType,
1519
isSelected: Bool,
1620
progress: CGFloat
1721
) {
22+
self.colorType = colorType
1823
self.isSelected = isSelected
1924
self.progress = progress
2025
}
@@ -29,7 +34,7 @@ struct CardProgressView: View {
2934
Circle()
3035
.trim(from: 0, to: progress)
3136
.stroke(
32-
isSelected ? .primary800 : .greyScale400,
37+
isSelected ? colorType.cardTintColor : .greyScale400,
3338
style: StrokeStyle(lineWidth: 8, lineCap: .butt, lineJoin: .bevel)
3439
)
3540
.rotationEffect(.degrees(-90))
@@ -42,7 +47,7 @@ struct CardProgressView: View {
4247
Text("%")
4348
.notoSans(.subhead_2)
4449
}
45-
.foregroundStyle(isSelected ? .primary800 : .greyScale400)
50+
.foregroundStyle(isSelected ? colorType.cardTintColor : .greyScale400)
4651
}
4752
}
4853
}

Projects/Feature/Home/Sources/Home/Views/Checklist/CardView.swift

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,23 @@
77

88
import SwiftUI
99

10+
import SharedDesignSystem
11+
1012
struct CardView: View {
1113
private let title: String
1214
private let isSelected: Bool
1315
private let progress: CGFloat
1416
private let onTap: () -> Void
17+
private let colorType: ChecklistColorType
1518

1619
init(
20+
colorType: ChecklistColorType,
1721
title: String,
1822
isSelected: Bool,
1923
progress: CGFloat,
2024
onTap: @escaping () -> Void
2125
) {
26+
self.colorType = colorType
2227
self.title = title
2328
self.isSelected = isSelected
2429
self.progress = progress
@@ -31,21 +36,47 @@ struct CardView: View {
3136
}) {
3237
HStack(spacing: .zero) {
3338
VStack(alignment: .leading, spacing: 10) {
34-
CardProgressView(isSelected: isSelected, progress: progress)
39+
CardProgressView(colorType: colorType, isSelected: isSelected, progress: progress)
3540
.padding(.top, 14)
3641

3742
Text(title)
3843
.notoSans(.subhead_3)
39-
.foregroundStyle(isSelected ? .primary800 : .greyScale600)
44+
.foregroundStyle(isSelected ? colorType.cardTintColor : .greyScale600)
4045
}
4146
Spacer()
4247
}
4348
}
4449
.padding(.horizontal, 12)
4550
.frame(width: 162, height: 120)
46-
.background(isSelected ? .primary100 : .greyScale050)
51+
.background(isSelected ? colorType.cardColor : .greyScale050)
4752
.clipShape(
4853
.rect(cornerRadius: 10)
4954
)
5055
}
5156
}
57+
58+
extension ChecklistColorType {
59+
60+
// MARK: - 카드 색상
61+
var cardColor: Color {
62+
switch self {
63+
case .blue:
64+
return Color.primary100
65+
case .green:
66+
return Color(hex: "EFFAF3")
67+
case .orange:
68+
return Color(hex: "FBF1D2")
69+
}
70+
}
71+
72+
var cardTintColor: Color {
73+
switch self {
74+
case .blue:
75+
return Color.primary800
76+
case .green:
77+
return Color(hex: "84E1AF")
78+
case .orange:
79+
return Color(hex: "F07603")
80+
}
81+
}
82+
}

Projects/Feature/Home/Sources/Home/Views/Checklist/ChecklistList.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,18 @@ import ComposableArchitecture
1414
struct ChecklistList: View {
1515
@Bindable private var store: StoreOf<HomeStore>
1616
private let width: CGFloat
17+
private let colorType: ChecklistColorType
1718

1819
init(store: StoreOf<HomeStore>, width: CGFloat) {
1920
self.store = store
2021
self.width = width
22+
23+
if let selected = store.selectedCard,
24+
let index = store.cards.firstIndex(of: selected) {
25+
self.colorType = ChecklistColorType(index: index)
26+
} else {
27+
self.colorType = .blue
28+
}
2129
}
2230

2331
var body: some View {
@@ -43,7 +51,8 @@ struct ChecklistList: View {
4351
isSelected: checkBox.isCompleted,
4452
onToggle: {
4553
store.send(.didTapChecklistCompleteButton(checkBox: checkBox))
46-
}
54+
},
55+
colorType: colorType
4756
)
4857
}
4958
}

Projects/Feature/Home/Sources/Home/Views/HeaderView.swift

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

88
import SwiftUI
99

10+
import SharedDesignSystem
11+
1012
import ComposableArchitecture
1113

1214
struct HeaderView: View {
@@ -85,8 +87,11 @@ struct HeaderView: View {
8587

8688
ScrollView(.horizontal, showsIndicators: false) {
8789
HStack(spacing: 8) {
88-
ForEach(store.cards) { card in
90+
ForEach(0..<store.cards.count) { i in
91+
let card = store.cards[i]
92+
let colorType: ChecklistColorType = .init(index: i)
8993
CardView(
94+
colorType: colorType,
9095
title: card.title,
9196
isSelected: store.selectedCard == card,
9297
progress: card.progress,

Projects/Feature/Home/Sources/HomeRootStore.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public struct HomeRootStore {
3737

3838
// MARK: - Navigation
3939

40-
case navigateToDetailChecklist(card: Card)
40+
case navigateToDetailChecklist(card: Card, index: Int)
4141
}
4242

4343
@Reducer
@@ -61,8 +61,8 @@ public struct HomeRootStore {
6161
case .onPresentChat:
6262
return .send(.onPresentChat)
6363

64-
case .onNaviagteToDetailChecklist(let card):
65-
return .send(.navigateToDetailChecklist(card: card))
64+
case .onNaviagteToDetailChecklist(let card, let index):
65+
return .send(.navigateToDetailChecklist(card: card, index: index))
6666

6767
default:
6868
return .none
@@ -71,8 +71,8 @@ public struct HomeRootStore {
7171
case .onAppendChecklist(let checklist):
7272
return .send(.home(.onAppendNewChecklist(checklist: checklist)))
7373

74-
case .navigateToDetailChecklist(let card):
75-
state.path.append(.detailChecklist(.init(card: card)))
74+
case .navigateToDetailChecklist(let card, let index):
75+
state.path.append(.detailChecklist(.init(index: index, card: card)))
7676
return .none
7777

7878
default:
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
//
2+
// ChecklistColorType.swift
3+
// FeatureHome
4+
//
5+
// Created by 현수빈 on 10/15/25.
6+
//
7+
8+
import SwiftUI
9+
10+
public enum ChecklistColorType: Int, CaseIterable {
11+
case blue = 0
12+
case green
13+
case orange
14+
15+
public init(index: Int) {
16+
self = ChecklistColorType(rawValue: index % ChecklistColorType.allCases.count ) ?? .blue
17+
}
18+
19+
// MARK: - 체크리스트 색상
20+
var checklistColor: Color {
21+
switch self {
22+
case .blue:
23+
return Color.primary050
24+
case .green:
25+
return Color(hex: "EFFAF3")
26+
case .orange:
27+
return Color.sub050
28+
}
29+
}
30+
31+
var checklistTintColor: Color {
32+
switch self {
33+
case .blue:
34+
return Color.primary500
35+
case .green:
36+
return Color(hex: "84E1AF")
37+
case .orange:
38+
return Color.sub500
39+
}
40+
}
41+
42+
// MARK: - 선택 시 체크리스 색상
43+
var checklistSelectedColor: Color {
44+
switch self {
45+
case .blue:
46+
return Color.primary100
47+
case .green:
48+
return Color(hex: "E5FBEC")
49+
case .orange:
50+
return Color.sub100
51+
}
52+
}
53+
54+
var checklistSelectedTintColor: Color {
55+
switch self {
56+
case .blue:
57+
return Color.primary900
58+
case .green:
59+
return Color(hex: "489C6E")
60+
case .orange:
61+
return Color.sub600
62+
}
63+
}
64+
}

0 commit comments

Comments
 (0)