Skip to content

Commit 5e682a7

Browse files
committed
[feat] #173 카테고리 추가 시트 구성
1 parent 0671f7d commit 5e682a7

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
//
2+
// PokitSelectSheet.swift
3+
// DSKit
4+
//
5+
// Created by 김민호 on 12/27/24.
6+
//
7+
8+
import SwiftUI
9+
import Util
10+
11+
12+
public struct PokitSelectSheet<Item: PokitSelectItem>: View {
13+
private let list: [Item]?
14+
private let itemSelected: (Item) -> Void
15+
private let pokitAddAction: (() -> Void)?
16+
17+
public init(
18+
list: [Item]?,
19+
itemSelected: @escaping (Item) -> Void,
20+
pokitAddAction: (() -> Void)?
21+
) {
22+
self.list = list
23+
self.itemSelected = itemSelected
24+
self.pokitAddAction = pokitAddAction
25+
}
26+
27+
28+
public var body: some View {
29+
Group {
30+
if let list {
31+
VStack(spacing: 0) {
32+
if let pokitAddAction {
33+
addButton {
34+
pokitAddAction()
35+
}
36+
}
37+
PokitList(
38+
selectedItem: nil,
39+
list: list
40+
) { item in
41+
itemSelected(item)
42+
}
43+
}
44+
.padding(.top, 12)
45+
.padding(.bottom, 20)
46+
} else {
47+
PokitLoading()
48+
}
49+
}
50+
}
51+
}
52+
extension PokitSelectSheet {
53+
@ViewBuilder
54+
private func addButton(
55+
action: @escaping () -> Void
56+
) -> some View {
57+
Button(action: action) {
58+
HStack(spacing: 20) {
59+
PokitIconButton(
60+
.icon(.plusR),
61+
state: .default(.secondary),
62+
size: .medium,
63+
shape: .round,
64+
action: action
65+
)
66+
67+
Text("포킷 추가하기")
68+
.pokitFont(.b1(.b))
69+
.foregroundStyle(.pokit(.text(.primary)))
70+
71+
Spacer()
72+
}
73+
.padding(.vertical, 22)
74+
.padding(.horizontal, 30)
75+
.background(alignment: .bottom) {
76+
Rectangle()
77+
.fill(.pokit(.border(.tertiary)))
78+
.frame(height: 1)
79+
}
80+
}
81+
}
82+
}

0 commit comments

Comments
 (0)