Skip to content

Commit 389daa5

Browse files
committed
[design] #157 포킷 뱃지 디자인 변경사항 반영
1 parent ead2ee6 commit 389daa5

File tree

4 files changed

+74
-23
lines changed

4 files changed

+74
-23
lines changed

Projects/DSKit/Sources/Components/PokitBadge.swift

Lines changed: 68 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,51 +8,101 @@
88
import SwiftUI
99

1010
public struct PokitBadge: View {
11-
private let labelText: String
1211
private let state: PokitBadge.State
1312

14-
public init(
15-
_ labelText: String,
16-
state: PokitBadge.State
17-
) {
18-
self.labelText = labelText
13+
public init(state: PokitBadge.State) {
1914
self.state = state
2015
}
2116

2217
public var body: some View {
23-
Text(labelText)
24-
.pokitFont(.l4)
25-
.foregroundStyle(
26-
state == .unCategorized ? .pokit(.text(.secondary)) : .pokit(.text(.tertiary))
27-
)
28-
.padding(.horizontal, state == .small ? 4 : 8)
29-
.padding(.vertical, state == .small ? 2 : 4)
18+
label
3019
.background {
3120
RoundedRectangle(cornerRadius: 4, style: .continuous)
3221
.fill(backgroundColor)
3322
.overlay {
3423
if state == .unRead {
3524
RoundedRectangle(cornerRadius: 4, style: .continuous)
36-
.stroke(.pokit(.border(.tertiary)), lineWidth: 1)
25+
.stroke(.pokit(.border(.brand)), lineWidth: 1)
3726
}
3827
}
3928
}
4029
}
4130

4231
private var backgroundColor: Color {
4332
switch self.state {
44-
case .default, .small: return .pokit(.bg(.primary))
33+
case .default, .small, .memo, .member: return .pokit(.bg(.primary))
4534
case .unCategorized: return .pokit(.color(.grayScale(._50)))
4635
case .unRead: return .pokit(.bg(.base))
4736
}
4837
}
38+
39+
private var labelColor: Color {
40+
switch self.state {
41+
case .default, .small: return .pokit(.text(.tertiary))
42+
case .unCategorized: return .pokit(.text(.secondary))
43+
case .unRead: return .pokit(.text(.brand))
44+
case .memo, .member: return .pokit(.icon(.secondary))
45+
}
46+
}
47+
48+
private var label: some View {
49+
Group {
50+
switch self.state {
51+
case let .default(labelText):
52+
Text(labelText)
53+
.pokitFont(.l4)
54+
.padding(.horizontal, 8)
55+
.padding(.vertical, 4)
56+
case let .small(labelText):
57+
Text(labelText)
58+
.pokitFont(.l4)
59+
.padding(.horizontal, 4)
60+
.padding(.vertical, 2)
61+
case .unCategorized:
62+
Text("미분류")
63+
.pokitFont(.l4)
64+
.padding(.horizontal, 8)
65+
.padding(.vertical, 4)
66+
case .unRead:
67+
Text("안읽음")
68+
.pokitFont(.l4)
69+
.padding(.horizontal, 8)
70+
.padding(.vertical, 4)
71+
case .memo:
72+
Image(.icon(.memo))
73+
.resizable()
74+
.frame(width: 16, height: 16)
75+
.padding(2)
76+
case .member:
77+
Image(.icon(.member))
78+
.resizable()
79+
.frame(width: 16, height: 16)
80+
.padding(2)
81+
}
82+
}
83+
.foregroundStyle(labelColor)
84+
}
4985
}
5086

5187
public extension PokitBadge {
52-
enum State {
53-
case `default`
54-
case small
88+
enum State: Equatable {
89+
case `default`(String)
90+
case small(String)
5591
case unCategorized
5692
case unRead
93+
case memo
94+
case member
5795
}
5896
}
97+
98+
#Preview {
99+
PokitBadge(state: .unRead)
100+
101+
PokitBadge(state: .default("포킷명"))
102+
103+
PokitBadge(state: .unCategorized)
104+
105+
PokitBadge(state: .memo)
106+
107+
PokitBadge(state: .member)
108+
}

Projects/DSKit/Sources/Components/PokitLinkCard.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,13 @@ public struct PokitLinkCard<Item: PokitLinkCardItem>: View {
9191

9292
HStack(spacing: 6) {
9393
PokitBadge(
94-
link.categoryName,
95-
state: isUnCategorized ? .unCategorized : .default
94+
state: isUnCategorized
95+
? .unCategorized
96+
: .default(link.categoryName)
9697
)
9798

9899
if let isRead = link.isRead, !isRead {
99-
PokitBadge("안읽음", state: .unRead)
100+
PokitBadge(state: .unRead)
100101
}
101102
}
102103
}

Projects/Feature/FeatureContentDetail/Sources/ContentDetail/ContentDetailView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ private extension ContentDetailView {
9090
}
9191
}
9292

93-
PokitBadge(content.category.categoryName, state: .default)
93+
PokitBadge(state: .default(content.category.categoryName))
9494

9595
Spacer()
9696
}

Projects/Feature/FeatureRemind/Sources/Remind/RemindView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ extension RemindView {
156156
)
157157

158158
VStack(alignment: .leading, spacing: 0) {
159-
PokitBadge(content.categoryName, state: .small)
159+
PokitBadge(state: .small(content.categoryName))
160160

161161
HStack(spacing: 4) {
162162
Text(content.title)

0 commit comments

Comments
 (0)