Skip to content

Commit 5e3d3c9

Browse files
committed
[fix] #193 ContentSetting, 외부에서 시트 제어할 수 있게 flag 추가
1 parent dae076a commit 5e3d3c9

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

Projects/DSKit/Sources/Components/PokitSelect.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ public struct PokitSelect<Item: PokitSelectItem>: View {
1414
private var selectedItem: Item?
1515
@State
1616
private var state: PokitSelect.SelectState
17-
@State
18-
private var showSheet: Bool = false
17+
@Binding
18+
private var isPresented: Bool
1919

2020
private let label: String
2121
private let list: [Item]?
@@ -24,13 +24,15 @@ public struct PokitSelect<Item: PokitSelectItem>: View {
2424

2525
public init(
2626
selectedItem: Binding<Item?> = .constant(nil),
27+
isPresented: Binding<Bool>,
2728
state: PokitSelect.SelectState = .default,
2829
label: String,
2930
list: [Item]?,
3031
action: @escaping (Item) -> Void,
3132
addAction: (() -> Void)?
3233
) {
3334
self._selectedItem = selectedItem
35+
self._isPresented = isPresented
3436
if selectedItem.wrappedValue != nil {
3537
self.state = .input
3638
} else {
@@ -49,7 +51,7 @@ public struct PokitSelect<Item: PokitSelectItem>: View {
4951
partSelectButton
5052
}
5153
.onChange(of: selectedItem) { onChangedSeletedItem($0) }
52-
.sheet(isPresented: $showSheet) {
54+
.sheet(isPresented: $isPresented) {
5355
PokitSelectSheet(
5456
list: list,
5557
itemSelected: { item in
@@ -104,22 +106,22 @@ public struct PokitSelect<Item: PokitSelectItem>: View {
104106
}
105107

106108
private func partSelectButtonTapped() {
107-
showSheet = true
109+
isPresented = true
108110
}
109111

110112
private func listCellTapped(_ item: Item) {
111113
withAnimation(.pokitDissolve) {
112114
self.selectedItem = item
113115
}
114-
showSheet = false
116+
isPresented = false
115117
}
116118

117119
private func onChangedSeletedItem(_ newValue: Item?) {
118120
state = newValue != nil ? .input : .default
119121
}
120122

121123
private func listDismiss() {
122-
showSheet = false
124+
isPresented = false
123125
}
124126
}
125127

Projects/Feature/FeatureContentSetting/Sources/ContentSetting/ContentSettingFeature.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public struct ContentSettingFeature {
7070
var link: String?
7171
var showLinkPreview = false
7272
var isShareExtension: Bool
73+
var pokitAddSheetPresented: Bool = false
7374
}
7475

7576
/// - Action
@@ -209,7 +210,8 @@ private extension ContentSettingFeature {
209210
state.linkPopup = .text(title: Constants.포킷_최대_갯수_문구)
210211
return .none
211212
}
212-
213+
/// 바텀시트 내리고 `포킷추가하기` depth 추가
214+
state.pokitAddSheetPresented = false
213215
return .send(.delegate(.포킷추가하기))
214216
case .뒤로가기_버튼_눌렀을때:
215217
state.categoryId = nil

Projects/Feature/FeatureContentSetting/Sources/ContentSetting/ContentSettingView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ private extension ContentSettingView {
141141
var pokitSelectButton: some View {
142142
PokitSelect(
143143
selectedItem: $store.selectedPokit,
144+
isPresented: $store.pokitAddSheetPresented,
144145
label: "포킷",
145146
list: store.pokitList,
146147
action: { send(.포킷선택_항목_눌렀을때(pokit: $0), animation: .pokitDissolve) },

0 commit comments

Comments
 (0)