Skip to content

Commit

Permalink
fix/#388 약속 정보 뷰 시간 제대로 안 뜨는 문제 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
youz2me committed Sep 17, 2024
1 parent eb7bd24 commit e8e34b8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,14 @@ extension PromiseInfoViewController {
func setupBinding() {
viewModel.promiseInfo.bindOnMain(with: self) { owner, info in
guard let info else { return }
let time = owner.viewModel.convertTime()

owner.rootView.editButton.isHidden = owner.viewModel.isEditButtonHidden()
owner.rootView.promiseNameLabel.setText(info.promiseName, style: .body01)
owner.rootView.locationContentLabel.setText(info.placeName, style: .body04)
owner.rootView.readyLevelContentLabel.setText(info.dressUpLevel, style: .body04)
owner.rootView.penaltyLevelContentLabel.setText(info.penalty, style: .body04)
owner.rootView.timeContentLabel.setText(info.time, style: .body04)
owner.rootView.timeContentLabel.setText(time, style: .body04)
}

viewModel.participantList.bindOnMain(with: self) { owner, list in
Expand Down
13 changes: 13 additions & 0 deletions KkuMulKum/Source/Promise/ViewModel/PromiseViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@ extension PromiseViewModel {
return .tardyEmptyView
}

func convertTime() -> String {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"

guard let promiseTime = promiseInfo.value?.time else { return "" }
guard let promiseDate = dateFormatter.date(from: promiseTime) else { return promiseTime }

let timeFormatter = DateFormatter()
timeFormatter.dateFormat = "M월 d일 a H:mm"

return timeFormatter.string(from: promiseDate)
}

/// 약속 상세 정보 조회 API 구현 함수
func fetchPromiseInfo() {
Task {
Expand Down

0 comments on commit e8e34b8

Please sign in to comment.