11import UIKit
22
33import DesignSystem
4+ import Infrastructure
45
56import ReactorKit
67import RxSwift
@@ -10,55 +11,71 @@ import Then
1011final class StoreListCell : UICollectionViewCell {
1112 static let identifier = " StoreListCell "
1213
14+ // MARK: - Properties
15+ var disposeBag = DisposeBag ( )
16+
17+ private enum Constant {
18+ static let imageHeight : CGFloat = 140
19+ static let bookmarkSize : CGFloat = 24
20+ static let bookmarkInset : CGFloat = 8
21+ static let categoryTopOffset : CGFloat = 12
22+ static let categoryHeight : CGFloat = 15
23+ static let titleTopOffset : CGFloat = 4
24+ static let addressHeight : CGFloat = 17
25+ static let dateHeight : CGFloat = 15
26+ static let cornerRadius : CGFloat = 12
27+ static let cellCornerRadius : CGFloat = 4
28+ }
29+
1330 // MARK: - Components
14- private let thumbnailImageView : UIImageView = {
15- let iv = UIImageView ( )
16- iv. contentMode = . scaleAspectFill
17- iv. clipsToBounds = true
18- iv. layer. cornerRadius = 12
19- iv. backgroundColor = . g100
20- return iv
21- } ( )
22-
23- let bookmarkButton : UIButton = {
24- let button = UIButton ( )
25- button. setImage ( UIImage ( named: " icon_bookmark " ) , for: . normal)
26- button. backgroundColor = . clear
27- button. layer. cornerRadius = 12
28- return button
29- } ( )
30-
31- private let categoryTagLabel = PPLabel ( style: . KOb11) . then {
31+ private let thumbnailImageView = UIImageView ( ) . then {
32+ $0. contentMode = . scaleAspectFill
33+ $0. clipsToBounds = true
34+ $0. layer. cornerRadius = Constant . cornerRadius
35+ $0. backgroundColor = . g100
36+ }
37+
38+ let bookmarkButton = UIButton ( ) . then {
39+ $0. setImage ( UIImage ( named: " icon_bookmark " ) , for: . normal)
40+ $0. backgroundColor = . clear
41+ $0. layer. cornerRadius = Constant . cornerRadius
42+ }
43+
44+ private let categoryTagLabel = PPLabel ( style: . bold, fontSize: 11 ) . then {
3245 $0. textColor = . blu500
46+ $0. setLineHeightText ( text: " category " , font: . korFont( style: . bold, size: 11 ) )
3347 }
3448
35- private let titleLabel = PPLabel ( style: . KOb14) . then {
36- $0. textColor = . g900
49+ private let titleLabel = PPLabel ( style: . bold, fontSize: 14 ) . then {
3750 $0. numberOfLines = 2
51+ $0. lineBreakMode = . byTruncatingTail
52+ $0. textColor = . g900
53+ $0. setLineHeightText ( text: " title " , font: . korFont( style: . bold, size: 14 ) )
3854 }
3955
40- private let locationLabel = PPLabel ( style: . KOm11) . then {
56+ private let locationLabel = PPLabel ( style: . medium, fontSize: 11 ) . then {
57+ $0. numberOfLines = 1
58+ $0. lineBreakMode = . byTruncatingTail
4159 $0. textColor = . g400
42- $0. numberOfLines = 2
60+ $0. setLineHeightText ( text : " location " , font : . korFont ( style : . medium , size : 11 ) )
4361 }
4462
45- private let dateLabel = PPLabel ( style: . KOr12) . then {
63+ private let dateLabel = PPLabel ( style: . medium, fontSize: 11 ) . then {
64+ $0. lineBreakMode = . byTruncatingTail
4665 $0. textColor = . g400
47- $0. numberOfLines = 2
66+ $0. setLineHeightText ( text : " date " , font : . korFont ( style : . medium , size : 11 ) )
4867 }
4968
50- var disposeBag = DisposeBag ( )
51-
5269 // MARK: - Init
5370 override init ( frame: CGRect ) {
5471 super. init ( frame: frame)
55-
56- setUpConstraints ( )
57- configureUI ( )
72+ self . addViews ( )
73+ self . setupConstraints ( )
74+ self . configureUI ( )
5875 }
5976
6077 required init ? ( coder: NSCoder ) {
61- fatalError ( )
78+ fatalError ( " \( #file ) , \( #function ) Error " )
6279 }
6380
6481 override func prepareForReuse( ) {
@@ -69,55 +86,58 @@ final class StoreListCell: UICollectionViewCell {
6986
7087// MARK: - SetUp
7188private extension StoreListCell {
72- func configureUI( ) {
73- // backgroundColor = .white
89+ func addViews( ) {
90+ [ thumbnailImageView, categoryTagLabel, titleLabel, locationLabel, dateLabel, bookmarkButton] . forEach {
91+ self . contentView. addSubview ( $0)
92+ }
7493 }
7594
76- func setUpConstraints( ) {
77- contentView. addSubview ( thumbnailImageView)
95+ func setupConstraints( ) {
7896 thumbnailImageView. snp. makeConstraints { make in
79- make. top. leading. equalToSuperview ( )
80- make. width. equalTo ( ( UIScreen . main. bounds. width - 48 ) / 2 )
81- make. height. equalTo ( thumbnailImageView. snp. width)
97+ make. width. equalTo ( self . contentView. bounds. width)
98+ make. height. equalTo ( Constant . imageHeight)
99+ make. top. equalToSuperview ( )
100+ make. centerX. equalToSuperview ( )
82101 }
83102
84- contentView. addSubview ( bookmarkButton)
85103 bookmarkButton. snp. makeConstraints { make in
86- make. top. trailing. equalToSuperview ( ) . inset ( 8 )
87- make. size. equalTo ( 24 )
104+ make. size. equalTo ( Constant . bookmarkSize)
105+ make. top. trailing. equalToSuperview ( ) . inset ( Constant . bookmarkInset)
106+ }
107+
108+ categoryTagLabel. snp. makeConstraints { make in
109+ make. leading. equalToSuperview ( )
110+ make. top. equalTo ( self . thumbnailImageView. snp. bottom) . offset ( Constant . categoryTopOffset)
111+ make. height. equalTo ( Constant . categoryHeight)
112+ }
113+
114+ titleLabel. snp. makeConstraints { make in
115+ make. top. equalTo ( self . categoryTagLabel. snp. bottom) . offset ( Constant . titleTopOffset)
116+ make. leading. trailing. equalToSuperview ( )
117+ }
118+
119+ dateLabel. snp. makeConstraints { make in
120+ make. leading. equalToSuperview ( )
121+ make. height. equalTo ( Constant . dateHeight) . priority ( . high)
122+ make. bottom. equalToSuperview ( )
123+ }
124+
125+ locationLabel. snp. makeConstraints { make in
126+ make. leading. trailing. equalToSuperview ( )
127+ make. bottom. equalTo ( self . dateLabel. snp. top)
128+ make. height. equalTo ( Constant . addressHeight) . priority ( . high)
88129 }
130+ }
89131
90- contentView. addSubview ( categoryTagLabel)
91- contentView. addSubview ( titleLabel)
92- contentView. addSubview ( locationLabel)
93- contentView. addSubview ( dateLabel)
94-
95- // κ° λΌλ²¨μ μμΉ μ€μ
96- categoryTagLabel. snp. makeConstraints { make in
97- make. top. equalTo ( thumbnailImageView. snp. bottom) . offset ( 10 )
98- make. leading. trailing. equalToSuperview ( )
99- make. height. equalTo ( 16 )
100- }
101-
102- titleLabel. snp. makeConstraints { make in
103- make. top. equalTo ( categoryTagLabel. snp. bottom) . offset ( 6 )
104- make. leading. trailing. equalToSuperview ( )
105- }
106-
107- locationLabel. snp. makeConstraints { make in
108- make. top. equalTo ( titleLabel. snp. bottom) . offset ( 12 )
109- make. leading. trailing. equalToSuperview ( )
110- }
111-
112- dateLabel. snp. makeConstraints { make in
113- make. top. equalTo ( locationLabel. snp. bottom) . offset ( 6 )
114- make. leading. trailing. equalToSuperview ( )
115- make. bottom. lessThanOrEqualToSuperview ( )
116- }
117- }
132+ func configureUI( ) {
133+ self . contentView. layer. cornerRadius = Constant . cellCornerRadius
134+ self . contentView. clipsToBounds = true
135+
136+ self . thumbnailImageView. layer. cornerRadius = Constant . cornerRadius
137+ self . thumbnailImageView. clipsToBounds = true
138+ }
118139}
119140
120- // MARK: - Inputable
121141extension StoreListCell : Inputable {
122142 struct Input {
123143 let thumbnailURL : String
@@ -129,13 +149,13 @@ extension StoreListCell: Inputable {
129149 }
130150
131151 func injection( with input: Input ) {
132- thumbnailImageView. setPPImage ( path: input. thumbnailURL)
133- categoryTagLabel. updateText ( to: " # \( input. category) " )
134- titleLabel. updateText ( to: input. title)
135- locationLabel. updateText ( to: input. location)
136- dateLabel. updateText ( to: input. date)
152+ self . thumbnailImageView. setPPImage ( path: input. thumbnailURL)
153+ self . categoryTagLabel. updateText ( to: " # \( input. category) " )
154+ self . titleLabel. updateText ( to: input. title)
155+ self . locationLabel. updateText ( to: input. location)
156+ self . dateLabel. updateText ( to: input. date)
137157
138158 let bookmarkImage = input. isBookmarked ? " icon_bookmark_fill " : " icon_bookmark "
139- bookmarkButton. setImage ( UIImage ( named: bookmarkImage) , for: . normal)
159+ self . bookmarkButton. setImage ( UIImage ( named: bookmarkImage) , for: . normal)
140160 }
141161}
0 commit comments