Add infinite scroll for comments

This commit is contained in:
Arkadiusz Fal
2022-01-05 17:12:32 +01:00
parent ac755d0ee6
commit 1db4a3197d
5 changed files with 84 additions and 47 deletions

View File

@@ -130,7 +130,11 @@ struct NowPlayingView: View {
}
if sections.contains(.comments) {
if !comments.loaded {
if comments.disabled {
NoCommentsView(text: "Comments are disabled", systemImage: "xmark.circle.fill")
} else if comments.loaded && comments.all.isEmpty {
NoCommentsView(text: "No comments", systemImage: "0.circle.fill")
} else if !comments.loaded {
VStack(alignment: .center) {
PlaceholderProgressView()
.onAppear {
@@ -142,6 +146,14 @@ struct NowPlayingView: View {
ForEach(comments.all) { comment in
CommentView(comment: comment, repliesID: $repliesID)
}
if comments.nextPageAvailable {
Text("Scroll to load more...")
.foregroundColor(.secondary)
.padding(.leading)
.onAppear {
comments.loadNextPage()
}
}
}
}
}