Skip to content

Commit

Permalink
Fix: Metric 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
GeonH0 committed Jun 26, 2024
1 parent 52d89ea commit 1a760ca
Showing 1 changed file with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,31 @@ import UIKit

final class RecipeListView: UIView {

private let itemSize = CGSize(width: UIScreen.main.bounds.width - 20, height: 200)
private enum Metric {
static let itemSize: CGSize = .init(width: UIScreen.main.bounds.width - 20, height: 200)
static let minimumLineSpacing: CGFloat = 10.0
static let minimumInteritemSpacing: CGFloat = 10.0

}
private let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())

override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
setupLayout()
}

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

private func setupUI() {
backgroundColor = .white
addSubview(collectionView)
collectionView.register(RecipeListViewCell.self, forCellWithReuseIdentifier: "RecipeCell")
configureCollectionView()
}

private func setupLayout() {
collectionView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
Expand All @@ -38,12 +43,12 @@ final class RecipeListView: UIView {
collectionView.bottomAnchor.constraint(equalTo: safeAreaLayoutGuide.bottomAnchor)
])
}

private func configureCollectionView() {
let layout = UICollectionViewFlowLayout()
layout.itemSize = itemSize
layout.minimumLineSpacing = 10
layout.minimumInteritemSpacing = 10
layout.itemSize = Metric.itemSize
layout.minimumLineSpacing = Metric.minimumLineSpacing
layout.minimumInteritemSpacing = Metric.minimumInteritemSpacing
collectionView.collectionViewLayout = layout
}

Expand Down

0 comments on commit 1a760ca

Please sign in to comment.