Skip to content

Commit 5dfac28

Browse files
committed
[design] #157 포킷 리스트 항목 디자인 변경사항 반영
1 parent 25fa5f7 commit 5dfac28

File tree

2 files changed

+45
-6
lines changed

2 files changed

+45
-6
lines changed

Projects/DSKit/Sources/Components/PokitList.swift

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,26 @@
88
import SwiftUI
99

1010
import Util
11+
import NukeUI
1112

1213
public struct PokitList<Item: PokitSelectItem>: View {
1314
@Namespace
1415
private var heroEffect
1516

1617
private let selectedItem: Item?
1718
private let list: [Item]
19+
private let isDisabled: Bool
1820
private let action: (Item) -> Void
1921

2022
public init(
2123
selectedItem: Item?,
2224
list: [Item],
25+
isDisabled: Bool = false,
2326
action: @escaping (Item) -> Void
2427
) {
2528
self.selectedItem = selectedItem
2629
self.list = list
30+
self.isDisabled = isDisabled
2731
self.action = action
2832
}
2933

@@ -54,29 +58,61 @@ public struct PokitList<Item: PokitSelectItem>: View {
5458
Button {
5559
action(item)
5660
} label: {
57-
HStack {
61+
HStack(spacing: 12) {
62+
thumbNail(url: item.categoryImage.imageURL)
63+
5864
VStack(alignment: .leading, spacing: 4) {
5965
Text(item.categoryName)
6066
.pokitFont(.b1(.b))
61-
.foregroundStyle(.pokit(.text(.primary)))
67+
.foregroundStyle(
68+
isDisabled
69+
? .pokit(.text(.disable))
70+
: .pokit(.text(.primary))
71+
)
6272

6373
Text("링크 \(item.contentCount)")
6474
.pokitFont(.detail1)
65-
.foregroundStyle(.pokit(.text(.tertiary)))
75+
.foregroundStyle(
76+
isDisabled
77+
? .pokit(.text(.disable))
78+
: .pokit(.text(.tertiary))
79+
)
6680
}
6781

6882
Spacer()
6983
}
70-
.padding(.leading, 28)
71-
.padding(.trailing, 20)
72-
.padding(.vertical, 13)
84+
.padding(.vertical, 18)
85+
.padding(.horizontal, 20)
7386
.background {
7487
if isSelected {
7588
Color.pokit(.bg(.primary))
7689
.matchedGeometryEffect(id: "SELECT", in: heroEffect)
90+
} else {
91+
isDisabled
92+
? Color.pokit(.bg(.disable))
93+
: Color.pokit(.bg(.base))
7794
}
7895
}
7996
}
8097
.animation(.pokitDissolve, value: isSelected)
98+
.disabled(isDisabled)
99+
}
100+
101+
@MainActor
102+
private func thumbNail(url: String) -> some View {
103+
LazyImage(url: URL(string: url)) { state in
104+
Group {
105+
if let image = state.image {
106+
image
107+
.resizable()
108+
} else {
109+
PokitSpinner()
110+
.foregroundStyle(.pokit(.icon(.brand)))
111+
.frame(width: 48, height: 48)
112+
}
113+
}
114+
.animation(.pokitDissolve, value: state.image)
115+
}
116+
.frame(width: 60, height: 60)
81117
}
82118
}

Projects/Util/Sources/Protocols/PokitSelectItem.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
import Foundation
99

1010
public protocol PokitSelectItem: Identifiable, Equatable {
11+
associatedtype Thumbnail: CategoryImage
12+
1113
var categoryName: String { get }
1214
var contentCount: Int { get }
15+
var categoryImage: Thumbnail { get }
1316
}

0 commit comments

Comments
 (0)