Skip to content

Commit

Permalink
fix/#357 준비 현황 버튼 텍스트 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
youz2me committed Sep 2, 2024
1 parent 3541f14 commit 9273ce0
Showing 1 changed file with 32 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ extension ReadyStatusViewController {
owner.updateReadyInfoView(flag: false)
return
}

owner.updateReadyInfoView(flag: true)
}
}
Expand Down Expand Up @@ -181,21 +182,17 @@ extension ReadyStatusViewController {
}
}

viewModel.myReadyProgressStatus.bind(with: self) { owner, status in
DispatchQueue.main.async {
owner.updateReadyStartButton(status: status)
}
viewModel.myReadyProgressStatus.bindOnMain(with: self) { owner, status in
owner.updateReadyStartButton()
}

viewModel.participantsInfo.bind(with: self) { owner, participants in
DispatchQueue.main.async {
owner.rootView.ourReadyStatusCollectionView.reloadData()

owner.rootView.ourReadyStatusCollectionView.snp.updateConstraints {
$0.height.equalTo(
CGFloat(participants?.count ?? 0) * Screen.height(80)
)
}
viewModel.participantsInfo.bindOnMain(with: self) { owner, participants in
owner.rootView.ourReadyStatusCollectionView.reloadData()

owner.rootView.ourReadyStatusCollectionView.snp.updateConstraints {
$0.height.equalTo(
CGFloat(participants?.count ?? 0) * Screen.height(80)
)
}
}

Expand All @@ -218,8 +215,8 @@ extension ReadyStatusViewController {
}

/// 준비 상태에 따라 버튼 상태 변경
func updateReadyStartButton(status: ReadyProgressStatus) {
switch status {
func updateReadyStartButton() {
switch viewModel.myReadyProgressStatus.value {
case .none:
DispatchQueue.main.async {
self.rootView.myReadyStatusProgressView.readyStartButton.setupButton(
Expand All @@ -234,10 +231,7 @@ extension ReadyStatusViewController {
"도착 완료",
.none
)
self.rootView.myReadyStatusProgressView.statusProgressView.setProgress(
0,
animated: false
)
self.rootView.myReadyStatusProgressView.statusProgressView.setProgress(0, animated: false)
}
case .ready:
DispatchQueue.main.async {
Expand All @@ -253,10 +247,10 @@ extension ReadyStatusViewController {
"도착 완료",
.none
)
self.rootView.myReadyStatusProgressView.statusProgressView.setProgress(
0.2,
animated: false
)
self.rootView.myReadyStatusProgressView.statusProgressView.setProgress(0.2, animated: false)

self.rootView.myReadyStatusProgressView.readyStartButton.isEnabled = false
self.rootView.myReadyStatusProgressView.moveStartButton.isEnabled = true

[
self.rootView.myReadyStatusProgressView.moveStartTimeLabel,
Expand Down Expand Up @@ -286,13 +280,10 @@ extension ReadyStatusViewController {
)
}
}

/// 준비 시작 네트워크 통신
viewModel.updatePreparationStatus()
case .move:
DispatchQueue.main.async {
self.rootView.myReadyStatusProgressView.readyStartButton.setupButton(
"준비 ",
"준비 완료",
.done
)
self.rootView.myReadyStatusProgressView.moveStartButton.setupButton(
Expand All @@ -307,6 +298,10 @@ extension ReadyStatusViewController {
0.5,
animated: false
)

self.rootView.myReadyStatusProgressView.moveStartButton.isEnabled = false
self.rootView.myReadyStatusProgressView.arrivalButton.isEnabled = true

self.rootView.myReadyStatusProgressView.arrivalTitleLabel.isHidden = false
self.rootView.myReadyStatusProgressView.moveStartTitleLabel.isHidden = true
self.rootView.myReadyStatusProgressView.readyStartTitleLabel.isHidden = true
Expand Down Expand Up @@ -341,17 +336,14 @@ extension ReadyStatusViewController {
)
}
}

/// 이동 시작 네트워크 통신
viewModel.updateDepartureStatus()
case .done:
DispatchQueue.main.async {
self.rootView.myReadyStatusProgressView.readyStartButton.setupButton(
"준비 ",
"준비 완료",
.done
)
self.rootView.myReadyStatusProgressView.moveStartButton.setupButton(
"이동 ",
"이동 완료",
.done
)
self.rootView.myReadyStatusProgressView.arrivalButton.setupButton(
Expand All @@ -363,6 +355,8 @@ extension ReadyStatusViewController {
animated: false
)

self.rootView.myReadyStatusProgressView.arrivalButton.isEnabled = false

[
self.rootView.myReadyStatusProgressView.arrivalTitleLabel,
self.rootView.myReadyStatusProgressView.moveStartTitleLabel,
Expand Down Expand Up @@ -411,30 +405,25 @@ extension ReadyStatusViewController {
)
}
}

/// 도착 완료 네트워크 통신
viewModel.updateArrivalStatus()
}
}

@objc
func readyStartButtonDidTap() {
viewModel.myReadyProgressStatus.value = .ready
rootView.myReadyStatusProgressView.readyStartButton.isEnabled = false
rootView.myReadyStatusProgressView.moveStartButton.isEnabled = true
viewModel.fetchPromiseParticipantList()
viewModel.updatePreparationStatus()
}

@objc
func moveStartButtonDidTap() {
viewModel.myReadyProgressStatus.value = .move
rootView.myReadyStatusProgressView.moveStartButton.isEnabled = false
rootView.myReadyStatusProgressView.arrivalButton.isEnabled = true
viewModel.fetchPromiseParticipantList()
viewModel.updateDepartureStatus()
}

@objc
func arrivalButtonDidTap() {
viewModel.myReadyProgressStatus.value = .done
rootView.myReadyStatusProgressView.arrivalButton.isEnabled = false
viewModel.fetchPromiseParticipantList()
viewModel.updateArrivalStatus()
}

@objc
Expand Down

0 comments on commit 9273ce0

Please sign in to comment.