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 {
|
2021-08-01 03:40:56 +05:30
|
|
|
ScrollViewReader { scrollView in
|
|
|
|
List {
|
|
|
|
ForEach(videos) { video in
|
|
|
|
VideoView(video: video, layout: .list)
|
2021-08-02 04:31:24 +05:30
|
|
|
.listRowInsets(EdgeInsets())
|
2021-08-01 03:40:56 +05:30
|
|
|
}
|
|
|
|
.onChange(of: videos) { videos in
|
2021-08-16 21:22:42 +05:30
|
|
|
#if !os(tvOS)
|
2021-07-12 02:22:49 +05:30
|
|
|
|
2021-08-16 21:22:42 +05:30
|
|
|
guard let video = videos.first else {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
scrollView.scrollTo(video.id, anchor: .top)
|
|
|
|
#endif
|
2021-08-01 03:40:56 +05:30
|
|
|
}
|
2021-06-24 03:49:58 +05:30
|
|
|
}
|
|
|
|
}
|
2021-09-01 02:47:50 +05:30
|
|
|
.listStyle(.grouped)
|
2021-06-24 03:49:58 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-07-28 04:10:04 +05:30
|
|
|
|
|
|
|
struct VideosListView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
VideosListView(videos: Video.allFixtures)
|
|
|
|
}
|
|
|
|
}
|