Skip to content

Commit fc11067

Browse files
committed
[design] #157 링크카드 디자인 변경사항 반영
1 parent 78ddfd8 commit fc11067

File tree

3 files changed

+85
-24
lines changed

3 files changed

+85
-24
lines changed

Projects/DSKit/Sources/Components/PokitLinkCard.swift

Lines changed: 65 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,48 @@ import NukeUI
1212

1313
public struct PokitLinkCard<Item: PokitLinkCardItem>: View {
1414
private let link: Item
15+
private let state: PokitLinkCard.State
16+
private let type: PokitLinkCard.CardType
1517
private let action: () -> Void
1618
private let kebabAction: (() -> Void)?
1719
private let fetchMetaData: (() -> Void)?
20+
private let favoriteAction: (() -> Void)?
21+
private let selectAction: (() -> Void)?
1822

1923
public init(
2024
link: Item,
25+
state: PokitLinkCard.State,
26+
type: PokitLinkCard.CardType = .accept,
2127
action: @escaping () -> Void,
2228
kebabAction: (() -> Void)? = nil,
23-
fetchMetaData: (() -> Void)? = nil
29+
fetchMetaData: (() -> Void)? = nil,
30+
favoriteAction: (() -> Void)? = nil,
31+
selectAction: (() -> Void)? = nil
2432
) {
2533
self.link = link
34+
self.state = state
35+
self.type = type
2636
self.action = action
2737
self.kebabAction = kebabAction
2838
self.fetchMetaData = fetchMetaData
39+
self.favoriteAction = favoriteAction
40+
self.selectAction = selectAction
2941
}
3042

3143
public var body: some View {
32-
Button(action: action) {
33-
buttonLabel
44+
VStack(spacing: 20) {
45+
Button(action: action) {
46+
buttonLabel
47+
}
48+
.padding(.top, state == .top ? 0 : 20)
49+
50+
if case .top = state {
51+
divider
52+
}
53+
54+
if case .middle = state {
55+
divider
56+
}
3457
}
3558
}
3659

@@ -68,6 +91,27 @@ public struct PokitLinkCard<Item: PokitLinkCardItem>: View {
6891
}
6992
}
7093
}
94+
.overlay(alignment: .bottomLeading) {
95+
if let isFavorite = link.isFavorite {
96+
PokitBookmark(
97+
state: isFavorite ? .active : .default,
98+
action: { favoriteAction?() }
99+
)
100+
.padding(4)
101+
}
102+
}
103+
.overlay(alignment: .topLeading) {
104+
if case .unCatgorized(let isSelected) = type {
105+
PokitCheckBox(
106+
baseState: .default,
107+
selectedState: .filled,
108+
isSelected: .constant(isSelected),
109+
shape: .rectangle,
110+
action: { selectAction?() }
111+
)
112+
.padding(4)
113+
}
114+
}
71115
}
72116

73117
private var title: some View {
@@ -90,14 +134,18 @@ public struct PokitLinkCard<Item: PokitLinkCardItem>: View {
90134
let isUnCategorized = link.categoryName == "미분류"
91135

92136
HStack(spacing: 6) {
137+
if let isRead = link.isRead, !isRead {
138+
PokitBadge(state: .unRead)
139+
}
140+
93141
PokitBadge(
94142
state: isUnCategorized
95143
? .unCategorized
96144
: .default(link.categoryName)
97145
)
98146

99-
if let isRead = link.isRead, !isRead {
100-
PokitBadge(state: .unRead)
147+
if let memo = link.memo, !memo.isEmpty {
148+
PokitBadge(state: .memo)
101149
}
102150
}
103151
}
@@ -150,17 +198,18 @@ public struct PokitLinkCard<Item: PokitLinkCardItem>: View {
150198
.frame(width: 124, height: 94)
151199
.clipShape(RoundedRectangle(cornerRadius: 8, style: .continuous))
152200
}
201+
}
202+
203+
extension PokitLinkCard {
204+
public enum State {
205+
case top
206+
case middle
207+
case bottom
208+
}
153209

154-
@ViewBuilder
155-
public func divider(isFirst: Bool, isLast: Bool) -> some View {
156-
let edge: Edge.Set = isFirst ? .bottom : isLast ? .top : .vertical
157-
158-
self
159-
.padding(edge, 20)
160-
.background(alignment: .bottom) {
161-
if !isLast {
162-
divider
163-
}
164-
}
210+
public enum CardType {
211+
case linkList
212+
case unCatgorized(isSelected: Bool)
213+
case accept
165214
}
166215
}

Projects/Feature/FeatureContentCard/Sources/ContentCard/ContentCardView.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,19 @@ import DSKit
1414
public struct ContentCardView: View {
1515
/// - Properties
1616
public var store: StoreOf<ContentCardFeature>
17+
private let type: PokitLinkCard<BaseContentItem>.CardType
1718
private let isFirst: Bool
1819
private let isLast: Bool
1920

2021
/// - Initializer
2122
public init(
2223
store: StoreOf<ContentCardFeature>,
24+
type: PokitLinkCard<BaseContentItem>.CardType = .accept,
2325
isFirst: Bool = false,
2426
isLast: Bool = false
2527
) {
2628
self.store = store
29+
self.type = type
2730
self.isFirst = isFirst
2831
self.isLast = isLast
2932
}
@@ -34,11 +37,14 @@ public extension ContentCardView {
3437
WithPerceptionTracking {
3538
PokitLinkCard(
3639
link: store.content,
40+
state: isFirst
41+
? .top
42+
: isLast ? .bottom : .middle,
43+
type: type,
3744
action: { send(.컨텐츠_항목_눌렀을때) },
3845
kebabAction: { send(.컨텐츠_항목_케밥_버튼_눌렀을때) },
3946
fetchMetaData: { send(.메타데이터_조회) }
4047
)
41-
.divider(isFirst: isFirst, isLast: isLast)
4248
}
4349
}
4450
}
@@ -55,11 +61,13 @@ private extension ContentCardView {
5561
categoryName: "미분류",
5662
categoryId: 992 ,
5763
title: "youtube",
64+
memo: nil,
5865
thumbNail: "https://i.ytimg.com/vi/NnOC4_kH0ok/hqdefault.jpg?sqp=-oaymwEjCNACELwBSFryq4qpAxUIARUAAAAAGAElAADIQj0AgKJDeAE=&rs=AOn4CLDN6u6mTjbaVmRZ4biJS_aDq4uvAQ",
5966
data: "https://www.youtube.com/watch?v=wtSwdGJzQCQ",
6067
domain: "신서유기",
6168
createdAt: "2024.08.08",
62-
isRead: false
69+
isRead: false,
70+
isFavorite: true
6371
)),
6472
reducer: { ContentCardFeature() }
6573
)

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,16 +258,18 @@ extension RemindView {
258258
}
259259

260260
ForEach(unreadContents, id: \.id) { content in
261-
let isFirst = content == unreadContents.elements.first
262-
let isLast = content == unreadContents.elements.last
261+
let isFirst = content.id == unreadContents.first?.id
262+
let isLast = content.id == unreadContents.last?.id
263263

264264
PokitLinkCard(
265265
link: content,
266+
state: isFirst
267+
? .top
268+
: isLast ? .bottom : .middle,
266269
action: { send(.컨텐츠_항목_눌렀을때(content: content)) },
267270
kebabAction: { send(.컨텐츠_항목_케밥_버튼_눌렀을때(content: content)) },
268271
fetchMetaData: { send(.읽지않음_항목_이미지_조회(contentId: content.id)) }
269272
)
270-
.divider(isFirst: isFirst, isLast: isLast)
271273
}
272274
}
273275
}
@@ -289,16 +291,18 @@ extension RemindView {
289291
.padding(.top, 16)
290292
} else {
291293
ForEach(favoriteContents, id: \.id) { content in
292-
let isFirst = content == favoriteContents.elements.first
293-
let isLast = content == favoriteContents.elements.last
294+
let isFirst = content.id == favoriteContents.first?.id
295+
let isLast = content.id == favoriteContents.last?.id
294296

295297
PokitLinkCard(
296298
link: content,
299+
state: isFirst
300+
? .top
301+
: isLast ? .bottom : .middle,
297302
action: { send(.컨텐츠_항목_눌렀을때(content: content)) },
298303
kebabAction: { send(.컨텐츠_항목_케밥_버튼_눌렀을때(content: content)) },
299304
fetchMetaData: { send(.즐겨찾기_항목_이미지_조회(contentId: content.id)) }
300305
)
301-
.divider(isFirst: isFirst, isLast: isLast)
302306
}
303307
}
304308
}

0 commit comments

Comments
 (0)