2021-06-28 10:43:07 +00:00
|
|
|
import Siesta
|
2021-06-11 12:36:26 +00:00
|
|
|
import SwiftUI
|
|
|
|
|
2021-07-27 22:40:04 +00:00
|
|
|
struct PopularView: View {
|
2021-09-25 08:18:22 +00:00
|
|
|
@StateObject private var store = Store<[Video]>()
|
2021-06-11 21:54:00 +00:00
|
|
|
|
2021-10-16 22:48:58 +00:00
|
|
|
@EnvironmentObject<AccountsModel> private var accounts
|
2021-06-11 21:11:59 +00:00
|
|
|
|
2021-10-20 22:21:50 +00:00
|
|
|
var resource: Resource? {
|
|
|
|
accounts.api.popular
|
2021-06-28 10:43:07 +00:00
|
|
|
}
|
2021-06-14 18:05:02 +00:00
|
|
|
|
2021-10-21 23:29:10 +00:00
|
|
|
var videos: [ContentItem] {
|
|
|
|
ContentItem.array(of: store.collection)
|
|
|
|
}
|
|
|
|
|
2021-06-28 10:43:07 +00:00
|
|
|
var body: some View {
|
2021-10-05 20:20:09 +00:00
|
|
|
PlayerControlsView {
|
2021-10-21 23:29:10 +00:00
|
|
|
VerticalCells(items: videos)
|
2021-10-05 20:20:09 +00:00
|
|
|
.onAppear {
|
2021-10-20 22:21:50 +00:00
|
|
|
resource?.addObserver(store)
|
|
|
|
resource?.loadIfNeeded()
|
2021-10-05 20:20:09 +00:00
|
|
|
}
|
|
|
|
#if !os(tvOS)
|
|
|
|
.navigationTitle("Popular")
|
|
|
|
#endif
|
|
|
|
}
|
2021-11-01 21:56:18 +00:00
|
|
|
.toolbar {
|
|
|
|
ToolbarItem(placement: .automatic) {
|
|
|
|
FavoriteButton(item: FavoriteItem(section: .popular))
|
|
|
|
}
|
|
|
|
}
|
2021-06-11 12:36:26 +00:00
|
|
|
}
|
|
|
|
}
|