yattee/Apple TV/VideosCellsView.swift

34 lines
813 B
Swift
Raw Normal View History

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
VideoCellView(video: video)
.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
}
}