mirror of
https://github.com/yattee/yattee.git
synced 2025-08-05 02:04:07 +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)])
|
||||
}
|
||||
}
|
@@ -6,7 +6,6 @@ struct VerticalCells<Header: View>: View {
|
||||
@Environment(\.verticalSizeClass) private var verticalSizeClass
|
||||
#endif
|
||||
|
||||
@Environment(\.scrollViewBottomPadding) private var scrollViewBottomPadding
|
||||
@Environment(\.loadMoreContentHandler) private var loadMoreContentHandler
|
||||
@Environment(\.listingStyle) private var listingStyle
|
||||
|
||||
@@ -15,14 +14,25 @@ struct VerticalCells<Header: View>: View {
|
||||
var edgesIgnoringSafeArea = Edge.Set.horizontal
|
||||
|
||||
let header: Header?
|
||||
init(items: [ContentItem], allowEmpty: Bool = false, edgesIgnoringSafeArea: Edge.Set = .horizontal, @ViewBuilder header: @escaping () -> Header? = { nil }) {
|
||||
|
||||
@State private var gridSize = CGSize.zero
|
||||
|
||||
init(
|
||||
items: [ContentItem],
|
||||
allowEmpty: Bool = false,
|
||||
edgesIgnoringSafeArea: Edge.Set = .horizontal,
|
||||
@ViewBuilder header: @escaping () -> Header? = { nil }
|
||||
) {
|
||||
self.items = items
|
||||
self.allowEmpty = allowEmpty
|
||||
self.edgesIgnoringSafeArea = edgesIgnoringSafeArea
|
||||
self.header = header()
|
||||
}
|
||||
|
||||
init(items: [ContentItem], allowEmpty: Bool = false) where Header == EmptyView {
|
||||
init(
|
||||
items: [ContentItem],
|
||||
allowEmpty: Bool = false
|
||||
) where Header == EmptyView {
|
||||
self.init(items: items, allowEmpty: allowEmpty) { EmptyView() }
|
||||
}
|
||||
|
||||
@@ -37,9 +47,6 @@ struct VerticalCells<Header: View>: View {
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
#if !os(tvOS)
|
||||
Color.clear.padding(.bottom, scrollViewBottomPadding)
|
||||
#endif
|
||||
}
|
||||
.animation(nil)
|
||||
.edgesIgnoringSafeArea(edgesIgnoringSafeArea)
|
||||
|
@@ -53,6 +53,7 @@ struct WatchView: View {
|
||||
}
|
||||
|
||||
FeedModel.shared.calculateUnwatchedFeed()
|
||||
WatchModel.shared.watchesChanged()
|
||||
}
|
||||
|
||||
var imageSystemName: String {
|
||||
|
Reference in New Issue
Block a user