From f750f3efb958bad0362960eca3b994e8d49fe6df Mon Sep 17 00:00:00 2001 From: mmaybei Date: Mon, 26 Aug 2024 16:35:24 +0900 Subject: [PATCH] =?UTF-8?q?fix/#301=20=EC=A4=80=EB=B9=84=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=20=EA=B4=80=EB=A0=A8=20=EC=98=A4=EB=A5=98=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 새로운 약속이 추가되어 오늘의 약속이 바뀔 때 준비 상태가 바뀌지 않는 오류 및 페이지 이동 시에만 시간 레이블이 반영되는 오류 수정 --- .../Source/Home/View/TodayPromiseView.swift | 27 +--- .../ViewController/HomeViewController.swift | 118 ++++++++++++++++-- .../Source/Home/ViewModel/HomeViewModel.swift | 2 + 3 files changed, 112 insertions(+), 35 deletions(-) diff --git a/KkuMulKum/Source/Home/View/TodayPromiseView.swift b/KkuMulKum/Source/Home/View/TodayPromiseView.swift index 92e50e0d..4e3f2f30 100644 --- a/KkuMulKum/Source/Home/View/TodayPromiseView.swift +++ b/KkuMulKum/Source/Home/View/TodayPromiseView.swift @@ -58,17 +58,11 @@ final class TodayPromiseView: BaseView { private let lineView = UIView(backgroundColor: .gray2) - let prepareLineView = UIView(backgroundColor: .maincolor).then { - $0.isHidden = true - } + let prepareLineView = UIView(backgroundColor: .maincolor) - let moveLineView = UIView(backgroundColor: .maincolor).then { - $0.isHidden = true - } + let moveLineView = UIView(backgroundColor: .maincolor) - let arriveLineView = UIView(backgroundColor: .maincolor).then { - $0.isHidden = true - } + let arriveLineView = UIView(backgroundColor: .maincolor) let prepareCircleView = UIView(backgroundColor: .maincolor).then { $0.layer.cornerRadius = 8 @@ -84,49 +78,38 @@ final class TodayPromiseView: BaseView { let prepareCheckView = UIImageView().then { $0.image = .iconCheck - $0.isHidden = true } let moveCheckView = UIImageView().then { $0.image = .iconCheck - $0.isHidden = true } let arriveCheckView = UIImageView().then { $0.image = .iconCheck - $0.isHidden = true } let prepareButton = UIButton().then { - $0.setTitle("준비 시작", style: .body05, color: .maincolor) $0.setLayer(borderWidth: 1, borderColor: .maincolor, cornerRadius: 16) } let moveButton = UIButton().then { - $0.setTitle("이동 시작", style: .body05, color: .gray4) - $0.setLayer(borderWidth: 1, borderColor: .gray4, cornerRadius: 16) - $0.isEnabled = false + $0.setLayer(borderWidth: 1, borderColor: .maincolor, cornerRadius: 16) } let arriveButton = UIButton().then { - $0.setTitle("도착 완료", style: .body05, color: .gray4) - $0.setLayer(borderWidth: 1, borderColor: .gray4, cornerRadius: 16) - $0.isEnabled = false + $0.setLayer(borderWidth: 1, borderColor: .maincolor, cornerRadius: 16) } let prepareLabel = UILabel().then { $0.setText("준비를 시작 시 눌러주세요", style: .label02, color: .gray5) - $0.isHidden = false } let moveLabel = UILabel().then { $0.setText("이동를 시작 시 눌러주세요", style: .label02, color: .gray5) - $0.isHidden = true } let arriveLabel = UILabel().then { $0.setText("도착 완료 시 눌러주세요", style: .label02, color: .gray5) - $0.isHidden = true } let prepareTimeLabel = UILabel() diff --git a/KkuMulKum/Source/Home/ViewController/HomeViewController.swift b/KkuMulKum/Source/Home/ViewController/HomeViewController.swift index 92401200..10e92189 100644 --- a/KkuMulKum/Source/Home/ViewController/HomeViewController.swift +++ b/KkuMulKum/Source/Home/ViewController/HomeViewController.swift @@ -204,7 +204,7 @@ private extension HomeViewController { case .arrive: self?.setArriveUI() case .none: - break + self?.setNoneUI() } } } @@ -325,86 +325,167 @@ private extension HomeViewController { } } + func getCurrentTimeString() -> String { + let dateFormatter = DateFormatter() + dateFormatter.dateFormat = "a h:mm" + dateFormatter.locale = Locale(identifier: "en_US_POSIX") + return dateFormatter.string(from: Date()) + } + func setDisableButton(_ sender: UIButton) { - sender.setTitleColor(.gray3, for: .normal) sender.layer.borderColor = UIColor.gray3.cgColor sender.backgroundColor = .white } func setEnableButton(_ sender: UIButton) { - sender.setTitleColor(.maincolor, for: .normal) sender.layer.borderColor = UIColor.maincolor.cgColor sender.backgroundColor = .white } func setProgressButton(_ sender: UIButton) { - sender.setTitleColor(.maincolor, for: .normal) sender.layer.borderColor = UIColor.maincolor.cgColor sender.backgroundColor = .green2 } func setCompleteButton(_ sender: UIButton) { - sender.setTitleColor(.white, for: .normal) sender.layer.borderColor = UIColor.maincolor.cgColor sender.backgroundColor = .maincolor } + func setNoneUI() { + print("setNoneUI") + setEnableButton(rootView.todayPromiseView.prepareButton) + setDisableButton(rootView.todayPromiseView.moveButton) + setDisableButton(rootView.todayPromiseView.arriveButton) + + rootView.todayPromiseView.prepareButton.setTitle("준비 시작", style: .body05, color: .maincolor) + rootView.todayPromiseView.moveButton.setTitle("이동 시작", style: .body05, color: .gray3) + rootView.todayPromiseView.arriveButton.setTitle("도착 완료", style: .body05, color: .gray3) + + rootView.todayPromiseView.prepareButton.isEnabled = true + rootView.todayPromiseView.moveButton.isEnabled = false + rootView.todayPromiseView.arriveButton.isEnabled = false + + rootView.todayPromiseView.prepareCircleView.backgroundColor = .gray2 + rootView.todayPromiseView.moveCircleView.backgroundColor = .gray2 + rootView.todayPromiseView.arriveCircleView.backgroundColor = .gray2 + + rootView.todayPromiseView.prepareCheckView.isHidden = true + rootView.todayPromiseView.moveCheckView.isHidden = true + rootView.todayPromiseView.arriveCheckView.isHidden = true + + rootView.todayPromiseView.prepareLabel.isHidden = false + rootView.todayPromiseView.moveLabel.isHidden = true + rootView.todayPromiseView.arriveLabel.isHidden = true + + rootView.todayPromiseView.prepareLineView.isHidden = true + rootView.todayPromiseView.moveLineView.isHidden = true + rootView.todayPromiseView.arriveLineView.isHidden = true + + rootView.todayPromiseView.prepareTimeLabel.isHidden = true + rootView.todayPromiseView.moveTimeLabel.isHidden = true + rootView.todayPromiseView.arriveTimeLabel.isHidden = true + } + func setPrepareUI() { + print("setPrepareUI") setProgressButton(rootView.todayPromiseView.prepareButton) - rootView.todayPromiseView.moveButton.setTitle("준비 중", for: .normal) setEnableButton(rootView.todayPromiseView.moveButton) setDisableButton(rootView.todayPromiseView.arriveButton) + rootView.todayPromiseView.prepareButton.setTitle("준비 중", style: .body05, color: .maincolor) + rootView.todayPromiseView.moveButton.setTitle("이동 시작", style: .body05, color: .maincolor) + rootView.todayPromiseView.arriveButton.setTitle("도착 완료", style: .body05, color: .gray3) + rootView.todayPromiseView.prepareButton.isEnabled = false rootView.todayPromiseView.moveButton.isEnabled = true + rootView.todayPromiseView.arriveButton.isEnabled = false rootView.todayPromiseView.prepareCircleView.backgroundColor = .green2 + rootView.todayPromiseView.moveCircleView.backgroundColor = .gray2 + rootView.todayPromiseView.arriveCircleView.backgroundColor = .gray2 + + rootView.todayPromiseView.prepareCheckView.isHidden = true + rootView.todayPromiseView.moveCheckView.isHidden = true + rootView.todayPromiseView.arriveCheckView.isHidden = true rootView.todayPromiseView.prepareLabel.isHidden = true rootView.todayPromiseView.moveLabel.isHidden = false + rootView.todayPromiseView.arriveLabel.isHidden = true rootView.todayPromiseView.prepareLineView.isHidden = false + rootView.todayPromiseView.moveLineView.isHidden = true + rootView.todayPromiseView.arriveLineView.isHidden = true + let currentTime = getCurrentTimeString() rootView.todayPromiseView.prepareTimeLabel.setText( - self.viewModel.myReadyStatus.value?.data?.preparationStartAt ?? "", style: .caption02, color: .gray8 + self.viewModel.myReadyStatus.value?.data?.preparationStartAt ?? currentTime, + style: .caption02, + color: .gray8 ) + + rootView.todayPromiseView.prepareTimeLabel.isHidden = false + rootView.todayPromiseView.moveTimeLabel.isHidden = true + rootView.todayPromiseView.arriveTimeLabel.isHidden = true } func setMoveUI() { + print("setMoveUI") setCompleteButton(rootView.todayPromiseView.prepareButton) - rootView.todayPromiseView.moveButton.setTitle("이동 중", for: .normal) setProgressButton(rootView.todayPromiseView.moveButton) setEnableButton(rootView.todayPromiseView.arriveButton) + rootView.todayPromiseView.prepareButton.setTitle("준비 중", style: .body05, color: .white) + rootView.todayPromiseView.moveButton.setTitle("이동 중", style: .body05, color: .maincolor) + rootView.todayPromiseView.arriveButton.setTitle("도착 완료", style: .body05, color: .maincolor) + rootView.todayPromiseView.prepareButton.isEnabled = false rootView.todayPromiseView.moveButton.isEnabled = false rootView.todayPromiseView.arriveButton.isEnabled = true rootView.todayPromiseView.prepareCircleView.backgroundColor = .maincolor rootView.todayPromiseView.moveCircleView.backgroundColor = .green2 + rootView.todayPromiseView.arriveCircleView.backgroundColor = .gray2 rootView.todayPromiseView.prepareLabel.isHidden = true rootView.todayPromiseView.moveLabel.isHidden = true rootView.todayPromiseView.arriveLabel.isHidden = false rootView.todayPromiseView.prepareCheckView.isHidden = false + rootView.todayPromiseView.moveCheckView.isHidden = true + rootView.todayPromiseView.arriveCheckView.isHidden = true rootView.todayPromiseView.prepareLineView.isHidden = false rootView.todayPromiseView.moveLineView.isHidden = false + rootView.todayPromiseView.arriveLineView.isHidden = true + let currentTime = getCurrentTimeString() rootView.todayPromiseView.prepareTimeLabel.setText( - self.viewModel.myReadyStatus.value?.data?.preparationStartAt ?? "", style: .caption02, color: .gray8 + self.viewModel.myReadyStatus.value?.data?.preparationStartAt ?? currentTime, + style: .caption02, + color: .gray8 ) rootView.todayPromiseView.moveTimeLabel.setText( - self.viewModel.myReadyStatus.value?.data?.departureAt ?? "", style: .caption02, color: .gray8 + self.viewModel.myReadyStatus.value?.data?.departureAt ?? currentTime, + style: .caption02, + color: .gray8 ) + + rootView.todayPromiseView.prepareTimeLabel.isHidden = false + rootView.todayPromiseView.moveTimeLabel.isHidden = false + rootView.todayPromiseView.arriveTimeLabel.isHidden = true } func setArriveUI() { + print("setArriveUI") setCompleteButton(rootView.todayPromiseView.prepareButton) setCompleteButton(rootView.todayPromiseView.moveButton) setCompleteButton(rootView.todayPromiseView.arriveButton) + rootView.todayPromiseView.prepareButton.setTitle("준비 중", style: .body05, color: .white) + rootView.todayPromiseView.moveButton.setTitle("이동 중", style: .body05, color: .white) + rootView.todayPromiseView.arriveButton.setTitle("도착 완료", style: .body05, color: .white) + rootView.todayPromiseView.prepareButton.isEnabled = false rootView.todayPromiseView.moveButton.isEnabled = false rootView.todayPromiseView.arriveButton.isEnabled = false @@ -425,15 +506,26 @@ private extension HomeViewController { rootView.todayPromiseView.moveLineView.isHidden = false rootView.todayPromiseView.arriveLineView.isHidden = false + let currentTime = getCurrentTimeString() rootView.todayPromiseView.prepareTimeLabel.setText( - self.viewModel.myReadyStatus.value?.data?.preparationStartAt ?? "", style: .caption02, color: .gray8 + self.viewModel.myReadyStatus.value?.data?.preparationStartAt ?? currentTime, + style: .caption02, + color: .gray8 ) rootView.todayPromiseView.moveTimeLabel.setText( - self.viewModel.myReadyStatus.value?.data?.departureAt ?? "", style: .caption02, color: .gray8 + self.viewModel.myReadyStatus.value?.data?.departureAt ?? currentTime, + style: .caption02, + color: .gray8 ) rootView.todayPromiseView.arriveTimeLabel.setText( - self.viewModel.myReadyStatus.value?.data?.arrivalAt ?? "", style: .caption02, color: .gray8 + self.viewModel.myReadyStatus.value?.data?.arrivalAt ?? currentTime, + style: .caption02, + color: .gray8 ) + + rootView.todayPromiseView.prepareTimeLabel.isHidden = false + rootView.todayPromiseView.moveTimeLabel.isHidden = false + rootView.todayPromiseView.arriveTimeLabel.isHidden = false } diff --git a/KkuMulKum/Source/Home/ViewModel/HomeViewModel.swift b/KkuMulKum/Source/Home/ViewModel/HomeViewModel.swift index 2db7cb9b..c7d3224d 100644 --- a/KkuMulKum/Source/Home/ViewModel/HomeViewModel.swift +++ b/KkuMulKum/Source/Home/ViewModel/HomeViewModel.swift @@ -71,6 +71,7 @@ final class HomeViewModel { ///서버에서 보내주는 readyStatus의 시간 유무에 따른 현재 상태 분류 private func judgeReadyStatus() { + print("judgeReadyStatus = \(currentState.value)") guard let data = myReadyStatus.value?.data else { currentState.value = .none return @@ -85,6 +86,7 @@ final class HomeViewModel { } else { currentState.value = .none } + print("judgeReadyStatus = \(currentState.value)") } func requestMyReadyStatus() {