feat(content): 콘텐츠 탭 당겨서 새로고침을 추가한다
This commit is contained in:
@@ -70,11 +70,9 @@ struct MainContentAllView: View {
|
||||
sortBar
|
||||
|
||||
if viewModel.isLoading && viewModel.hasLoaded == false {
|
||||
ProgressView()
|
||||
.progressViewStyle(CircularProgressViewStyle(tint: .white))
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
loadingContent
|
||||
} else if viewModel.shouldShowEmptyState {
|
||||
MainContentAudioEmptyStateView(message: I18n.MainContentAll.emptyStateMessage)
|
||||
emptyContent
|
||||
} else {
|
||||
ScrollView(showsIndicators: false) {
|
||||
gridContent
|
||||
@@ -88,6 +86,35 @@ struct MainContentAllView: View {
|
||||
.padding(.vertical, SodaSpacing.s20)
|
||||
}
|
||||
}
|
||||
.refreshable {
|
||||
await viewModel.refresh()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var loadingContent: some View {
|
||||
GeometryReader { geometry in
|
||||
ScrollView(showsIndicators: false) {
|
||||
ProgressView()
|
||||
.progressViewStyle(CircularProgressViewStyle(tint: .white))
|
||||
.frame(maxWidth: .infinity)
|
||||
.frame(minHeight: geometry.size.height)
|
||||
}
|
||||
.refreshable {
|
||||
await viewModel.refresh()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var emptyContent: some View {
|
||||
GeometryReader { geometry in
|
||||
ScrollView(showsIndicators: false) {
|
||||
MainContentAudioEmptyStateView(message: I18n.MainContentAll.emptyStateMessage)
|
||||
.frame(minHeight: geometry.size.height)
|
||||
}
|
||||
.refreshable {
|
||||
await viewModel.refresh()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -197,4 +224,3 @@ struct MainContentAllView_Previews: PreviewProvider {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ final class MainContentAllViewModel: ObservableObject {
|
||||
}
|
||||
|
||||
func fetchFirstPageIfNeeded() {
|
||||
guard hasLoaded == false else { return }
|
||||
guard hasLoaded == false, isLoading == false else { return }
|
||||
fetchFirstPage()
|
||||
}
|
||||
|
||||
@@ -40,6 +40,16 @@ final class MainContentAllViewModel: ObservableObject {
|
||||
fetchContents(page: 0, isNextPage: false)
|
||||
}
|
||||
|
||||
func refresh() async {
|
||||
if !isLoading {
|
||||
fetchFirstPage()
|
||||
}
|
||||
|
||||
for await isLoading in $isLoading.values {
|
||||
if !isLoading { return }
|
||||
}
|
||||
}
|
||||
|
||||
func apply(type: MainContentAllType, sort: ContentSort) {
|
||||
guard allowedSorts(for: type).contains(sort) else { return }
|
||||
|
||||
@@ -247,4 +257,3 @@ extension SeriesPublishedDaysOfWeek {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user