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.
This commit is contained in:
Toni Förster
2024-05-18 00:36:40 +02:00
parent 1fe8a32fb8
commit 38c4ddbe43
4 changed files with 30 additions and 24 deletions

View File

@@ -2,7 +2,7 @@ import SwiftUI
struct ListView: View {
var items: [ContentItem]
var limit: Int? = 10
var limit: Int?
var body: some View {
LazyVStack(alignment: .leading) {
@@ -16,16 +16,12 @@ struct ListView: View {
}
var limitedItems: [ContentItem] {
if let limit, limit >= 0 {
return Array(items.prefix(limit))
}
return items
Array(items.prefix(limit ?? items.count))
}
}
struct ListView_Previews: PreviewProvider {
static var previews: some View {
ListView(items: [.init(video: .fixture)])
ListView(items: [.init(video: .fixture)], limit: 10)
}
}