1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-15 23:00:32 +05:30
yattee/Apple TV/VideosCellsView.swift

36 lines
876 B
Swift
Raw Normal View History

import Defaults
2021-06-24 03:49:58 +05:30
import SwiftUI
struct VideosCellsView: View {
@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)
.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
}
}