Skip to content

Commit

Permalink
fix/#301 준비 상태 관련 오류 수정
Browse files Browse the repository at this point in the history
새로운 약속이 추가되어 오늘의 약속이 바뀔 때 준비 상태가 바뀌지 않는 오류 및 페이지 이동 시에만 시간 레이블이 반영되는 오류 수정
  • Loading branch information
mmaybei committed Aug 26, 2024
1 parent 0ec8ec2 commit f750f3e
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 35 deletions.
27 changes: 5 additions & 22 deletions KkuMulKum/Source/Home/View/TodayPromiseView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down
118 changes: 105 additions & 13 deletions KkuMulKum/Source/Home/ViewController/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ private extension HomeViewController {
case .arrive:
self?.setArriveUI()
case .none:
break
self?.setNoneUI()
}
}
}
Expand Down Expand Up @@ -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
Expand All @@ -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
}


Expand Down
2 changes: 2 additions & 0 deletions KkuMulKum/Source/Home/ViewModel/HomeViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -85,6 +86,7 @@ final class HomeViewModel {
} else {
currentState.value = .none
}
print("judgeReadyStatus = \(currentState.value)")
}

func requestMyReadyStatus() {
Expand Down

0 comments on commit f750f3e

Please sign in to comment.