1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-14 14:20:32 +05:30
yattee/Shared/Views/ChannelPlaylistCell.swift

60 lines
1.8 KiB
Swift
Raw Normal View History

2021-10-23 04:34:03 +05:30
import SDWebImageSwiftUI
import SwiftUI
struct ChannelPlaylistCell: View {
let playlist: ChannelPlaylist
@Environment(\.navigationStyle) private var navigationStyle
var navigation = NavigationModel.shared
2021-10-23 04:34:03 +05:30
var body: some View {
Button {
2022-11-27 16:12:16 +05:30
NavigationModel.shared.openChannelPlaylist(playlist, navigationStyle: navigationStyle)
2021-10-23 04:34:03 +05:30
} label: {
content
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
.contentShape(RoundedRectangle(cornerRadius: 12))
}
.buttonStyle(.plain)
}
var content: some View {
VStack {
HStack(alignment: .top, spacing: 3) {
Image(systemName: "list.and.film")
2022-12-04 18:13:09 +05:30
Text("Playlist".localized().uppercased())
2021-10-23 04:34:03 +05:30
.fontWeight(.light)
.opacity(0.6)
}
.foregroundColor(.secondary)
2022-11-10 23:41:19 +05:30
WebImage(url: playlist.thumbnailURL, options: [.lowPriority])
2022-09-12 01:03:08 +05:30
.resizable()
.placeholder {
Rectangle().fill(Color("PlaceholderColor"))
2021-10-23 04:34:03 +05:30
}
2022-09-12 01:03:08 +05:30
.indicator(.activity)
.frame(width: 165, height: 88)
.clipShape(RoundedRectangle(cornerRadius: 10))
2021-10-23 04:34:03 +05:30
Group {
DetailBadge(text: playlist.title, style: .prominent)
.lineLimit(2)
Text("\(playlist.videosCount ?? playlist.videos.count) videos")
.foregroundColor(.secondary)
.frame(height: 20)
}
}
}
}
struct ChannelPlaylistCell_Previews: PreviewProvider {
static var previews: some View {
ChannelPlaylistCell(playlist: ChannelPlaylist.fixture)
.frame(maxWidth: 320)
.injectFixtureEnvironmentObjects()
}
}