2021-06-26 23:29:55 +00:00
|
|
|
import Defaults
|
2021-06-23 22:19:58 +00:00
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct VideosListView: View {
|
|
|
|
var videos: [Video]
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
Section {
|
2021-07-31 22:10:56 +00:00
|
|
|
ScrollViewReader { scrollView in
|
|
|
|
List {
|
|
|
|
ForEach(videos) { video in
|
|
|
|
VideoView(video: video, layout: .list)
|
2021-08-01 23:01:24 +00:00
|
|
|
.listRowInsets(EdgeInsets())
|
2021-07-31 22:10:56 +00:00
|
|
|
}
|
|
|
|
.onChange(of: videos) { videos in
|
2021-08-16 15:52:42 +00:00
|
|
|
#if !os(tvOS)
|
2021-07-11 20:52:49 +00:00
|
|
|
|
2021-08-16 15:52:42 +00:00
|
|
|
guard let video = videos.first else {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
scrollView.scrollTo(video.id, anchor: .top)
|
|
|
|
#endif
|
2021-07-31 22:10:56 +00:00
|
|
|
}
|
2021-06-23 22:19:58 +00:00
|
|
|
}
|
|
|
|
}
|
2021-08-01 23:01:24 +00:00
|
|
|
.listStyle(GroupedListStyle())
|
2021-06-23 22:19:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-07-27 22:40:04 +00:00
|
|
|
|
|
|
|
struct VideosListView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
VideosListView(videos: Video.allFixtures)
|
|
|
|
}
|
|
|
|
}
|