mirror of
https://github.com/yattee/yattee.git
synced 2025-08-06 10:44:06 +00:00
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:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user