Skip to content

Commit

Permalink
[design] #157 링크 추가에서 포킷 추가 버튼 변경사항 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
ShapeKim98 committed Nov 29, 2024
1 parent 416b2b0 commit 1ff6183
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 23 deletions.
62 changes: 54 additions & 8 deletions Projects/DSKit/Sources/Components/PokitSelect.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ public struct PokitSelect<Item: PokitSelectItem>: View {
private let label: String
private let list: [Item]?
private let action: (Item) -> Void
private let addAction: (() -> Void)?

public init(
selectedItem: Binding<Item?> = .constant(nil),
state: PokitSelect.SelectState = .default,
label: String,
list: [Item]?,
action: @escaping (Item) -> Void
action: @escaping (Item) -> Void,
addAction: (() -> Void)?
) {
self._selectedItem = selectedItem
if selectedItem.wrappedValue != nil {
Expand All @@ -37,6 +39,7 @@ public struct PokitSelect<Item: PokitSelectItem>: View {
self.label = label
self.list = list
self.action = action
self.addAction = addAction
}

public var body: some View {
Expand Down Expand Up @@ -96,21 +99,60 @@ public struct PokitSelect<Item: PokitSelectItem>: View {
private var listSheet: some View {
Group {
if let list {
PokitList(
selectedItem: selectedItem,
list: list
) { item in
action(item)
listCellTapped(item)
VStack(spacing: 0) {
if let addAction {
addButton {
listDismiss()
addAction()
}
}

PokitList(
selectedItem: selectedItem,
list: list
) { item in
action(item)
listCellTapped(item)
}
}
.padding(.top, 36)
.padding(.top, 24)
.padding(.bottom, 20)
} else {
PokitLoading()
}
}
}

@ViewBuilder
private func addButton(
action: @escaping () -> Void
) -> some View {
Button(action: action) {
HStack(spacing: 20) {
PokitIconButton(
.icon(.plusR),
state: .default(.secondary),
size: .medium,
shape: .round,
action: action
)

Text("포킷 추가하기")
.pokitFont(.b1(.b))
.foregroundStyle(.pokit(.text(.primary)))

Spacer()
}
.padding(.vertical, 22)
.padding(.horizontal, 30)
.background(alignment: .bottom) {
Rectangle()
.fill(.pokit(.border(.tertiary)))
.frame(height: 1)
}
}
}

private func partSelectButtonTapped() {
showSheet = true
}
Expand All @@ -125,6 +167,10 @@ public struct PokitSelect<Item: PokitSelectItem>: View {
private func onChangedSeletedItem(_ newValue: Item?) {
state = newValue != nil ? .input : .default
}

private func listDismiss() {
showSheet = false
}
}

public extension PokitSelect {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ public extension ContentSettingView {

titleTextField

HStack(alignment: .bottom, spacing: 8) {
pokitSelectButton

addPokitButton
}
pokitSelectButton

memoTextArea

Expand Down Expand Up @@ -155,19 +151,11 @@ private extension ContentSettingView {
selectedItem: $store.selectedPokit,
label: "포킷",
list: store.pokitList,
action: { send(.포킷선택_항목_눌렀을때(pokit: $0), animation: .pokitDissolve) }
action: { send(.포킷선택_항목_눌렀을때(pokit: $0), animation: .pokitDissolve) },
addAction: { send(.포킷추가_버튼_눌렀을때, animation: .pokitSpring) }
)
}

var addPokitButton: some View {
PokitIconButton(
.icon(.plusR),
state: .filled(.primary),
size: .large,
shape: .rectangle
) { send(.포킷추가_버튼_눌렀을때, animation: .pokitSpring) }
}

var memoTextArea: some View {
PokitTextArea(
text: $store.memo,
Expand Down

0 comments on commit 1ff6183

Please sign in to comment.