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

[Refactor] #196 - 디테일 성취 UI 로직 변경 #201

Merged
merged 10 commits into from
Jan 27, 2024
4 changes: 4 additions & 0 deletions iOS-NOTTODO/iOS-NOTTODO.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
09A146652A1964B500DDC308 /* AddAnotherDayResponseDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09A146642A19649A00DDC308 /* AddAnotherDayResponseDTO.swift */; };
09C8602D2AB14B4800C4F4B1 /* FSCalendar in Frameworks */ = {isa = PBXBuildFile; productRef = 09C8602C2AB14B4800C4F4B1 /* FSCalendar */; };
09CF56042B09F23800526C8C /* HomeDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09CF56032B09F23800526C8C /* HomeDataSource.swift */; };
09CF56022B09E98A00526C8C /* DetailAchieveHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09CF56012B09E98A00526C8C /* DetailAchieveHeaderView.swift */; };
09DCCD1F2A18ED76003DCF8A /* DailyMissionResponseDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09DCCD1E2A18ED76003DCF8A /* DailyMissionResponseDTO.swift */; };
09DCCD212A18EF43003DCF8A /* HomeSevice.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09DCCD202A18EF43003DCF8A /* HomeSevice.swift */; };
09DCCD232A18EFB0003DCF8A /* HomeAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09DCCD222A18EFB0003DCF8A /* HomeAPI.swift */; };
Expand Down Expand Up @@ -209,6 +210,7 @@
09A1465E2A192C4900DDC308 /* WeekMissionResponseDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeekMissionResponseDTO.swift; sourceTree = "<group>"; };
09A146642A19649A00DDC308 /* AddAnotherDayResponseDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddAnotherDayResponseDTO.swift; sourceTree = "<group>"; };
09CF56032B09F23800526C8C /* HomeDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeDataSource.swift; sourceTree = "<group>"; };
09CF56012B09E98A00526C8C /* DetailAchieveHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailAchieveHeaderView.swift; sourceTree = "<group>"; };
09DCCD1E2A18ED76003DCF8A /* DailyMissionResponseDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DailyMissionResponseDTO.swift; sourceTree = "<group>"; };
09DCCD202A18EF43003DCF8A /* HomeSevice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeSevice.swift; sourceTree = "<group>"; };
09DCCD222A18EFB0003DCF8A /* HomeAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeAPI.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -590,6 +592,7 @@
3B027AA1299C355800BEB65C /* AchievementViewController.swift */,
09582B5029C0BC3600EF3207 /* DetailAchievementViewController.swift */,
0930D37229B4FCAE0000C4AE /* StatisticsView.swift */,
09CF56012B09E98A00526C8C /* DetailAchieveHeaderView.swift */,
);
path = ViewControllers;
sourceTree = "<group>";
Expand Down Expand Up @@ -1332,6 +1335,7 @@
3B11740D2A4B574B0033DDF3 /* CALayer+.swift in Sources */,
3B14A13D29A6FBD300F92897 /* UIView+.swift in Sources */,
09F6719529CBFCD200708725 /* GradientView.swift in Sources */,
09CF56022B09E98A00526C8C /* DetailAchieveHeaderView.swift in Sources */,
3B4E12F82A27C12F001D1EC1 /* WithdrawModalView.swift in Sources */,
6CA208252A18FEEA001C4247 /* RecommendService.swift in Sources */,
3B482FA5299EAB8800BCF424 /* TabBarController.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@

import UIKit

class DetailAchievementCollectionViewCell: UICollectionViewCell {
import SnapKit
import Then

final class DetailAchievementCollectionViewCell: UICollectionViewCell {

// MARK: - Properties

Expand All @@ -16,15 +19,14 @@ class DetailAchievementCollectionViewCell: UICollectionViewCell {
// MARK: - UI Components

let tagLabel = PaddingLabel(padding: UIEdgeInsets(top: 4, left: 12, bottom: 4, right: 12))
private let horizontalStackView = UIStackView()
private let emptyView = UIView()
let titleLabel = UILabel()
private let checkImage = UIImageView()

// MARK: - Life Cycle

override init(frame: CGRect) {
super.init(frame: frame)

setUI()
setLayout()
}
Expand All @@ -37,55 +39,57 @@ class DetailAchievementCollectionViewCell: UICollectionViewCell {
// MARK: - Methods

extension DetailAchievementCollectionViewCell {

private func setUI() {

contentView.backgroundColor = .clear

tagLabel.do {
$0.layer.backgroundColor = UIColor.bg?.cgColor
$0.font = .Pretendard(.medium, size: 14)
$0.textColor = .gray1
$0.layer.cornerRadius = 10
$0.layer.cornerRadius = 25/2
}

horizontalStackView.do {
$0.addArrangedSubviews(titleLabel, emptyView, checkImage)
$0.axis = .horizontal
}


titleLabel.do {
$0.font = .Pretendard(.semiBold, size: 16)
$0.textColor = .gray2
$0.numberOfLines = 0
$0.numberOfLines = 1
$0.textAlignment = .left
}

checkImage.do {
$0.image = .icChecked
}
}

private func setLayout() {
addSubviews(tagLabel, horizontalStackView)
contentView.addSubviews(tagLabel, titleLabel, checkImage)

tagLabel.snp.makeConstraints {
$0.top.equalToSuperview().offset(22)
$0.leading.equalToSuperview().offset(29)
$0.leading.equalToSuperview().inset(28)
}
horizontalStackView.snp.makeConstraints {

titleLabel.snp.makeConstraints {
$0.top.equalTo(tagLabel.snp.bottom).offset(7)
$0.leading.equalToSuperview().inset(28)
$0.trailing.equalToSuperview()
$0.bottom.equalToSuperview().inset(24)
$0.trailing.equalToSuperview().inset(50)
}

checkImage.snp.makeConstraints {
$0.trailing.equalToSuperview()
$0.centerY.equalTo(titleLabel.snp.centerY)
$0.size.equalTo(21)
$0.trailing.equalToSuperview().inset(28)
$0.bottom.equalToSuperview().inset(24)
}
}

func configure(model: DailyMissionResponseDTO) {
tagLabel.text = model.title
titleLabel.text = model.situationName
tagLabel.text = model.situationName
titleLabel.text = model.title
titleLabel.lineBreakMode = .byTruncatingTail

switch model.completionStatus {
case .CHECKED: checkImage.isHidden = false
case .UNCHECKED: checkImage.isHidden = true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//
// DetailAchieveHeaderView.swift
// iOS-NOTTODO
//
// Created by JEONGEUN KIM on 11/19/23.
//

import UIKit

import SnapKit
import Then

final class DetailAchieveHeaderView: UICollectionReusableView {

// MARK: - Properties

static let identifier = "DetailAchieveHeaderView"

// MARK: - UI Components

private let dateLabel = UILabel()

// MARK: - Life Cycle

override init(frame: CGRect) {
super.init(frame: .zero)

setUI()
setLayout()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

}

// MARK: - Method

extension DetailAchieveHeaderView {

private func setUI() {

dateLabel.do {
$0.font = .Pretendard(.semiBold, size: 18)
$0.textColor = .gray2
$0.textAlignment = .center
}
}

private func setLayout() {
addSubview(dateLabel)

dateLabel.snp.makeConstraints {
$0.top.equalToSuperview()
$0.centerX.equalToSuperview()
$0.bottom.equalToSuperview().inset(12)
}
}

func configure(text: String) {
dateLabel.text = text
}
}
Loading