88 lines
3.7 KiB
Swift
88 lines
3.7 KiB
Swift
import SwiftUI
|
|
|
|
struct MainContentRecommendationView: View {
|
|
let onTapContent: (Int) -> Void
|
|
let onTapBanner: (AudioBannerResponse) -> Void
|
|
let onTapSeries: (Int) -> Void
|
|
|
|
@StateObject private var viewModel = MainContentRecommendationViewModel()
|
|
|
|
var body: some View {
|
|
ZStack {
|
|
Color.black
|
|
.ignoresSafeArea()
|
|
|
|
if viewModel.isLoading && viewModel.recommendations == nil {
|
|
ProgressView()
|
|
.progressViewStyle(CircularProgressViewStyle(tint: .white))
|
|
} else if viewModel.shouldShowEmptyState {
|
|
MainContentAudioEmptyStateView(message: viewModel.emptyStateMessage)
|
|
} else {
|
|
ScrollView(showsIndicators: false) {
|
|
VStack(alignment: .leading, spacing: SodaSpacing.s24) {
|
|
if let recommendations = viewModel.recommendations {
|
|
MainContentAudioBannerSection(
|
|
items: recommendations.banners,
|
|
onTapBanner: onTapBanner
|
|
)
|
|
|
|
MainContentAudioHorizontalCardSection(
|
|
title: I18n.MainContentRecommendation.latestAudioSectionTitle,
|
|
items: recommendations.latestAudios,
|
|
onTapContent: onTapContent
|
|
)
|
|
|
|
MainContentAudioListCarouselSection(
|
|
title: I18n.MainContentRecommendation.newAndHotSectionTitle,
|
|
items: recommendations.newAndHotAudios,
|
|
onTapContent: onTapContent
|
|
)
|
|
|
|
MainContentVoiceOnOnlySection(
|
|
title: I18n.MainContentRecommendation.voiceOnOnlySectionTitle,
|
|
items: recommendations.originalSeries,
|
|
onTapSeries: onTapSeries
|
|
)
|
|
|
|
MainContentAudioHorizontalCardSection(
|
|
title: I18n.MainContentRecommendation.freeAudioSectionTitle,
|
|
items: recommendations.freeAudios,
|
|
onTapContent: onTapContent
|
|
)
|
|
|
|
MainContentAudioHorizontalCardSection(
|
|
title: I18n.MainContentRecommendation.pointAudioSectionTitle,
|
|
items: recommendations.pointAudios,
|
|
onTapContent: onTapContent
|
|
)
|
|
|
|
MainContentMostCommentedAudioSection(
|
|
title: I18n.MainContentRecommendation.mostCommentedAudioSectionTitle,
|
|
items: recommendations.mostCommentedAudios,
|
|
onTapContent: onTapContent
|
|
)
|
|
|
|
MainContentRecommendedAudioGridSection(
|
|
title: I18n.MainContentRecommendation.recommendedAudioSectionTitle,
|
|
items: recommendations.recommendedAudios,
|
|
onTapContent: onTapContent
|
|
)
|
|
}
|
|
}
|
|
.padding(.vertical, SodaSpacing.s20)
|
|
}
|
|
}
|
|
}
|
|
.onAppear {
|
|
if !viewModel.hasLoaded {
|
|
viewModel.fetchRecommendations()
|
|
}
|
|
}
|
|
.sodaToast(
|
|
isPresented: $viewModel.isShowPopup,
|
|
message: viewModel.errorMessage,
|
|
autohideIn: 2
|
|
)
|
|
}
|
|
}
|