@@ -9,26 +9,31 @@ import UIKit
9
9
10
10
final class RecipeListView : UIView {
11
11
12
- private let itemSize = CGSize ( width: UIScreen . main. bounds. width - 20 , height: 200 )
12
+ private enum Metric {
13
+ static let itemSize : CGSize = . init( width: UIScreen . main. bounds. width - 20 , height: 200 )
14
+ static let minimumLineSpacing : CGFloat = 10.0
15
+ static let minimumInteritemSpacing : CGFloat = 10.0
16
+
17
+ }
13
18
private let collectionView = UICollectionView ( frame: . zero, collectionViewLayout: UICollectionViewFlowLayout ( ) )
14
-
19
+
15
20
override init ( frame: CGRect ) {
16
21
super. init ( frame: frame)
17
22
setupUI ( )
18
23
setupLayout ( )
19
24
}
20
-
25
+
21
26
required init ? ( coder: NSCoder ) {
22
27
fatalError ( " init(coder:) has not been implemented " )
23
28
}
24
-
29
+
25
30
private func setupUI( ) {
26
31
backgroundColor = . white
27
32
addSubview ( collectionView)
28
33
collectionView. register ( RecipeListViewCell . self, forCellWithReuseIdentifier: " RecipeCell " )
29
34
configureCollectionView ( )
30
35
}
31
-
36
+
32
37
private func setupLayout( ) {
33
38
collectionView. translatesAutoresizingMaskIntoConstraints = false
34
39
NSLayoutConstraint . activate ( [
@@ -38,12 +43,12 @@ final class RecipeListView: UIView {
38
43
collectionView. bottomAnchor. constraint ( equalTo: safeAreaLayoutGuide. bottomAnchor)
39
44
] )
40
45
}
41
-
46
+
42
47
private func configureCollectionView( ) {
43
48
let layout = UICollectionViewFlowLayout ( )
44
- layout. itemSize = itemSize
45
- layout. minimumLineSpacing = 10
46
- layout. minimumInteritemSpacing = 10
49
+ layout. itemSize = Metric . itemSize
50
+ layout. minimumLineSpacing = Metric . minimumLineSpacing
51
+ layout. minimumInteritemSpacing = Metric . minimumInteritemSpacing
47
52
collectionView. collectionViewLayout = layout
48
53
}
49
54
0 commit comments