yattee/Shared/Videos/VideosListView.swift
2021-09-02 01:11:58 +02:00

37 lines
971 B
Swift

import Defaults
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)
.listRowInsets(EdgeInsets())
}
.onChange(of: videos) { videos in
#if !os(tvOS)
guard let video = videos.first else {
return
}
scrollView.scrollTo(video.id, anchor: .top)
#endif
}
}
}
.listStyle(.grouped)
}
}
}
struct VideosListView_Previews: PreviewProvider {
static var previews: some View {
VideosListView(videos: Video.allFixtures)
}
}