Fix placeholders

This commit is contained in:
Arkadiusz Fal 2022-12-14 17:20:24 +01:00
parent 2028446d03
commit 71c666ebfe
6 changed files with 15 additions and 14 deletions

View File

@ -20,6 +20,10 @@ struct ContentItem: Identifiable {
}
}
static var placeholders: [Self] {
(0 ..< 9).map { i in .init(id: String(i)) }
}
var video: Video!
var playlist: ChannelPlaylist!
var channel: Channel!

View File

@ -37,11 +37,7 @@ struct HorizontalCells: View {
}
var contentItems: [ContentItem] {
items.isEmpty ? placeholders : items
}
var placeholders: [ContentItem] {
(0 ..< 9).map { _ in .init() }
items.isEmpty ? ContentItem.placeholders : items
}
func loadMoreContentItemsIfNeeded(current item: ContentItem) {

View File

@ -48,11 +48,7 @@ struct VerticalCells<Header: View>: View {
}
var contentItems: [ContentItem] {
items.isEmpty ? (allowEmpty ? items : placeholders) : items.sorted { $0 < $1 }
}
var placeholders: [ContentItem] {
(0 ..< 9).map { _ in .init() }
items.isEmpty ? (allowEmpty ? items : ContentItem.placeholders) : items.sorted { $0 < $1 }
}
func loadMoreContentItemsIfNeeded(current item: ContentItem) {

View File

@ -80,7 +80,7 @@ struct VideoBanner: View {
if !inChannelView, !video.isLocal || video.localStreamIsRemoteURL {
ChannelLinkView(channel: video.channel) {
HStack(spacing: Constants.channelDetailsStackSpacing) {
if let url = video.channel.thumbnailURLOrCached {
if let url = video.channel.thumbnailURLOrCached, video != .fixture {
ThumbnailView(url: url)
.frame(width: Constants.channelThumbnailSize, height: Constants.channelThumbnailSize)
.clipShape(Circle())

View File

@ -169,7 +169,8 @@ struct VideoCell: View {
HStack(spacing: Constants.channelDetailsStackSpacing) {
if !inChannelView,
let video,
let url = video.channel.thumbnailURLOrCached
let url = video.channel.thumbnailURLOrCached,
video != .fixture
{
ChannelLinkView(channel: video.channel) {
ThumbnailView(url: url)
@ -271,7 +272,9 @@ struct VideoCell: View {
if !channelOnThumbnail, !inChannelView {
ChannelLinkView(channel: video.channel) {
HStack(spacing: Constants.channelDetailsStackSpacing) {
if let url = video.channel.thumbnailURLOrCached {
if let url = video.channel.thumbnailURLOrCached,
video != .fixture
{
ThumbnailView(url: url)
.frame(width: Constants.channelThumbnailSize, height: Constants.channelThumbnailSize)
.clipShape(Circle())
@ -297,7 +300,8 @@ struct VideoCell: View {
if channelOnThumbnail,
!inChannelView,
let video,
let url = video.channel.thumbnailURLOrCached
let url = video.channel.thumbnailURLOrCached,
video != .fixture
{
ChannelLinkView(channel: video.channel) {
ThumbnailView(url: url)

View File

@ -71,6 +71,7 @@ struct ContentItemView: View {
@ViewBuilder func placeholderItem() -> some View {
if listingStyle == .cells {
PlaceholderCell()
.id(item.id)
} else {
PlaceholderListItem()
#if os(tvOS)