1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-15 06:40:32 +05:30
yattee/Shared/Views/ChannelCell.swift

74 lines
2.1 KiB
Swift
Raw Normal View History

import Foundation
import SDWebImageSwiftUI
import SwiftUI
struct ChannelCell: View {
let channel: Channel
@Environment(\.navigationStyle) private var navigationStyle
@EnvironmentObject<NavigationModel> private var navigation
2021-12-17 22:04:55 +05:30
@EnvironmentObject<PlayerModel> private var player
@EnvironmentObject<RecentsModel> private var recents
var body: some View {
Button {
2021-12-17 22:04:55 +05:30
NavigationModel.openChannel(
channel,
player: player,
recents: recents,
2022-06-30 13:35:32 +05:30
navigation: navigation,
navigationStyle: navigationStyle
2021-12-17 22:04:55 +05:30
)
} label: {
content
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
.contentShape(RoundedRectangle(cornerRadius: 12))
}
.buttonStyle(.plain)
}
var content: some View {
VStack {
2021-10-23 04:34:03 +05:30
HStack(alignment: .top, spacing: 3) {
Image(systemName: "person.crop.rectangle")
Text("Channel".uppercased())
.fontWeight(.light)
.opacity(0.6)
}
.foregroundColor(.secondary)
WebImage(url: channel.thumbnailURL)
.resizable()
.placeholder {
Rectangle().fill(Color("PlaceholderColor"))
}
2021-10-23 17:03:40 +05:30
.indicator(.activity)
.frame(width: 88, height: 88)
.clipShape(Circle())
2021-10-23 04:34:03 +05:30
DetailBadge(text: channel.name, style: .prominent)
2021-10-23 04:34:03 +05:30
Group {
if let subscriptions = channel.subscriptionsString {
Text("\(subscriptions) subscribers")
.foregroundColor(.secondary)
} else {
Text("")
}
}
2021-10-23 04:34:03 +05:30
.frame(height: 20)
}
}
}
struct ChannelSearchItem_Preview: PreviewProvider {
static var previews: some View {
Group {
ChannelCell(channel: Video.fixture.channel)
}
.frame(maxWidth: 300, maxHeight: 200)
.injectFixtureEnvironmentObjects()
}
}