mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-26 18:21: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
|
@ViewBuilder
|
||||||
private func makePendingNewPostsView(proxy: ScrollViewProxy) -> some View {
|
private func makePendingNewPostsView(proxy: ScrollViewProxy) -> some View {
|
||||||
if !viewModel.pendingStatuses.isEmpty {
|
if !viewModel.pendingStatuses.isEmpty {
|
||||||
Button {
|
HStack(spacing: 6) {
|
||||||
withAnimation {
|
Button {
|
||||||
proxy.scrollTo(Constants.scrollToTop)
|
withAnimation {
|
||||||
viewModel.displayPendingStatuses()
|
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)
|
.padding(.top, 6)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,4 +179,13 @@ class TimelineViewModel: ObservableObject, StatusesFetcher {
|
||||||
pendingStatuses = []
|
pendingStatuses = []
|
||||||
statusesState = .display(statuses: statuses, nextPageState: .hasNextPage)
|
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