pagination bug

This commit is contained in:
Aiden Vigue 2021-05-29 13:11:54 -04:00
parent ae9381e5a3
commit 04936e75af
No known key found for this signature in database
GPG Key ID: E7570472648F4544
2 changed files with 18 additions and 6 deletions

View File

@ -71,12 +71,13 @@ struct LibraryView: View {
Button {
viewModel.requestPreviousPage()
} label: {
Image(systemName: "chevron.left")
Image(systemName: "chevron.left").font(.system(size: 25))
}.disabled(viewModel.isHiddenPreviousButton)
Spacer()
Button {
viewModel.requestNextPage()
} label: {
Image(systemName: "chevron.right")
Image(systemName: "chevron.right").font(.system(size: 25))
}.disabled(viewModel.isHiddenNextButton)
Spacer()
}

View File

@ -121,17 +121,28 @@ final class LibraryViewModel: ObservableObject {
self.isLoading = false
}, receiveValue: { [weak self] items, count in
guard let self = self else { return }
if count > 100 {
if self.page > 1 {
print(count)
print(items.count)
print(self.page)
if(count > 100) {
self.isHiddenPreviousButton = true
self.isHiddenNextButton = true
if(self.page > 1) {
self.isHiddenPreviousButton = false
}
if count > (self.page * 100) {
if(self.page * 100 < count) {
self.isHiddenNextButton = false
}
} else {
self.isHiddenNextButton = true
self.isHiddenPreviousButton = true
self.isHiddenNextButton = true
}
print(self.isHiddenPreviousButton)
print(self.isHiddenNextButton)
self.items = items
})