2021-06-28 15:27:53 +00:00
|
|
|
import Defaults
|
2021-06-23 22:19:58 +00:00
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct VideosCellsView: View {
|
|
|
|
@State private var columns: Int
|
|
|
|
|
|
|
|
init(videos: [Video], columns: Int = 3) {
|
|
|
|
self.videos = videos
|
|
|
|
self.columns = columns
|
|
|
|
}
|
|
|
|
|
|
|
|
var videos = [Video]()
|
|
|
|
|
|
|
|
var body: some View {
|
2021-06-26 09:39:35 +00:00
|
|
|
ScrollView(.vertical, showsIndicators: false) {
|
2021-07-11 20:52:49 +00:00
|
|
|
LazyVGrid(columns: items, alignment: .center) {
|
2021-06-23 22:19:58 +00:00
|
|
|
ForEach(videos) { video in
|
2021-07-27 22:40:04 +00:00
|
|
|
VideoView(video: video)
|
2021-06-28 15:27:53 +00:00
|
|
|
.contextMenu { VideoContextMenuView(video: video) }
|
2021-06-23 22:19:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
.padding()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var items: [GridItem] {
|
2021-07-09 15:24:13 +00:00
|
|
|
Array(repeating: .init(.fixed(600)), count: gridColumns)
|
|
|
|
}
|
2021-07-11 20:52:49 +00:00
|
|
|
|
2021-07-09 15:24:13 +00:00
|
|
|
var gridColumns: Int {
|
|
|
|
videos.count < columns ? videos.count : columns
|
2021-06-23 22:19:58 +00:00
|
|
|
}
|
|
|
|
}
|