Add empty view for scrolling

This commit is contained in:
Jackson Harper 2023-12-01 14:30:16 +08:00
parent 2f4436a8cb
commit 0edced69bf
2 changed files with 4 additions and 4 deletions

View file

@ -614,6 +614,7 @@ struct AnimatingCellHeight: AnimatableModifier {
ScrollViewReader { reader in
List(selection: $selection) {
Section(content: {
EmptyView().id("TOP")
if let appliedFilter = viewModel.filterState.appliedFilter,
networkMonitor.status == .disconnected,
!appliedFilter.allowLocalFetch
@ -689,9 +690,9 @@ struct AnimatingCellHeight: AnimatableModifier {
.listRowInsets(.init(top: 0, leading: 0, bottom: 0, trailing: 0))
.coordinateSpace(name: "scroll")
.onChange(of: shouldScrollToTop) { _ in
if shouldScrollToTop, let topItem = viewModel.fetcher.items.first {
withAnimation { // add animation for scroll to top
reader.scrollTo(topItem.unwrappedID, anchor: .top) // scroll
if shouldScrollToTop {
withAnimation {
reader.scrollTo("TOP", anchor: .top)
}
}
shouldScrollToTop = false

View file

@ -33,7 +33,6 @@ struct TabBarButton: View {
.aspectRatio(contentMode: .fit)
.frame(width: 28, height: 28)
.foregroundColor(selectedTab == key ? Color.blue : Color.themeTabButtonColor)
.frame(maxWidth: .infinity)
})
}