Skip to content

Commit 148b437

Browse files
design: 홈화면 분실물 UI 변경
1 parent f6c9995 commit 148b437

1 file changed

Lines changed: 38 additions & 30 deletions

File tree

Koin/Presentation/Home/Home/SubViews/LostItemListView.swift

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,22 @@ final class LostItemListView: UIView {
2323
$0.font = UIFont.appFont(.pretendardBold, size: 15)
2424
}
2525

26-
private let chevronButton = UIButton().then {
27-
$0.setImage(UIImage(named: "chevronRightBlue")?.withRenderingMode(.alwaysTemplate), for: .normal)
28-
$0.tintColor = UIColor(hexCode: "1C1B1F")
29-
}
30-
3126
private let descriptionButton = UIButton().then {
3227
$0.backgroundColor = .appColor(.neutral100)
3328
$0.layer.cornerRadius = 8
3429
$0.clipsToBounds = true
3530
}
3631

32+
private let descriptionLabel = UILabel().then {
33+
$0.font = .appFont(.pretendardMedium, size: 14)
34+
$0.textColor = .appColor(.neutral800)
35+
}
36+
37+
private let chevronImageView = UIImageView(image: .appImage(asset: .chevronRightBlue)?.withTintColor(UIColor(hexCode: "1C1B1F"))
38+
)
39+
40+
41+
3742
// MARK: - Initializer
3843
init() {
3944
super.init(frame: .zero)
@@ -47,16 +52,25 @@ final class LostItemListView: UIView {
4752
func configure(lostItemStats: LostItemStats) {
4853
foundCountTitle = "지금까지 \(lostItemStats.foundCount)명이 분실물을 찾았어요."
4954
notFoundCountTitle = "\(lostItemStats.notFoundCount)개의 분실물이 주인을 찾고있어요."
50-
descriptionButton.setAttributedTitle(NSAttributedString(
51-
string: notFoundCountTitle,
52-
attributes: [
53-
.font : UIFont.appFont(.pretendardMedium, size: 14),
54-
.foregroundColor : UIColor.appColor(.neutral800)
55-
]), for: .normal
56-
)
55+
56+
let longerTitle: String
57+
foundCountTitle.count < notFoundCountTitle.count ? (longerTitle = notFoundCountTitle) : (longerTitle = foundCountTitle)
58+
59+
descriptionLabel.text = longerTitle
60+
61+
descriptionLabel.snp.remakeConstraints {
62+
$0.center.equalTo(descriptionButton)
63+
$0.width.equalTo(descriptionLabel.intrinsicContentSize.width)
64+
}
65+
chevronImageView.snp.remakeConstraints {
66+
$0.centerY.equalTo(descriptionLabel)
67+
$0.leading.equalTo(descriptionLabel.snp.trailing).offset(8)
68+
}
5769

5870
if 50 <= lostItemStats.foundCount {
5971
setTimer()
72+
} else {
73+
descriptionLabel.text = notFoundCountTitle
6074
}
6175
}
6276
}
@@ -73,24 +87,16 @@ extension LostItemListView {
7387
$0.type = .push
7488
$0.subtype = .fromTop
7589
}
76-
descriptionButton.titleLabel?.layer.add(transition, forKey: "newTitle")
90+
descriptionLabel.layer.add(transition, forKey: "newTitle")
7791

78-
let newTitle = descriptionButton.titleLabel?.text == notFoundCountTitle ? foundCountTitle : notFoundCountTitle
92+
let newTitle = descriptionLabel.text == notFoundCountTitle ? foundCountTitle : notFoundCountTitle
7993

80-
descriptionButton.setAttributedTitle(NSAttributedString(
81-
string: newTitle,
82-
attributes: [
83-
.font : UIFont.appFont(.pretendardMedium, size: 14),
84-
.foregroundColor : UIColor.appColor(.neutral800)
85-
]), for: .normal
86-
)
94+
descriptionLabel.text = newTitle
8795
}
8896
}
8997

9098
private func setAddTargets() {
91-
[chevronButton, descriptionButton].forEach {
92-
$0.addTarget(self, action: #selector(lostItemListTapped), for: .touchUpInside)
93-
}
99+
descriptionButton.addTarget(self, action: #selector(lostItemListTapped), for: .touchUpInside)
94100
}
95101
@objc private func lostItemListTapped() {
96102
lostItemListTappedPublisher.send()
@@ -99,7 +105,7 @@ extension LostItemListView {
99105
extension LostItemListView {
100106

101107
private func setLayouts() {
102-
[nameLabel, chevronButton, descriptionButton].forEach {
108+
[nameLabel, descriptionButton, descriptionLabel, chevronImageView].forEach {
103109
addSubview($0)
104110
}
105111
}
@@ -108,17 +114,19 @@ extension LostItemListView {
108114
$0.top.equalToSuperview()
109115
$0.leading.equalToSuperview().offset(20)
110116
}
111-
chevronButton.snp.makeConstraints {
112-
$0.centerY.equalTo(nameLabel)
113-
$0.trailing.equalToSuperview().offset(-24)
114-
$0.size.equalTo(29)
115-
}
116117
descriptionButton.snp.makeConstraints {
117118
$0.top.equalTo(nameLabel.snp.bottom).offset(16)
118119
$0.leading.trailing.equalToSuperview().inset(24)
119120
$0.height.equalTo(44)
120121
$0.bottom.equalToSuperview()
121122
}
123+
descriptionLabel.snp.makeConstraints {
124+
$0.center.equalTo(descriptionButton)
125+
}
126+
chevronImageView.snp.makeConstraints {
127+
$0.centerY.equalTo(descriptionLabel)
128+
$0.centerX.equalTo(descriptionLabel).offset(100)
129+
}
122130
}
123131
private func configureView() {
124132
setLayouts()

0 commit comments

Comments
 (0)