1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-14 06:10:32 +05:30
yattee/Shared/VideosListView.swift
2021-08-02 01:18:21 +02:00

36 lines
1.0 KiB
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)
.frame(maxHeight: 200)
.contextMenu { VideoContextMenuView(video: video) }
.listRowInsets(EdgeInsets())
}
.onChange(of: videos) { videos in
guard let video = videos.first else {
return
}
scrollView.scrollTo(video.id, anchor: .top)
}
}
}
.listStyle(GroupedListStyle())
}
}
}
struct VideosListView_Previews: PreviewProvider {
static var previews: some View {
VideosListView(videos: Video.allFixtures)
}
}