@@ -53,36 +53,24 @@ final class HomePresenter {
5353/// Handles actions triggered by the View layer.
5454
5555extension HomePresenter : ViewToPresenterHomeProtocol {
56+
57+
5658
5759 func viewDidLoad( ) {
5860 view? . setBackColorAble ( color: " backColor " )
59- //TODO: move to Localizable
60- view? . setNavigationTitle ( title: " Home Page " )
61+ view? . setNavigationTitle ( title: LocalizableUI . homePageNavTitle. localized)
6162
6263 Task { @MainActor in
6364 await loadData ( )
6465 }
65-
66-
6766 }
6867
69-
7068
7169 @MainActor
7270 func loadData( ) async {
73- // Sending 'self' risks causing data races
74- // Sending main actor-isolated 'self' into async let risks causing data races between nonisolated and main actor-isolated uses
75-
76- /*
77- async let popular = interactor.loadPopularMovies()
78- async let movies = interactor.loadAiringMovies()
79- await popular
80- await movies
81- */
82-
83-
84- await interactor. loadPopularMovies ( )
85- await interactor. loadAiringMovies ( )
71+ view? . startLoading ( )
72+ await interactor. loadData ( )
73+ view? . finishLoading ( )
8674 }
8775
8876}
@@ -142,33 +130,28 @@ extension HomePresenter {
142130 }
143131 }
144132
145-
146- func titleForSection( at section: Int ) -> (
147- title: String ,
148- sizeType: SectionSizeType ,
149- buttonType: [ TitleForSectionButtonType ] ?
150- ) {
133+ func titleForSection( at section: Int ) -> GenericCollectionViewKit . HeaderViewItem {
134+ var headerViewItem : HeaderViewItem
151135 guard let sectionType = SectionType ( rawValue: section) else {
152- return ( title: " " , sizeType: . small, buttonType: [ ] )
136+ headerViewItem = . init( title: " " , sizeType: . empty)
137+ return headerViewItem
153138 }
154139
155- var item : ( title: String , sizeType: SectionSizeType , buttonType: [ TitleForSectionButtonType ] ? )
156-
157140 switch sectionType {
158141 case . popular:
159- item = (
142+ headerViewItem = . init (
160143 title: LocalizableUI . popular. localized,
144+ icon: . init( image: . systemImage( " flame.fill " ) , tintColor: . custom( hex: " #FF0000 " ) ) ,
161145 sizeType: . large,
162- buttonType: [ . allList]
163- )
146+ buttonTypes: [ . allList] )
164147 case . airingToday:
165- item = (
148+ headerViewItem = . init (
166149 title: LocalizableUI . airingToday. localized,
167- sizeType : . small ,
168- buttonType : [ . allList ]
169- )
150+ icon : . init ( image : . systemImage ( " circle.fill " ) , tintColor : . custom ( hex : " #008000 " ) ) ,
151+ sizeType : . large ,
152+ buttonTypes : [ . allList ] )
170153 }
171- return item
154+ return headerViewItem
172155 }
173156
174157
@@ -210,32 +193,32 @@ extension HomePresenter {
210193
211194// MARK: - InteractorToPresenterHomeProtocol
212195/// Receives data from the Interactor and updates the view.
213- extension HomePresenter : InteractorToPresenterHomeProtocol {
196+ extension HomePresenter : InteractorToPresenterHomeProtocol {
197+ func sendError( ) {
198+
199+ view? . sendError ( errorState: ( isHidden: true ,
200+ message: LocalizableUI . somethingWentWrong. localized) )
201+ view? . relaodCollectionView ( )
202+
203+ }
204+
214205
215206 func sendAiringTvShows( _ data: [ AiringToday ] ) {
216- view ? . startLoading ( )
207+
217208 airingTodayShows = data. map { AiringTodayPresentation ( tvShow: $0) }
218209 view? . sendError ( errorState: ( isHidden: false , message: " " ) )
219210 view? . relaodCollectionView ( )
220- view ? . finishLoading ( )
211+
221212 }
222213
223214 func sendPopularTvShows( _ data: [ PopularTvShows ] ) {
224- view ? . startLoading ( )
215+
225216 popularTvShows = data
226217 . map { PopularTVShowPresentation ( tvShow: $0) }
227218 . sorted { $0. rating > $1. rating }
228219 view? . sendError ( errorState: ( isHidden: false , message: " " ) )
229220 view? . relaodCollectionView ( )
230- view? . finishLoading ( )
231- }
232-
233- func sendError( _ type: HomePageErrorType ) {
234- view? . startLoading ( )
235- view? . sendError ( errorState: ( isHidden: true ,
236- message: LocalizableUI . somethingWentWrong. localized) )
237- view? . relaodCollectionView ( )
238- view? . finishLoading ( )
221+
239222 }
240223}
241224
0 commit comments