feat(recommendation): 추천 서브 배너와 연속 순환을 추가한다
This commit is contained in:
@@ -44,6 +44,10 @@ struct MainHomeRecommendationView: View {
|
||||
onTapCommunityPost: onTapCommunityPost
|
||||
)
|
||||
|
||||
if let items = viewModel.recommendations?.eligibleSubBanners, !items.isEmpty {
|
||||
SubBannerCarousel(items: items) { SubBannerLinkOpener.open($0) }
|
||||
}
|
||||
|
||||
MainHomeRecentDebutCreatorSection(
|
||||
items: viewModel.recommendations?.recentDebutCreators ?? [],
|
||||
onTapCreator: onTapCreator
|
||||
|
||||
@@ -33,6 +33,13 @@ final class MainHomeRecommendationViewModel: ObservableObject {
|
||||
} receiveValue: { [weak self] response in
|
||||
guard let self else { return }
|
||||
|
||||
guard response.statusCode == 200 else {
|
||||
self.errorMessage = I18n.Common.commonError
|
||||
self.isShowPopup = true
|
||||
self.isLoading = false
|
||||
return
|
||||
}
|
||||
|
||||
let responseData = response.data
|
||||
|
||||
do {
|
||||
|
||||
+5
@@ -3,12 +3,17 @@ import Foundation
|
||||
struct HomeRecommendationResponse: Decodable {
|
||||
let lives: [HomeLiveItem]
|
||||
let banners: [RecommendationBannerResponse]
|
||||
let subBanners: [SubBanner]
|
||||
let recentlyActiveCreators: [HomeActiveCreatorItem]
|
||||
let recentDebutCreators: [HomeCreatorItem]
|
||||
let aiCharacters: [HomeAiCharacterItem]
|
||||
let genreCreators: [HomeGenreCreatorGroupItem]
|
||||
let cheerCreators: [HomeCreatorItem]
|
||||
let popularCommunityPosts: [HomePopularCommunityPostItem]
|
||||
|
||||
var eligibleSubBanners: [SubBanner] {
|
||||
subBanners.filter { $0.placement == .homeRecommendation && $0.isEligible }
|
||||
}
|
||||
}
|
||||
|
||||
struct HomeLiveItem: Decodable, Hashable {
|
||||
|
||||
+6
-1
@@ -42,6 +42,11 @@ extension MainHomeRecommendationApi: TargetType {
|
||||
}
|
||||
|
||||
var headers: [String: String]? {
|
||||
return ["Authorization": "Bearer \(UserDefaults.string(forKey: UserDefaultsKey.token))"]
|
||||
let token = UserDefaults.string(forKey: .token)
|
||||
if case .getRecommendations = self,
|
||||
token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
||||
return nil
|
||||
}
|
||||
return ["Authorization": "Bearer \(token)"]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user