@@ -55,8 +55,12 @@ struct LayoutDesignerCodePreviewViewModel {
5555 }
5656
5757 func setup() {
58- // use AutoLayout in real world
59- card = UIView(frame: CGRect(x: 80, y: 100, width: frame.width - 160, height: frame.height - 200))
58+ // preferably use AutoLayout! this is only for simplicity
59+ let cardFrame = CGRect(x: 80,
60+ y: 100,
61+ width: frame.width - 160,
62+ height: frame.height - 200)
63+ card = UIView(frame: cardFrame)
6064 card.backgroundColor = .gray
6165 contentView.addSubview(card)
6266 }
@@ -73,7 +77,10 @@ struct LayoutDesignerCodePreviewViewModel {
7377 }
7478
7579 private func setupCollectionView() {
76- collectionView = UICollectionView(frame: view.frame, collectionViewLayout: CollectionViewPagingLayout())
80+ collectionView = UICollectionView(
81+ frame: view.frame,
82+ collectionViewLayout: CollectionViewPagingLayout()
83+ )
7784 collectionView.isPagingEnabled = true
7885 collectionView.register(MyCell.self, forCellWithReuseIdentifier: " cell " )
7986 collectionView.dataSource = self
@@ -87,12 +94,20 @@ struct LayoutDesignerCodePreviewViewModel {
8794 })
8895 }
8996
90- func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
97+ func collectionView(
98+ _ collectionView: UICollectionView,
99+ numberOfItemsInSection section: Int
100+ ) -> Int {
91101 10
92102 }
93103
94- func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
95- collectionView.dequeueReusableCell(withReuseIdentifier: " cell " , for: indexPath)
104+ func collectionView(
105+ _ collectionView: UICollectionView,
106+ cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
107+ collectionView.dequeueReusableCell(
108+ withReuseIdentifier: " cell " ,
109+ for: indexPath
110+ )
96111 }
97112
98113 }
0 commit comments