2021-06-28 20:57:53 +05:30
|
|
|
import Defaults
|
2021-06-24 03:49:58 +05:30
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct VideosCellsView: View {
|
2021-06-28 20:57:53 +05:30
|
|
|
@Default(.tabSelection) var tabSelection
|
|
|
|
|
2021-06-24 03:49:58 +05:30
|
|
|
@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 15:09:35 +05:30
|
|
|
ScrollView(.vertical, showsIndicators: false) {
|
2021-07-09 20:54:13 +05:30
|
|
|
LazyVGrid(columns: items, alignment: .center, spacing: 10) {
|
2021-06-24 03:49:58 +05:30
|
|
|
ForEach(videos) { video in
|
|
|
|
VideoCellView(video: video)
|
2021-06-28 20:57:53 +05:30
|
|
|
.contextMenu { VideoContextMenuView(video: video) }
|
2021-06-24 03:49:58 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
.padding()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var items: [GridItem] {
|
2021-07-09 20:54:13 +05:30
|
|
|
Array(repeating: .init(.fixed(600)), count: gridColumns)
|
|
|
|
}
|
|
|
|
|
|
|
|
var gridColumns: Int {
|
|
|
|
videos.count < columns ? videos.count : columns
|
2021-06-24 03:49:58 +05:30
|
|
|
}
|
|
|
|
}
|