Show channel avatars in sidebar

This commit is contained in:
Arkadiusz Fal 2022-12-11 18:11:56 +01:00
parent bc42a2fa88
commit 38593ed488
2 changed files with 18 additions and 2 deletions

View File

@ -11,7 +11,16 @@ struct AppSidebarSubscriptions: View {
NavigationLink(tag: TabSelection.channel(channel.id), selection: $navigation.tabSelection) { NavigationLink(tag: TabSelection.channel(channel.id), selection: $navigation.tabSelection) {
LazyView(ChannelVideosView(channel: channel).modifier(PlayerOverlayModifier())) LazyView(ChannelVideosView(channel: channel).modifier(PlayerOverlayModifier()))
} label: { } label: {
Label(channel.name, systemImage: RecentsModel.symbolSystemImage(channel.name)) if channel.thumbnailURL != nil {
HStack {
ChannelAvatarView(channel: channel, subscribedBadge: false)
.frame(width: 20, height: 20)
Text(channel.name)
}
} else {
Label(channel.name, systemImage: RecentsModel.symbolSystemImage(channel.name))
}
} }
.contextMenu { .contextMenu {
Button("Unsubscribe") { Button("Unsubscribe") {

View File

@ -4,6 +4,8 @@ struct ChannelAvatarView: View {
var channel: Channel? var channel: Channel?
var video: Video? var video: Video?
var subscribedBadge = true
@ObservedObject private var accounts = AccountsModel.shared @ObservedObject private var accounts = AccountsModel.shared
@ObservedObject private var subscribedChannels = SubscribedChannelsModel.shared @ObservedObject private var subscribedChannels = SubscribedChannelsModel.shared
@ -33,13 +35,18 @@ struct ChannelAvatarView: View {
} }
.clipShape(Circle()) .clipShape(Circle())
if accounts.app.supportsSubscriptions, if subscribedBadge,
accounts.app.supportsSubscriptions,
accounts.signedIn, accounts.signedIn,
let channel, let channel,
subscribedChannels.isSubscribing(channel.id) subscribedChannels.isSubscribing(channel.id)
{ {
Image(systemName: "star.circle.fill") Image(systemName: "star.circle.fill")
#if os(tvOS)
.background(Color.black) .background(Color.black)
#else
.background(Color.background)
#endif
.clipShape(Circle()) .clipShape(Circle())
.foregroundColor(.secondary) .foregroundColor(.secondary)
} }