Skip to content

Commit

Permalink
feat/#388 약속 상세 내 약속 여부에 따라 약속 수정 버튼 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
youz2me committed Sep 15, 2024
1 parent 918f77c commit 5fbe45a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class PromiseViewController: BaseViewController {
super.viewDidLoad()

setupNavigationBarBackButton()
setupBindings()
setupBinding()
}

override func viewWillAppear(_ animated: Bool) {
Expand Down Expand Up @@ -141,8 +141,19 @@ class PromiseViewController: BaseViewController {
// MARK: - Extension

private extension PromiseViewController {
func setupBindings() {

func setupBinding() {
viewModel.promiseInfo.bindOnMain(with: self) { owner, info in
guard let isParticipant = info?.isParticipant else { return }

let moreButton = UIBarButtonItem(
image: .imgMore.withRenderingMode(.alwaysOriginal),
style: .plain,
target: owner,
action: #selector(owner.moreButtonDidTap)
)

owner.navigationController?.navigationItem.rightBarButtonItem = isParticipant ? moreButton : nil
}
}

@objc
Expand Down
9 changes: 9 additions & 0 deletions KkuMulKum/Source/Promise/ViewModel/PromiseViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class PromiseViewModel {
// MARK: Property

let promiseID: Int
let promiseInfo = ObservablePattern<PromiseInfoModel?>(nil)

private let service: PromiseServiceProtocol

Expand All @@ -38,11 +39,17 @@ extension PromiseViewModel {
guard let success = result?.success,
success == true
else {
print(">>>>> \(String(describing: result)) : \(#function)")

return
}

promiseInfo.value = result?.data
} catch {
print(">>>>> \(error.localizedDescription) : \(#function)")
}


}
}

Expand Down Expand Up @@ -168,6 +175,7 @@ extension PromiseViewModel {
}
}

/// 약속 삭제 API 구현 함수
func deletePromise() {
Task {
do {
Expand All @@ -184,6 +192,7 @@ extension PromiseViewModel {
}
}

/// 약속 나가기 API 구현 함수
func exitPromise() {
Task {
do {
Expand Down

0 comments on commit 5fbe45a

Please sign in to comment.