2022-12-11 16:06:02 +00:00
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct ChannelAvatarView: View {
|
|
|
|
var channel: Channel?
|
|
|
|
var video: Video?
|
|
|
|
|
2022-12-11 17:11:56 +00:00
|
|
|
var subscribedBadge = true
|
|
|
|
|
2022-12-11 16:06:02 +00:00
|
|
|
@ObservedObject private var accounts = AccountsModel.shared
|
|
|
|
@ObservedObject private var subscribedChannels = SubscribedChannelsModel.shared
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
ZStack(alignment: .bottomTrailing) {
|
|
|
|
Group {
|
|
|
|
Group {
|
2022-12-14 17:10:50 +00:00
|
|
|
if let url = channel?.thumbnailURLOrCached {
|
2022-12-11 16:06:02 +00:00
|
|
|
ThumbnailView(url: url)
|
|
|
|
} else {
|
|
|
|
ZStack {
|
|
|
|
Color(white: 0.6)
|
|
|
|
.opacity(0.5)
|
|
|
|
|
|
|
|
Group {
|
|
|
|
if let video, video.isLocal {
|
|
|
|
Image(systemName: video.localStreamImageSystemName)
|
|
|
|
} else {
|
|
|
|
Image(systemName: "play.rectangle")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.foregroundColor(.accentColor)
|
|
|
|
.font(.system(size: 20))
|
|
|
|
.contentShape(Rectangle())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.clipShape(Circle())
|
|
|
|
|
2022-12-11 17:11:56 +00:00
|
|
|
if subscribedBadge,
|
|
|
|
accounts.app.supportsSubscriptions,
|
2022-12-11 16:06:02 +00:00
|
|
|
accounts.signedIn,
|
|
|
|
let channel,
|
|
|
|
subscribedChannels.isSubscribing(channel.id)
|
|
|
|
{
|
|
|
|
Image(systemName: "star.circle.fill")
|
2022-12-11 17:11:56 +00:00
|
|
|
#if os(tvOS)
|
2022-12-11 16:06:02 +00:00
|
|
|
.background(Color.black)
|
2022-12-11 17:11:56 +00:00
|
|
|
#else
|
|
|
|
.background(Color.background)
|
|
|
|
#endif
|
2022-12-11 16:06:02 +00:00
|
|
|
.clipShape(Circle())
|
|
|
|
.foregroundColor(.secondary)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.imageScale(.small)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ChannelAvatarView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
ChannelAvatarView(channel: Video.fixture.channel)
|
|
|
|
}
|
|
|
|
}
|