Skip to content
This repository was archived by the owner on Jun 17, 2023. It is now read-only.

Commit 5cba1cc

Browse files
author
Amir Khorsandi
committed
Compact the generated code so it's more readable
1 parent 9b0bc04 commit 5cba1cc

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

Samples/PagingLayoutSamples/Modules/LayoutDesigner/Code/LayoutDesignerCodePreviewViewModel.swift

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)