mirror of
https://github.com/yattee/yattee.git
synced 2025-10-17 21:08:16 +00:00
Popular videos tab
This commit is contained in:
@@ -2,12 +2,12 @@ import SwiftUI
|
||||
|
||||
struct ChannelView: View {
|
||||
@ObservedObject private var provider = ChannelVideosProvider()
|
||||
@ObservedObject var state: AppState
|
||||
@EnvironmentObject private var state: AppState
|
||||
|
||||
@Binding var tabSelection: TabSelection
|
||||
|
||||
var body: some View {
|
||||
VideosView(state: state, tabSelection: $tabSelection, videos: videos)
|
||||
VideosView(tabSelection: $tabSelection, videos: videos)
|
||||
}
|
||||
|
||||
var listRowInsets: EdgeInsets {
|
||||
|
@@ -2,12 +2,12 @@ import SwiftUI
|
||||
|
||||
struct PopularVideosView: View {
|
||||
@ObservedObject private var provider = PopularVideosProvider()
|
||||
@ObservedObject var state: AppState
|
||||
@EnvironmentObject private var state: AppState
|
||||
|
||||
@Binding var tabSelection: TabSelection
|
||||
|
||||
var body: some View {
|
||||
VideosView(state: state, tabSelection: $tabSelection, videos: videos)
|
||||
VideosView(tabSelection: $tabSelection, videos: videos)
|
||||
.task {
|
||||
async {
|
||||
provider.load()
|
||||
|
@@ -2,14 +2,14 @@ import SwiftUI
|
||||
|
||||
struct SearchView: View {
|
||||
@ObservedObject private var provider = SearchedVideosProvider()
|
||||
@ObservedObject var state: AppState
|
||||
@EnvironmentObject private var state: AppState
|
||||
|
||||
@Binding var tabSelection: TabSelection
|
||||
|
||||
@State var query = ""
|
||||
@State private var query = ""
|
||||
|
||||
var body: some View {
|
||||
VideosView(state: state, tabSelection: $tabSelection, videos: videos)
|
||||
VideosView(tabSelection: $tabSelection, videos: videos)
|
||||
.searchable(text: $query)
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import AVKit
|
||||
|
||||
class StreamAVPlayerViewController: AVPlayerViewController {
|
||||
final class StreamAVPlayerViewController: AVPlayerViewController {
|
||||
var state: PlayerState?
|
||||
|
||||
override func viewWillDisappear(_ animated: Bool) {
|
||||
|
@@ -2,12 +2,12 @@ import SwiftUI
|
||||
|
||||
struct SubscriptionsView: View {
|
||||
@ObservedObject private var provider = SubscriptionVideosProvider()
|
||||
@ObservedObject var state: AppState
|
||||
@EnvironmentObject private var state: AppState
|
||||
|
||||
@Binding var tabSelection: TabSelection
|
||||
|
||||
var body: some View {
|
||||
VideosView(state: state, tabSelection: $tabSelection, videos: videos)
|
||||
VideosView(tabSelection: $tabSelection, videos: videos)
|
||||
.task {
|
||||
async {
|
||||
provider.load()
|
||||
|
29
Apple TV/TrendingCategorySelectionView.swift
Normal file
29
Apple TV/TrendingCategorySelectionView.swift
Normal file
@@ -0,0 +1,29 @@
|
||||
import SwiftUI
|
||||
|
||||
struct TrendingCategorySelectionView: View {
|
||||
@Environment(\.presentationMode) private var presentationMode
|
||||
|
||||
@Binding var selectedCategory: TrendingCategory
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
VisualEffectView(effect: UIBlurEffect(style: .dark))
|
||||
|
||||
VStack(alignment: .leading) {
|
||||
Spacer()
|
||||
|
||||
ForEach(TrendingCategory.allCases) { category in
|
||||
Button(category.name) {
|
||||
selectedCategory = category
|
||||
presentationMode.wrappedValue.dismiss()
|
||||
}
|
||||
}
|
||||
.frame(width: 800)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.edgesIgnoringSafeArea(.all)
|
||||
}
|
||||
}
|
34
Apple TV/TrendingCountrySelectionView.swift
Normal file
34
Apple TV/TrendingCountrySelectionView.swift
Normal file
@@ -0,0 +1,34 @@
|
||||
import SwiftUI
|
||||
|
||||
struct TrendingCountrySelectionView: View {
|
||||
@Environment(\.presentationMode) private var presentationMode
|
||||
@ObservedObject var provider: TrendingCountriesProvider
|
||||
|
||||
@State private var query: String = ""
|
||||
@Binding var selectedCountry: Country
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
VisualEffectView(effect: UIBlurEffect(style: .dark))
|
||||
|
||||
ScrollView(.vertical) {
|
||||
ForEach(countries) { country in
|
||||
Button(country.name) {
|
||||
selectedCountry = country
|
||||
presentationMode.wrappedValue.dismiss()
|
||||
}
|
||||
}
|
||||
.frame(width: 800)
|
||||
}
|
||||
.searchable(text: $query)
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.edgesIgnoringSafeArea(.all)
|
||||
}
|
||||
|
||||
var countries: [Country] {
|
||||
provider.load(query)
|
||||
|
||||
return provider.countries
|
||||
}
|
||||
}
|
52
Apple TV/TrendingView.swift
Normal file
52
Apple TV/TrendingView.swift
Normal file
@@ -0,0 +1,52 @@
|
||||
import SwiftUI
|
||||
|
||||
struct TrendingView: View {
|
||||
@EnvironmentObject private var state: AppState
|
||||
@EnvironmentObject private var trendingState: TrendingState
|
||||
|
||||
@Binding var tabSelection: TabSelection
|
||||
|
||||
@ObservedObject private var countriesProvider = TrendingCountriesProvider()
|
||||
@ObservedObject private var videosProvider = TrendingVideosProvider()
|
||||
|
||||
@State private var selectingCategory = false
|
||||
@State private var selectingCountry = false
|
||||
|
||||
var body: some View {
|
||||
Section {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
HStack(alignment: .top) {
|
||||
Spacer()
|
||||
|
||||
Button(trendingState.category.name) {
|
||||
selectingCategory.toggle()
|
||||
}
|
||||
.fullScreenCover(isPresented: $selectingCategory) {
|
||||
TrendingCategorySelectionView(selectedCategory: $trendingState.category)
|
||||
}
|
||||
|
||||
Text(trendingState.country.flag)
|
||||
.font(.system(size: 60))
|
||||
|
||||
Button(trendingState.country.rawValue) {
|
||||
selectingCountry.toggle()
|
||||
}
|
||||
.fullScreenCover(isPresented: $selectingCountry) {
|
||||
TrendingCountrySelectionView(provider: countriesProvider, selectedCountry: $trendingState.country)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
}
|
||||
.scaleEffect(0.85)
|
||||
|
||||
VideosView(tabSelection: $tabSelection, videos: videos)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var videos: [Video] {
|
||||
videosProvider.load(category: trendingState.category, country: trendingState.country)
|
||||
|
||||
return videosProvider.videos
|
||||
}
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
import SwiftUI
|
||||
|
||||
struct VideosView: View {
|
||||
@ObservedObject var state: AppState
|
||||
@EnvironmentObject private var state: AppState
|
||||
|
||||
@Binding var tabSelection: TabSelection
|
||||
|
||||
|
13
Apple TV/VisualEffectView.swift
Normal file
13
Apple TV/VisualEffectView.swift
Normal file
@@ -0,0 +1,13 @@
|
||||
import SwiftUI
|
||||
|
||||
struct VisualEffectView: UIViewRepresentable {
|
||||
var effect: UIVisualEffect?
|
||||
|
||||
func makeUIView(context _: UIViewRepresentableContext<Self>) -> UIVisualEffectView {
|
||||
UIVisualEffectView()
|
||||
}
|
||||
|
||||
func updateUIView(_ uiView: UIVisualEffectView, context _: UIViewRepresentableContext<Self>) {
|
||||
uiView.effect = effect
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user