@@ -17,10 +17,10 @@ class HeroDetailViewController: UIViewController, StoryboardInstantiable {
17
17
18
18
private func setupBarButtonItem( ) {
19
19
let image = UIImage ( named: " star " ) ? . withRenderingMode ( . alwaysTemplate)
20
- navigationItem. rightBarButtonItem = . init( image: image,
21
- style: . plain,
22
- target: self ,
23
- action: #selector( favoriteButtonTapped) )
20
+ navigationItem. rightBarButtonItem = . init( image: image,
21
+ style: . plain,
22
+ target: self ,
23
+ action: #selector( favoriteButtonTapped) )
24
24
}
25
25
26
26
private func setupCollectionView( ) {
@@ -51,7 +51,7 @@ extension HeroDetailViewController: HeroDetailInput {
51
51
func reloadData( ) {
52
52
collectionView. reloadData ( )
53
53
}
54
-
54
+
55
55
func showLoading( ) {
56
56
guard loadingIndicator == nil else { return }
57
57
let indicator = UIActivityIndicatorView ( style: . gray)
@@ -71,26 +71,29 @@ extension HeroDetailViewController: UICollectionViewDataSource {
71
71
return interactor. numberOfSections
72
72
}
73
73
74
- func collectionView( _ collectionView: UICollectionView , numberOfItemsInSection
75
- section: Int ) -> Int {
74
+ func collectionView( _ collectionView: UICollectionView ,
75
+ numberOfItemsInSection section: Int ) -> Int {
76
76
return interactor. numberOfItemsInSection ( section)
77
77
}
78
78
79
- func collectionView( _ collectionView: UICollectionView , cellForItemAt indexPath: IndexPath ) -> UICollectionViewCell {
79
+ func collectionView( _ collectionView: UICollectionView ,
80
+ cellForItemAt indexPath: IndexPath ) -> UICollectionViewCell {
80
81
switch interactor. cellTypeForSection ( indexPath. section) {
81
82
case . poster: return posterCell ( collectionView, cellForItemAt: indexPath)
82
83
case . card: return cardCell ( collectionView, cellForItemAt: indexPath)
83
84
}
84
85
}
85
86
86
- private func posterCell( _ collectionView: UICollectionView , cellForItemAt indexPath: IndexPath ) -> PosterCell {
87
+ private func posterCell( _ collectionView: UICollectionView ,
88
+ cellForItemAt indexPath: IndexPath ) -> PosterCell {
87
89
let cell = collectionView. dequeue ( PosterCell . self, for: indexPath)
88
90
cell. configure ( with: interactor. hero)
89
91
90
92
return cell
91
93
}
92
94
93
- private func cardCell( _ collectionView: UICollectionView , cellForItemAt indexPath: IndexPath ) -> CardCell {
95
+ private func cardCell( _ collectionView: UICollectionView ,
96
+ cellForItemAt indexPath: IndexPath ) -> CardCell {
94
97
let cell = collectionView. dequeue ( CardCell . self, for: indexPath)
95
98
cell. configure ( for: interactor. product ( at: indexPath) )
96
99
@@ -99,20 +102,26 @@ extension HeroDetailViewController: UICollectionViewDataSource {
99
102
}
100
103
101
104
extension HeroDetailViewController : UICollectionViewDelegateFlowLayout {
102
- func collectionView( _ collectionView: UICollectionView , layout collectionViewLayout: UICollectionViewLayout , referenceSizeForHeaderInSection section: Int ) -> CGSize {
105
+ func collectionView( _ collectionView: UICollectionView ,
106
+ layout collectionViewLayout: UICollectionViewLayout ,
107
+ referenceSizeForHeaderInSection section: Int ) -> CGSize {
103
108
return section > 0 ?
104
- . init( width: collectionView. frame. width, height: 50 ) :
109
+ . init( width: collectionView. frame. width, height: 50 ) :
105
110
. zero
106
111
}
107
112
108
- func collectionView( _ collectionView: UICollectionView , layout collectionViewLayout: UICollectionViewLayout , sizeForItemAt indexPath: IndexPath ) -> CGSize {
113
+ func collectionView( _ collectionView: UICollectionView ,
114
+ layout collectionViewLayout: UICollectionViewLayout ,
115
+ sizeForItemAt indexPath: IndexPath ) -> CGSize {
109
116
110
117
return indexPath. section == 0 ?
111
- . init( width: collectionView. frame. width, height: 300 ) :
118
+ . init( width: collectionView. frame. width, height: 300 ) :
112
119
. init( width: collectionView. frame. width, height: 272 )
113
120
}
114
121
115
- func collectionView( _ collectionView: UICollectionView , viewForSupplementaryElementOfKind kind: String , at indexPath: IndexPath ) -> UICollectionReusableView {
122
+ func collectionView( _ collectionView: UICollectionView ,
123
+ viewForSupplementaryElementOfKind kind: String ,
124
+ at indexPath: IndexPath ) -> UICollectionReusableView {
116
125
guard kind == UICollectionView . elementKindSectionHeader,
117
126
indexPath. section != 0 else { return UICollectionReusableView ( ) }
118
127
0 commit comments