tvOS filters for all views

Vertical list for trending, popular, playlists, search

Fix #413, #415
This commit is contained in:
Arkadiusz Fal
2023-04-22 21:07:30 +02:00
parent 6596a440a5
commit 83dfdd6c0e
11 changed files with 175 additions and 142 deletions

View File

@@ -17,7 +17,7 @@ struct HideShortsButtons: View {
}
}
#if os(tvOS)
.font(.caption2)
.font(.caption)
.imageScale(.small)
#endif
}

View File

@@ -12,7 +12,7 @@ struct ListingStyleButtons: View {
} label: {
Label(listingStyle.rawValue.capitalized, systemImage: listingStyle.systemImage)
#if os(tvOS)
.font(.caption2)
.font(.caption)
.imageScale(.small)
#endif
}

View File

@@ -21,7 +21,7 @@ struct PopularView: View {
}
var body: some View {
VerticalCells(items: videos)
VerticalCells(items: videos) { if shouldDisplayHeader { header } }
.onAppear {
resource?.addObserver(store)
resource?.loadIfNeeded()?
@@ -116,6 +116,36 @@ struct PopularView: View {
}
}
#endif
var shouldDisplayHeader: Bool {
#if os(tvOS)
true
#else
false
#endif
}
var header: some View {
HStack {
Spacer()
ListingStyleButtons(listingStyle: $popularListingStyle)
HideShortsButtons(hide: $hideShorts)
Button {
resource?.load()
.onFailure { self.error = $0 }
.onSuccess { _ in self.error = nil }
} label: {
Label("Refresh", systemImage: "arrow.clockwise")
.labelStyle(.iconOnly)
.imageScale(.small)
.font(.caption)
}
}
.padding(.leading, 30)
.padding(.bottom, 15)
.padding(.trailing, 30)
}
}
struct PopularView_Previews: PreviewProvider {