Fix displaying subscriptions label in channel

This commit is contained in:
Arkadiusz Fal 2022-12-04 19:11:19 +01:00
parent 6394d129de
commit e5bfcfadb4
2 changed files with 20 additions and 16 deletions

View File

@ -84,8 +84,8 @@ struct Channel: Identifiable, Hashable {
} }
var subscriptionsString: String? { var subscriptionsString: String? {
if subscriptionsCount != nil, subscriptionsCount! > 0 { if let subscriptionsCount, subscriptionsCount > 0 {
return subscriptionsCount!.formattedAsAbbreviation() return subscriptionsCount.formattedAsAbbreviation()
} }
return subscriptionsText return subscriptionsText
@ -107,6 +107,6 @@ struct Channel: Identifiable, Hashable {
func hasData(for contentType: ContentType) -> Bool { func hasData(for contentType: ContentType) -> Bool {
guard contentType != .videos, contentType != .playlists else { return true } guard contentType != .videos, contentType != .playlists else { return true }
return tabs.contains(where: { $0.contentType == contentType }) return tabs.contains { $0.contentType == contentType }
} }
} }

View File

@ -214,23 +214,27 @@ struct ChannelVideosView: View {
} }
var subscriptionsLabel: some View { var subscriptionsLabel: some View {
Group {
if let subscribers = store.item?.subscriptionsString {
HStack(spacing: 0) { HStack(spacing: 0) {
if let subscribers = presentedChannel?.subscriptionsString {
Text(subscribers) Text(subscribers)
} else { Image(systemName: "person.2.fill")
}
} else if store.item.isNil {
HStack(spacing: 0) {
Text("1234") Text("1234")
.redacted(reason: .placeholder) .redacted(reason: .placeholder)
}
Image(systemName: "person.2.fill") Image(systemName: "person.2.fill")
.imageScale(.small)
} }
}
}
.imageScale(.small)
.foregroundColor(.secondary) .foregroundColor(.secondary)
} }
var viewsLabel: some View { var viewsLabel: some View {
HStack(spacing: 0) { HStack(spacing: 0) {
if let views = presentedChannel?.totalViewsString { if let views = store.item?.totalViewsString {
Text(views) Text(views)
Image(systemName: "eye.fill") Image(systemName: "eye.fill")
@ -259,7 +263,7 @@ struct ChannelVideosView: View {
.font(.headline) .font(.headline)
.foregroundColor(.primary) .foregroundColor(.primary)
.layoutPriority(1) .layoutPriority(1)
.frame(minWidth: 120, alignment: .leading) .frame(minWidth: 160, alignment: .leading)
Group { Group {
HStack(spacing: 12) { HStack(spacing: 12) {
@ -271,7 +275,7 @@ struct ChannelVideosView: View {
viewsLabel viewsLabel
} }
.frame(minWidth: 120, alignment: .leading) .frame(minWidth: 160, alignment: .leading)
} }
.font(.caption2.bold()) .font(.caption2.bold())
.foregroundColor(.secondary) .foregroundColor(.secondary)
@ -281,7 +285,7 @@ struct ChannelVideosView: View {
.foregroundColor(.accentColor) .foregroundColor(.accentColor)
.imageScale(.small) .imageScale(.small)
} }
.frame(maxWidth: 300) .frame(maxWidth: 320)
} }
} }
#endif #endif