1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-14 14:20:32 +05:30
yattee/Shared/VideosListView.swift

46 lines
1.3 KiB
Swift
Raw Normal View History

2021-06-27 04:59:55 +05:30
import Defaults
2021-06-24 03:49:58 +05:30
import SwiftUI
struct VideosListView: View {
var videos: [Video]
var body: some View {
Section {
ScrollViewReader { scrollView in
List {
ForEach(videos) { video in
VideoView(video: video, layout: .list)
.contextMenu { VideoContextMenuView(video: video) }
#if os(tvOS)
.listRowInsets(listRowInsets)
#elseif os(iOS)
.listRowInsets(EdgeInsets(.zero))
.listRowSeparator(.hidden)
#endif
}
.onChange(of: videos) { videos in
guard let video = videos.first else {
return
}
2021-07-12 02:22:49 +05:30
scrollView.scrollTo(video.id, anchor: .top)
}
2021-06-24 03:49:58 +05:30
}
}
2021-07-12 02:22:49 +05:30
#if os(tvOS)
.listStyle(GroupedListStyle())
#endif
2021-06-24 03:49:58 +05:30
}
}
var listRowInsets: EdgeInsets {
EdgeInsets(top: .zero, leading: .zero, bottom: .zero, trailing: 30)
}
}
2021-07-28 04:10:04 +05:30
struct VideosListView_Previews: PreviewProvider {
static var previews: some View {
VideosListView(videos: Video.allFixtures)
}
}