mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-26 10:11:00 +00:00
Timeline: Dequeue one
This commit is contained in:
parent
511717e492
commit
88b56fe016
2 changed files with 32 additions and 9 deletions
|
@ -109,17 +109,31 @@ public struct TimelineView: View {
|
|||
@ViewBuilder
|
||||
private func makePendingNewPostsView(proxy: ScrollViewProxy) -> some View {
|
||||
if !viewModel.pendingStatuses.isEmpty {
|
||||
Button {
|
||||
withAnimation {
|
||||
proxy.scrollTo(Constants.scrollToTop)
|
||||
viewModel.displayPendingStatuses()
|
||||
HStack(spacing: 6) {
|
||||
Button {
|
||||
withAnimation {
|
||||
proxy.scrollTo(Constants.scrollToTop)
|
||||
viewModel.displayPendingStatuses()
|
||||
}
|
||||
} label: {
|
||||
Text(viewModel.pendingStatusesButtonTitle)
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
.background(.thinMaterial)
|
||||
.cornerRadius(8)
|
||||
if viewModel.pendingStatuses.count > 1 {
|
||||
Button {
|
||||
withAnimation {
|
||||
viewModel.dequeuePendingStatuses()
|
||||
}
|
||||
} label: {
|
||||
Image(systemName: "play.square.stack")
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
.background(.thinMaterial)
|
||||
.cornerRadius(8)
|
||||
}
|
||||
} label: {
|
||||
Text(viewModel.pendingStatusesButtonTitle)
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
.background(.thinMaterial)
|
||||
.cornerRadius(8)
|
||||
.padding(.top, 6)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -179,4 +179,13 @@ class TimelineViewModel: ObservableObject, StatusesFetcher {
|
|||
pendingStatuses = []
|
||||
statusesState = .display(statuses: statuses, nextPageState: .hasNextPage)
|
||||
}
|
||||
|
||||
func dequeuePendingStatuses() {
|
||||
guard timeline == .home else { return }
|
||||
if pendingStatuses.count > 1 {
|
||||
let status = pendingStatuses.removeLast()
|
||||
statuses.insert(status, at: 0)
|
||||
}
|
||||
statusesState = .display(statuses: statuses, nextPageState: .hasNextPage)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue