mirror of
https://github.com/yattee/yattee.git
synced 2024-11-09 15:58:20 +00:00
38c4ddbe43
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.
28 lines
688 B
Swift
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)
|
|
}
|
|
}
|