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-11 22:49:42 +00:00
|
|
|
if (provider.videos.isEmpty) {
|
|
|
|
provider.load()
|
|
|
|
}
|
|
|
|
|
2021-06-11 21:40:35 +00:00
|
|
|
return provider.videos
|
2021-06-11 12:36:26 +00:00
|
|
|
}
|
|
|
|
}
|