2023-05-25 12:28:29 +00:00
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct ListView: View {
|
|
|
|
var items: [ContentItem]
|
2024-05-17 22:36:40 +00:00
|
|
|
var limit: Int?
|
2023-05-25 12:28:29 +00:00
|
|
|
|
|
|
|
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] {
|
2024-05-17 22:36:40 +00:00
|
|
|
Array(items.prefix(limit ?? items.count))
|
2023-05-25 12:28:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ListView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
2024-05-17 22:36:40 +00:00
|
|
|
ListView(items: [.init(video: .fixture)], limit: 10)
|
2023-05-25 12:28:29 +00:00
|
|
|
}
|
|
|
|
}
|