2021-10-23 04:34:03 +05:30
|
|
|
import SDWebImageSwiftUI
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct ChannelPlaylistCell: View {
|
|
|
|
let playlist: ChannelPlaylist
|
|
|
|
|
|
|
|
@Environment(\.navigationStyle) private var navigationStyle
|
|
|
|
|
|
|
|
var body: some View {
|
2023-05-23 02:37:14 +05:30
|
|
|
#if os(tvOS)
|
|
|
|
button
|
|
|
|
#else
|
|
|
|
if navigationStyle == .tab {
|
|
|
|
navigationLink
|
|
|
|
} else {
|
|
|
|
button
|
2022-12-11 17:08:57 +05:30
|
|
|
}
|
2023-05-23 02:37:14 +05:30
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
var navigationLink: some View {
|
|
|
|
NavigationLink(destination: ChannelPlaylistView(playlist: playlist)) { cell }
|
|
|
|
}
|
|
|
|
|
|
|
|
var button: some View {
|
|
|
|
Button {
|
|
|
|
NavigationModel.shared.openChannelPlaylist(playlist, navigationStyle: navigationStyle)
|
|
|
|
} label: {
|
|
|
|
cell
|
2021-10-23 04:34:03 +05:30
|
|
|
}
|
2023-05-23 02:37:14 +05:30
|
|
|
.buttonStyle(.plain)
|
2022-12-11 17:08:57 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
var cell: some View {
|
|
|
|
content
|
|
|
|
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
|
|
|
|
.contentShape(RoundedRectangle(cornerRadius: 12))
|
2021-10-23 04:34:03 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
var content: some View {
|
|
|
|
VStack {
|
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()
|
|
|
|
}
|
|
|
|
}
|