From e5bfcfadb4cbf10d1bb868ba12fcb178b3571d77 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Sun, 4 Dec 2022 19:11:19 +0100 Subject: [PATCH] Fix displaying subscriptions label in channel --- Model/Channel.swift | 6 +++--- Shared/Views/ChannelVideosView.swift | 30 ++++++++++++++++------------ 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Model/Channel.swift b/Model/Channel.swift index 7da66f9e..39f6d32a 100644 --- a/Model/Channel.swift +++ b/Model/Channel.swift @@ -84,8 +84,8 @@ struct Channel: Identifiable, Hashable { } var subscriptionsString: String? { - if subscriptionsCount != nil, subscriptionsCount! > 0 { - return subscriptionsCount!.formattedAsAbbreviation() + if let subscriptionsCount, subscriptionsCount > 0 { + return subscriptionsCount.formattedAsAbbreviation() } return subscriptionsText @@ -107,6 +107,6 @@ struct Channel: Identifiable, Hashable { func hasData(for contentType: ContentType) -> Bool { guard contentType != .videos, contentType != .playlists else { return true } - return tabs.contains(where: { $0.contentType == contentType }) + return tabs.contains { $0.contentType == contentType } } } diff --git a/Shared/Views/ChannelVideosView.swift b/Shared/Views/ChannelVideosView.swift index cdf44685..fd6f0c24 100644 --- a/Shared/Views/ChannelVideosView.swift +++ b/Shared/Views/ChannelVideosView.swift @@ -214,23 +214,27 @@ struct ChannelVideosView: View { } var subscriptionsLabel: some View { - HStack(spacing: 0) { - if let subscribers = presentedChannel?.subscriptionsString { - Text(subscribers) - } else { - Text("1234") - .redacted(reason: .placeholder) + Group { + if let subscribers = store.item?.subscriptionsString { + HStack(spacing: 0) { + Text(subscribers) + Image(systemName: "person.2.fill") + } + } else if store.item.isNil { + HStack(spacing: 0) { + Text("1234") + .redacted(reason: .placeholder) + Image(systemName: "person.2.fill") + } } - - Image(systemName: "person.2.fill") - .imageScale(.small) } + .imageScale(.small) .foregroundColor(.secondary) } var viewsLabel: some View { HStack(spacing: 0) { - if let views = presentedChannel?.totalViewsString { + if let views = store.item?.totalViewsString { Text(views) Image(systemName: "eye.fill") @@ -259,7 +263,7 @@ struct ChannelVideosView: View { .font(.headline) .foregroundColor(.primary) .layoutPriority(1) - .frame(minWidth: 120, alignment: .leading) + .frame(minWidth: 160, alignment: .leading) Group { HStack(spacing: 12) { @@ -271,7 +275,7 @@ struct ChannelVideosView: View { viewsLabel } - .frame(minWidth: 120, alignment: .leading) + .frame(minWidth: 160, alignment: .leading) } .font(.caption2.bold()) .foregroundColor(.secondary) @@ -281,7 +285,7 @@ struct ChannelVideosView: View { .foregroundColor(.accentColor) .imageScale(.small) } - .frame(maxWidth: 300) + .frame(maxWidth: 320) } } #endif