11import UIKit
22
33import DesignSystem
4+ import Infrastructure
45
56import ReactorKit
67import RxSwift
@@ -9,63 +10,70 @@ import SnapKit
910final class StoreListCell: UICollectionViewCell {
1011 static let identifier = "StoreListCell"
1112
13+ // MARK: - Properties
14+ var disposeBag = DisposeBag()
15+
16+ private enum Constant {
17+ static let imageHeight: CGFloat = 140
18+ static let bookmarkSize: CGFloat = 24
19+ static let bookmarkInset: CGFloat = 8
20+ static let categoryTopOffset: CGFloat = 12
21+ static let categoryHeight: CGFloat = 15
22+ static let titleTopOffset: CGFloat = 4
23+ static let addressHeight: CGFloat = 17
24+ static let dateHeight: CGFloat = 15
25+ static let cornerRadius: CGFloat = 12
26+ }
27+
1228 // MARK: - Components
13- private let thumbnailImageView: UIImageView = {
14- let iv = UIImageView()
15- iv.contentMode = .scaleAspectFill
16- iv.clipsToBounds = true
17- iv.layer.cornerRadius = 12
18- iv.backgroundColor = .g100
19- return iv
20- }()
21-
22- let bookmarkButton: UIButton = {
23- let button = UIButton()
24- button.setImage(UIImage(named: "icon_bookmark"), for: .normal)
25- button.backgroundColor = .clear
26- button.layer.cornerRadius = 12
27- return button
28- }()
29-
30- private let categoryTagLabel: PPLabel = {
31- let label = PPLabel(style: .bold, fontSize: 11, text: "")
32- label.textColor = .blu500
33- label.text = "#카테고리"
34- return label
35- }()
36-
37- private let titleLabel: PPLabel = {
38- let label = PPLabel(style: .bold, fontSize: 14, text: "")
39- label.textColor = .g900
40- label.numberOfLines = 2
41- return label
42- }()
43-
44- private let locationLabel: PPLabel = {
45- let label = PPLabel(style: .medium, fontSize: 11, text: "")
46- label.textColor = .g400
47- label.numberOfLines = 2
48- return label
49- }()
50-
51- private let dateLabel: PPLabel = {
52- let label = PPLabel(style: .regular, fontSize: 12, text: "")
53- label.textColor = .g400
54- label.numberOfLines = 2
55- return label
56- }()
29+ private let thumbnailImageView = UIImageView().then {
30+ $0.contentMode = .scaleAspectFill
31+ $0.clipsToBounds = true
32+ $0.layer.cornerRadius = Constant.cornerRadius
33+ $0.backgroundColor = .g100
34+ }
5735
58- var disposeBag = DisposeBag()
36+ let bookmarkButton = UIButton().then {
37+ $0.setImage(UIImage(named: "icon_bookmark"), for: .normal)
38+ $0.backgroundColor = .clear
39+ }
40+
41+ private let categoryTagLabel = PPLabel(style: .bold, fontSize: 11).then {
42+ $0.textColor = .blu500
43+ $0.setLineHeightText(text: "category", font: .korFont(style: .bold, size: 11))
44+ }
45+
46+ private let titleLabel = PPLabel(style: .bold, fontSize: 14).then {
47+ $0.numberOfLines = 2
48+ $0.lineBreakMode = .byTruncatingTail
49+ $0.textColor = .g900
50+ $0.setLineHeightText(text: "title", font: .korFont(style: .bold, size: 14))
51+ }
52+
53+ private let locationLabel = PPLabel(style: .medium, fontSize: 11).then {
54+ $0.numberOfLines = 1
55+ $0.lineBreakMode = .byTruncatingTail
56+ $0.textColor = .g400
57+ $0.setLineHeightText(text: "location", font: .korFont(style: .medium, size: 11))
58+ }
59+
60+ private let dateLabel = PPLabel(style: .medium, fontSize: 11).then {
61+ $0.lineBreakMode = .byTruncatingTail
62+ $0.textColor = .g400
63+ $0.setLineHeightText(text: "date", font: .korFont(style: .medium, size: 11))
64+ }
5965
6066 // MARK: - Init
6167 override init(frame: CGRect) {
6268 super.init(frame: frame)
63- setUpConstraints()
64- configureUI()
69+
70+ self.addViews()
71+ self.setupConstraints()
72+ self.configureUI()
6573 }
6674
6775 required init?(coder: NSCoder) {
68- fatalError()
76+ fatalError("\(#file), \(#function) Error" )
6977 }
7078
7179 override func prepareForReuse() {
@@ -76,52 +84,56 @@ final class StoreListCell: UICollectionViewCell {
7684
7785// MARK: - SetUp
7886private extension StoreListCell {
79- func configureUI() {
80- // backgroundColor = .white
87+ func addViews() {
88+ [thumbnailImageView, categoryTagLabel, titleLabel, locationLabel, dateLabel, bookmarkButton].forEach {
89+ self.contentView.addSubview($0)
90+ }
8191 }
8292
83- func setUpConstraints() {
84- contentView.addSubview(thumbnailImageView)
93+ func setupConstraints() {
8594 thumbnailImageView.snp.makeConstraints { make in
86- make.top.leading.equalToSuperview()
87- make.width.equalTo((UIScreen.main.bounds.width - 48) / 2)
88- make.height.equalTo(thumbnailImageView.snp.width)
95+ make.width.equalTo(contentView.bounds.width)
96+ make.height.equalTo(Constant.imageHeight)
97+ make.top.equalToSuperview()
98+ make.centerX.equalToSuperview()
8999 }
90100
91- contentView.addSubview(bookmarkButton)
92101 bookmarkButton.snp.makeConstraints { make in
93- make.top.trailing.equalToSuperview().inset(8)
94- make.size.equalTo(24)
102+ make.size.equalTo(Constant.bookmarkSize)
103+ make.top.trailing.equalToSuperview().inset(Constant.bookmarkInset)
104+ }
105+
106+ categoryTagLabel.snp.makeConstraints { make in
107+ make.leading.equalToSuperview()
108+ make.top.equalTo(thumbnailImageView.snp.bottom).offset(Constant.categoryTopOffset)
109+ make.height.equalTo(Constant.categoryHeight)
110+ }
111+
112+ titleLabel.snp.makeConstraints { make in
113+ make.top.equalTo(categoryTagLabel.snp.bottom).offset(Constant.titleTopOffset)
114+ make.leading.trailing.equalToSuperview()
115+ }
116+
117+ dateLabel.snp.makeConstraints { make in
118+ make.leading.equalToSuperview()
119+ make.height.equalTo(Constant.dateHeight).priority(.high)
120+ make.bottom.equalToSuperview()
95121 }
96122
97- contentView.addSubview(categoryTagLabel)
98- contentView.addSubview(titleLabel)
99- contentView.addSubview(locationLabel)
100- contentView.addSubview(dateLabel)
101-
102- // 각 라벨의 위치 설정
103- categoryTagLabel.snp.makeConstraints { make in
104- make.top.equalTo(thumbnailImageView.snp.bottom).offset(10)
105- make.leading.trailing.equalToSuperview()
106- make.height.equalTo(16)
107- }
108-
109- titleLabel.snp.makeConstraints { make in
110- make.top.equalTo(categoryTagLabel.snp.bottom).offset(6)
111- make.leading.trailing.equalToSuperview()
112- }
113-
114- locationLabel.snp.makeConstraints { make in
115- make.top.equalTo(titleLabel.snp.bottom).offset(12)
116- make.leading.trailing.equalToSuperview()
117- }
118-
119- dateLabel.snp.makeConstraints { make in
120- make.top.equalTo(locationLabel.snp.bottom).offset(6)
121- make.leading.trailing.equalToSuperview()
122- make.bottom.lessThanOrEqualToSuperview()
123- }
124- }
123+ locationLabel.snp.makeConstraints { make in
124+ make.leading.trailing.equalToSuperview()
125+ make.bottom.equalTo(dateLabel.snp.top)
126+ make.height.equalTo(Constant.addressHeight).priority(.high)
127+ }
128+ }
129+
130+ func configureUI() {
131+ self.contentView.layer.cornerRadius = 4
132+ self.contentView.clipsToBounds = true
133+
134+ thumbnailImageView.layer.cornerRadius = 4
135+ thumbnailImageView.clipsToBounds = true
136+ }
125137}
126138
127139// MARK: - Inputable
@@ -145,5 +157,4 @@ extension StoreListCell: Inputable {
145157 let bookmarkImage = input.isBookmarked ? "icon_bookmark_fill" : "icon_bookmark"
146158 bookmarkButton.setImage(UIImage(named: bookmarkImage), for: .normal)
147159 }
148-
149160}
0 commit comments