yattee/Apple TV/VideoCellView.swift

82 lines
3.0 KiB
Swift
Raw Normal View History

2021-06-23 22:19:58 +00:00
import URLImage
import URLImageStore
import SwiftUI
struct VideoCellView: View {
var video: Video
2021-06-28 10:43:07 +00:00
2021-06-23 22:19:58 +00:00
var body: some View {
NavigationLink(destination: PlayerView(id: video.id)) {
VStack(alignment: .leading) {
ZStack(alignment: .trailing) {
2021-07-12 17:05:16 +00:00
if let thumbnail = video.thumbnailURL(quality: .high) {
2021-06-23 22:19:58 +00:00
// to replace with AsyncImage when it is fixed with lazy views
URLImage(thumbnail) { image in
image
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: 550, height: 310)
}
.mask(RoundedRectangle(cornerRadius: 12))
} else {
Image(systemName: "exclamationmark.square")
.frame(width: 550, height: 310)
}
2021-07-11 20:52:49 +00:00
VStack(alignment: .trailing) {
Text(video.author)
2021-06-23 22:19:58 +00:00
.padding(8)
.background(.thickMaterial)
.mask(RoundedRectangle(cornerRadius: 12))
2021-07-11 20:52:49 +00:00
.offset(x: -5, y: 5)
.truncationMode(.middle)
Spacer()
if let time = video.playTime {
Text(time)
.fontWeight(.bold)
.padding(8)
.background(.thickMaterial)
.mask(RoundedRectangle(cornerRadius: 12))
.offset(x: -5, y: -5)
}
2021-06-23 22:19:58 +00:00
}
}
.frame(width: 550, height: 310)
VStack(alignment: .leading) {
Text(video.title)
.bold()
.lineLimit(2)
.multilineTextAlignment(.leading)
.padding(.horizontal)
.padding(.bottom, 2)
.frame(minHeight: 80, alignment: .top)
.truncationMode(.middle)
2021-06-26 09:39:35 +00:00
if !video.published.isEmpty || video.views != 0 {
HStack(spacing: 8) {
if !video.published.isEmpty {
Image(systemName: "calendar")
Text(video.published)
}
2021-06-23 22:19:58 +00:00
2021-06-26 09:39:35 +00:00
if video.views != 0 {
Image(systemName: "eye")
Text(video.viewsCount)
}
2021-06-23 22:19:58 +00:00
}
2021-06-26 09:39:35 +00:00
.padding([.horizontal, .bottom])
.foregroundColor(.secondary)
2021-06-23 22:19:58 +00:00
}
}
}
.frame(width: 550, alignment: .leading)
}
.buttonStyle(.plain)
.padding(.vertical)
}
}