yattee/Shared/Videos/ListView.swift
Toni Förster 38c4ddbe43
HomeView: Changes to Favourites and History Widget
The History Widget in the Home View was hard-coded to 10 items. Now it uses the limit set in the settings.

The items weren't immediate updated when the limit was changed.

List Views had a hard-coded limit of 10 items. Now they use the limit supplied in the parameter.
2024-05-18 00:36:40 +02:00

28 lines
688 B
Swift

import SwiftUI
struct ListView: View {
var items: [ContentItem]
var limit: Int?
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))
}
}
struct ListView_Previews: PreviewProvider {
static var previews: some View {
ListView(items: [.init(video: .fixture)], limit: 10)
}
}