Skip to content

Commit

Permalink
[feat] #167 메모 수정 시 키보드 툴바(취소, 완료 버튼) 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
ShapeKim98 committed Dec 9, 2024
1 parent 413a6be commit c40312f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ public struct ContentDetailFeature {
case 삭제_버튼_눌렀을때
case 삭제확인_버튼_눌렀을때
case 즐겨찾기_버튼_눌렀을때
case 키보드_취소_버튼_눌렀을때
case 키보드_완료_버튼_눌렀울때

case 경고시트_해제

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

public enum InnerAction: Equatable {
Expand Down Expand Up @@ -179,12 +181,12 @@ private extension ContentDetailFeature {
case .경고시트_해제:
state.showAlert = false
return .none
case let .메모포커스_변경되었을때(isFocused):
guard
!isFocused,
state.memo != state.domain.content?.memo
else { return .none }
case .키보드_취소_버튼_눌렀을때:
state.memo = state.domain.content?.memo ?? ""
return .none
case .키보드_완료_버튼_눌렀울때:
let memo = state.memo
guard memo != state.domain.content?.memo else { return .none }
state.domain.content?.memo = memo
return .send(.async(.컨텐츠_수정_API))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public extension ContentDetailView {
PokitLinkPopup(type: $store.linkPopup)
}
}
.dismissKeyboard(focused: $isFocused)
.onChange(of: isFocused) { send(.메모포커스_변경되었을때($0)) }
// .dismissKeyboard(focused: $isFocused)
// .onChange(of: isFocused) { send(.메모포커스_변경되었을때($0)) }
.sheet(isPresented: $store.showAlert) {
PokitAlert(
"링크를 정말 삭제하시겠습니까?",
Expand Down Expand Up @@ -159,12 +159,29 @@ private extension ContentDetailView {
focusState: $isFocused,
equals: true
)
.toolbar { keyboardToolBar }
.frame(minHeight: isFocused ? 164 : 132)
.animation(.pokitDissolve, value: isFocused)
}
.padding(.bottom, 24)
.padding(.horizontal, 20)
}

var keyboardToolBar: some ToolbarContent {
ToolbarItemGroup(placement: .keyboard) {
Button("취소") {
isFocused = false
send(.키보드_취소_버튼_눌렀을때)
}

Spacer()

Button("완료") {
isFocused = false
send(.키보드_완료_버튼_눌렀울때)
}
}
}

@ViewBuilder
func bottomList(favorites: Bool) -> some View {
Expand Down

0 comments on commit c40312f

Please sign in to comment.