2021-06-11 04:20:10 +05:30
|
|
|
import SwiftUI
|
|
|
|
import URLImage
|
|
|
|
import URLImageStore
|
|
|
|
|
2021-06-28 20:32:13 +05:30
|
|
|
struct VideoListRowView: View {
|
2021-06-11 05:35:59 +05:30
|
|
|
@Environment(\.isFocused) private var focused: Bool
|
2021-06-11 04:20:10 +05:30
|
|
|
|
|
|
|
var video: Video
|
|
|
|
|
|
|
|
var body: some View {
|
2021-06-11 05:35:59 +05:30
|
|
|
NavigationLink(destination: PlayerView(id: video.id)) {
|
2021-06-11 04:20:10 +05:30
|
|
|
HStack(alignment: .top, spacing: 2) {
|
2021-06-12 02:41:59 +05:30
|
|
|
Section {
|
|
|
|
if let thumbnail = video.thumbnailURL {
|
|
|
|
// to replace with AsyncImage when it is fixed with lazy views
|
|
|
|
URLImage(thumbnail) { image in
|
|
|
|
image
|
|
|
|
.resizable()
|
|
|
|
.aspectRatio(contentMode: .fill)
|
|
|
|
.frame(width: 320, height: 180)
|
|
|
|
}
|
|
|
|
.mask(RoundedRectangle(cornerRadius: 12))
|
|
|
|
} else {
|
|
|
|
Image(systemName: "exclamationmark.square")
|
|
|
|
}
|
2021-06-11 04:20:10 +05:30
|
|
|
}
|
|
|
|
.frame(width: 320, height: 180)
|
|
|
|
|
2021-06-11 05:35:59 +05:30
|
|
|
HStack {
|
|
|
|
VStack(alignment: .leading) {
|
|
|
|
Text(video.title)
|
|
|
|
.foregroundColor(.primary)
|
|
|
|
.bold()
|
|
|
|
.lineLimit(1)
|
2021-06-11 04:20:10 +05:30
|
|
|
|
2021-06-11 05:35:59 +05:30
|
|
|
Text("\(video.author)")
|
|
|
|
.foregroundColor(.secondary)
|
|
|
|
.bold()
|
|
|
|
.lineLimit(1)
|
|
|
|
|
2021-06-26 15:09:35 +05:30
|
|
|
if !video.published.isEmpty || video.views != 0 {
|
|
|
|
HStack(spacing: 8) {
|
|
|
|
if !video.published.isEmpty {
|
|
|
|
Image(systemName: "calendar")
|
|
|
|
Text(video.published)
|
|
|
|
}
|
2021-06-11 05:35:59 +05:30
|
|
|
|
2021-06-26 15:09:35 +05:30
|
|
|
if video.views != 0 {
|
|
|
|
Image(systemName: "eye")
|
|
|
|
Text(video.viewsCount)
|
|
|
|
}
|
2021-06-17 01:00:50 +05:30
|
|
|
}
|
2021-06-26 15:09:35 +05:30
|
|
|
.foregroundColor(.secondary)
|
|
|
|
.padding(.top)
|
2021-06-11 05:35:59 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
.padding()
|
|
|
|
|
|
|
|
Spacer()
|
2021-06-11 04:20:10 +05:30
|
|
|
|
2021-06-11 05:35:59 +05:30
|
|
|
HStack(spacing: 8) {
|
2021-06-17 01:00:50 +05:30
|
|
|
if let time = video.playTime {
|
|
|
|
Image(systemName: "clock")
|
2021-06-11 05:35:59 +05:30
|
|
|
|
2021-06-17 01:00:50 +05:30
|
|
|
Text(time)
|
|
|
|
.fontWeight(.bold)
|
|
|
|
}
|
2021-06-11 05:35:59 +05:30
|
|
|
}
|
|
|
|
.foregroundColor(.secondary)
|
|
|
|
}
|
|
|
|
.frame(minHeight: 180)
|
2021-06-11 04:20:10 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-14 23:35:02 +05:30
|
|
|
// struct VideoThumbnailView_Previews: PreviewProvider {
|
|
|
|
// static var previews: some View {
|
|
|
|
// VideoThumbnailView(video: Video(
|
|
|
|
// id: "A",
|
|
|
|
// title: "A very very long text which",
|
|
|
|
// thumbnailURL: URL(string: "https://invidious.home.arekf.net/vi/yXohcxCKqvo/maxres.jpg")!,
|
|
|
|
// author: "Bear",
|
|
|
|
// length: 240,
|
|
|
|
// published: "2 days ago",
|
|
|
|
// channelID: ""
|
|
|
|
// )).frame(maxWidth: 350)
|
|
|
|
// }
|
|
|
|
// }
|