1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-15 14:50:32 +05:30
yattee/Shared/Videos/ListView.swift

28 lines
688 B
Swift
Raw Normal View History

2023-05-25 17:58:29 +05:30
import SwiftUI
struct ListView: View {
var items: [ContentItem]
var limit: Int?
2023-05-25 17:58:29 +05:30
var body: some View {
LazyVStack(alignment: .leading) {
ForEach(limitedItems) { item in
ContentItemView(item: item)
.environment(\.listingStyle, .list)
.environment(\.noListingDividers, limit == 1)
.transition(.opacity)
}
}
}
var limitedItems: [ContentItem] {
Array(items.prefix(limit ?? items.count))
2023-05-25 17:58:29 +05:30
}
}
struct ListView_Previews: PreviewProvider {
static var previews: some View {
ListView(items: [.init(video: .fixture)], limit: 10)
2023-05-25 17:58:29 +05:30
}
}