Skip to content

Commit c40312f

Browse files
committed
[feat] #167 메모 수정 시 키보드 툴바(취소, 완료 버튼) 추가
1 parent 413a6be commit c40312f

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

Projects/Feature/FeatureContentDetail/Sources/ContentDetail/ContentDetailFeature.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,12 @@ public struct ContentDetailFeature {
6969
case 삭제_버튼_눌렀을때
7070
case 삭제확인_버튼_눌렀을때
7171
case 즐겨찾기_버튼_눌렀을때
72+
case 키보드_취소_버튼_눌렀을때
73+
case 키보드_완료_버튼_눌렀울때
74+
7275
case 경고시트_해제
7376

7477
case 링크_공유_완료되었을때
75-
case 메모포커스_변경되었을때(Bool)
7678
}
7779

7880
public enum InnerAction: Equatable {
@@ -179,12 +181,12 @@ private extension ContentDetailFeature {
179181
case .경고시트_해제:
180182
state.showAlert = false
181183
return .none
182-
case let .메모포커스_변경되었을때(isFocused):
183-
guard
184-
!isFocused,
185-
state.memo != state.domain.content?.memo
186-
else { return .none }
184+
case .키보드_취소_버튼_눌렀을때:
185+
state.memo = state.domain.content?.memo ?? ""
186+
return .none
187+
case .키보드_완료_버튼_눌렀울때:
187188
let memo = state.memo
189+
guard memo != state.domain.content?.memo else { return .none }
188190
state.domain.content?.memo = memo
189191
return .send(.async(.컨텐츠_수정_API))
190192
}

Projects/Feature/FeatureContentDetail/Sources/ContentDetail/ContentDetailView.swift

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public extension ContentDetailView {
5656
PokitLinkPopup(type: $store.linkPopup)
5757
}
5858
}
59-
.dismissKeyboard(focused: $isFocused)
60-
.onChange(of: isFocused) { send(.메모포커스_변경되었을때($0)) }
59+
// .dismissKeyboard(focused: $isFocused)
60+
// .onChange(of: isFocused) { send(.메모포커스_변경되었을때($0)) }
6161
.sheet(isPresented: $store.showAlert) {
6262
PokitAlert(
6363
"링크를 정말 삭제하시겠습니까?",
@@ -159,12 +159,29 @@ private extension ContentDetailView {
159159
focusState: $isFocused,
160160
equals: true
161161
)
162+
.toolbar { keyboardToolBar }
162163
.frame(minHeight: isFocused ? 164 : 132)
163164
.animation(.pokitDissolve, value: isFocused)
164165
}
165166
.padding(.bottom, 24)
166167
.padding(.horizontal, 20)
167168
}
169+
170+
var keyboardToolBar: some ToolbarContent {
171+
ToolbarItemGroup(placement: .keyboard) {
172+
Button("취소") {
173+
isFocused = false
174+
send(.키보드_취소_버튼_눌렀을때)
175+
}
176+
177+
Spacer()
178+
179+
Button("완료") {
180+
isFocused = false
181+
send(.키보드_완료_버튼_눌렀울때)
182+
}
183+
}
184+
}
168185

169186
@ViewBuilder
170187
func bottomList(favorites: Bool) -> some View {

0 commit comments

Comments
 (0)