mirror of
https://github.com/yattee/yattee.git
synced 2025-08-06 10:44:06 +00:00
Home Settings
This commit is contained in:
32
Shared/Videos/ListView.swift
Normal file
32
Shared/Videos/ListView.swift
Normal file
@@ -0,0 +1,32 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ListView: View {
|
||||
var items: [ContentItem]
|
||||
var limit: Int? = 10
|
||||
|
||||
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] {
|
||||
if let limit, limit >= 0 {
|
||||
return Array(items.prefix(limit))
|
||||
}
|
||||
|
||||
return items
|
||||
}
|
||||
}
|
||||
|
||||
struct ListView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
ListView(items: [.init(video: .fixture)])
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user