Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] #141 - 홈 상세보기, 다른 날짜 추가 UI 수정 #142

Merged
merged 2 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ final class MissionDetailCollectionViewCell: UICollectionViewCell {
private let accumulateView = UIView()
private let accumulateSubView = UIView()
private let accumulateLabel = UILabel()

private let verticalStackView = UIStackView()
private let action = DetailStackView(tag: I18N.detailAction, isTop: true, empty: .actionEmpty)
private let goal = DetailStackView(tag: I18N.detailGoal, isTop: false, empty: .goalEmpty)
Expand Down Expand Up @@ -54,27 +53,32 @@ extension MissionDetailCollectionViewCell {
$0.font = .Pretendard(.medium, size: 14)
$0.textColor = .gray1
}

missionLabel.do {
$0.font = .Pretendard(.semiBold, size: 20)
$0.textColor = .gray2
$0.numberOfLines = 0
}

accumulateView.do {
$0.backgroundColor = .green2?.withAlphaComponent(0.3)
$0.layer.masksToBounds = true
$0.layer.cornerRadius = 34
}

accumulateSubView.do {
$0.backgroundColor = .green2
$0.layer.masksToBounds = true
$0.layer.cornerRadius = 28
}

accumulateLabel.do {
$0.textAlignment = .center
$0.textColor = .white
$0.font = .Pretendard(.semiBold, size: 14)
$0.numberOfLines = 2
}

verticalStackView.do {
$0.addArrangedSubviews(action, goal)
$0.axis = .vertical
Expand All @@ -84,30 +88,35 @@ extension MissionDetailCollectionViewCell {
}

private func setLayout() {
contentView.addSubviews(missionTagLabel, missionLabel, accumulateView, verticalStackView)
contentView.addSubviews(missionTagLabel, accumulateView, missionLabel, verticalStackView)
accumulateView.addSubviews(accumulateSubView, accumulateLabel)

missionTagLabel.snp.makeConstraints {
$0.top.equalToSuperview().offset(30)
$0.leading.equalToSuperview().offset(29)
}
missionLabel.snp.makeConstraints {
$0.top.equalTo(missionTagLabel.snp.bottom).offset(10)
$0.leading.equalTo(missionTagLabel.snp.leading)
}

accumulateView.snp.makeConstraints {
$0.top.equalTo(missionTagLabel.snp.top)
$0.trailing.equalToSuperview().inset(19)
$0.width.height.equalTo(68)
}

accumulateSubView.snp.makeConstraints {
$0.center.centerY.equalToSuperview()
$0.width.height.equalTo(56)
}

missionLabel.snp.makeConstraints {
$0.top.equalTo(missionTagLabel.snp.bottom).offset(10)
$0.leading.equalTo(missionTagLabel.snp.leading)
$0.trailing.equalTo(accumulateView.snp.leading).offset(-30)
}

accumulateLabel.snp.makeConstraints {
$0.centerX.centerY.equalToSuperview()
}

verticalStackView.snp.makeConstraints {
$0.top.equalTo(missionLabel.snp.bottom).offset(56)
$0.directionalHorizontalEdges.equalToSuperview().inset(29)
Expand All @@ -118,7 +127,9 @@ extension MissionDetailCollectionViewCell {
func configure(model: MissionDetailResponseDTO) {
missionTagLabel.text = model.situation
missionLabel.text = model.title
missionLabel.setLineSpacing(lineSpacing: 6.0)
accumulateLabel.text = "\(model.count)회\n달성"

if model.actions.isEmpty || model.actions.contains(where: { $0.name.isEmpty }) {
action.titleLabel.isHidden = true
action.emptyIcon.isHidden = false
Expand All @@ -130,6 +141,7 @@ extension MissionDetailCollectionViewCell {
action.verticalStackView.removeArrangedSubview(action.emptyIcon)
action.emptyIcon.removeFromSuperview()
}

if model.goal.isEmpty {
goal.titleLabel.isHidden = true
goal.emptyIcon.isHidden = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,19 @@ extension DetailCalendarViewController {
private func requestAddAnotherDay(id: Int, dates: [String]) {
HomeAPI.shared.postAnotherDay(id: id, dates: dates) { response in
guard response != nil else { return }
self.setUI()
self.dismiss(animated: true)
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy.MM.dd"
if let earliestDate = dateFormatter.date(from: self.anotherDate.min() ?? "") {
let earliestDateString = dateFormatter.string(from: earliestDate)
print("The earliest date is \(earliestDateString)")
self.movedateClosure?(earliestDateString)
} else {
print("Invalid date strings")
guard let statusCode = response?.status else { return }
switch statusCode {
case 200..<204:
self.setUI()
self.dismiss(animated: true)
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy.MM.dd"
if let earliestDate = dateFormatter.date(from: self.anotherDate.min() ?? "") {
let earliestDateString = dateFormatter.string(from: earliestDate)
self.movedateClosure?(earliestDateString)
}
default:
self.showToast(message: self.htmlToString(response?.message ?? "")?.string ?? "", controller: self)
}
}
}
Expand Down