Fix flicker in feed

This commit is contained in:
Arkadiusz Fal 2022-12-13 20:15:00 +01:00
parent e390bbcf09
commit 0517b4feea

View File

@ -17,41 +17,7 @@ struct FeedView: View {
}
var body: some View {
VerticalCells(items: videos) {
HStack {
#if os(tvOS)
SubscriptionsPageButton()
ListingStyleButtons(listingStyle: $subscriptionsListingStyle)
#endif
if showCacheStatus {
Spacer()
CacheStatusHeader(
refreshTime: feed.formattedFeedTime,
isLoading: feed.isLoading
)
}
#if os(tvOS)
if !showCacheStatus {
Spacer()
}
Button {
feed.loadResources(force: true)
} label: {
Label("Refresh", systemImage: "arrow.clockwise")
.labelStyle(.iconOnly)
.imageScale(.small)
.font(.caption2)
}
#endif
}
.padding(.leading, 30)
#if os(tvOS)
.padding(.bottom, 15)
#endif
}
VerticalCells(items: videos) { if shouldDisplayHeader { header } }
.environment(\.loadMoreContentHandler) { feed.loadNextPage() }
.onAppear {
feed.loadResources()
@ -86,6 +52,50 @@ struct FeedView: View {
}
#endif
}
var header: some View {
HStack {
#if os(tvOS)
SubscriptionsPageButton()
ListingStyleButtons(listingStyle: $subscriptionsListingStyle)
#endif
if showCacheStatus {
Spacer()
CacheStatusHeader(
refreshTime: feed.formattedFeedTime,
isLoading: feed.isLoading
)
}
#if os(tvOS)
if !showCacheStatus {
Spacer()
}
Button {
feed.loadResources(force: true)
} label: {
Label("Refresh", systemImage: "arrow.clockwise")
.labelStyle(.iconOnly)
.imageScale(.small)
.font(.caption2)
}
#endif
}
.padding(.leading, 30)
#if os(tvOS)
.padding(.bottom, 15)
#endif
}
var shouldDisplayHeader: Bool {
#if os(tvOS)
true
#else
showCacheStatus
#endif
}
}
struct SubscriptonsView_Previews: PreviewProvider {