yattee/Apple TV/PopularVideosView.swift

26 lines
566 B
Swift
Raw Normal View History

2021-06-11 12:36:26 +00:00
import SwiftUI
struct PopularVideosView: View {
2021-06-11 21:11:59 +00:00
@ObservedObject private var provider = PopularVideosProvider()
@ObservedObject var state: AppState
2021-06-11 21:54:00 +00:00
2021-06-11 21:11:59 +00:00
@Binding var tabSelection: TabSelection
2021-06-11 12:36:26 +00:00
var body: some View {
2021-06-11 21:40:35 +00:00
VideosView(state: state, tabSelection: $tabSelection, videos: videos)
.task {
async {
provider.load()
2021-06-11 12:36:26 +00:00
}
}
}
2021-06-11 21:11:59 +00:00
2021-06-11 21:40:35 +00:00
var videos: [Video] {
2021-06-14 18:05:02 +00:00
if provider.videos.isEmpty {
2021-06-11 22:49:42 +00:00
provider.load()
}
2021-06-14 18:05:02 +00:00
2021-06-11 21:40:35 +00:00
return provider.videos
2021-06-11 12:36:26 +00:00
}
}