mirror of
https://github.com/yattee/yattee.git
synced 2025-10-25 08:48:17 +00:00
Add Defaults library
This commit is contained in:
@@ -4,10 +4,8 @@ struct ChannelView: View {
|
||||
@ObservedObject private var provider = ChannelVideosProvider()
|
||||
@EnvironmentObject private var state: AppState
|
||||
|
||||
@Binding var tabSelection: TabSelection
|
||||
|
||||
var body: some View {
|
||||
VideosListView(tabSelection: $tabSelection, videos: videos)
|
||||
VideosListView(videos: videos)
|
||||
}
|
||||
|
||||
var listRowInsets: EdgeInsets {
|
||||
|
||||
@@ -3,8 +3,6 @@ import SwiftUI
|
||||
struct PlaylistsView: View {
|
||||
@EnvironmentObject private var state: AppState
|
||||
|
||||
@Binding var tabSelection: TabSelection
|
||||
|
||||
@ObservedObject private var provider = PlaylistsProvider()
|
||||
|
||||
@State private var selectedPlaylist: Playlist?
|
||||
@@ -23,7 +21,7 @@ struct PlaylistsView: View {
|
||||
|
||||
VStack {
|
||||
if selectedPlaylist != nil {
|
||||
VideosView(tabSelection: $tabSelection, videos: selectedPlaylist!.videos)
|
||||
VideosView(videos: selectedPlaylist!.videos)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,8 @@ import SwiftUI
|
||||
struct PopularVideosView: View {
|
||||
@ObservedObject private var provider = PopularVideosProvider()
|
||||
|
||||
@Binding var tabSelection: TabSelection
|
||||
|
||||
var body: some View {
|
||||
VideosView(tabSelection: $tabSelection, videos: videos)
|
||||
VideosView(videos: videos)
|
||||
}
|
||||
|
||||
var videos: [Video] {
|
||||
|
||||
@@ -5,12 +5,10 @@ struct SearchView: View {
|
||||
@EnvironmentObject private var profile: Profile
|
||||
@EnvironmentObject private var state: AppState
|
||||
|
||||
@Binding var tabSelection: TabSelection
|
||||
|
||||
@State private var query = ""
|
||||
|
||||
var body: some View {
|
||||
VideosView(tabSelection: $tabSelection, videos: videos)
|
||||
VideosView(videos: videos)
|
||||
.environmentObject(state)
|
||||
.environmentObject(profile)
|
||||
.searchable(text: $query)
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import SwiftUI
|
||||
|
||||
struct SubscriptionsView: View {
|
||||
@Binding var tabSelection: TabSelection
|
||||
|
||||
@ObservedObject private var provider = SubscriptionVideosProvider()
|
||||
|
||||
var body: some View {
|
||||
VideosView(tabSelection: $tabSelection, videos: videos)
|
||||
VideosView(videos: videos)
|
||||
}
|
||||
|
||||
var videos: [Video] {
|
||||
|
||||
@@ -7,23 +7,20 @@ struct TrendingCountrySelectionView: View {
|
||||
@State private var query: String = ""
|
||||
@Binding var selectedCountry: Country
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
VisualEffectView(effect: UIBlurEffect(style: .dark))
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
|
||||
ScrollView(.vertical) {
|
||||
ForEach(countries) { country in
|
||||
Button(country.name) {
|
||||
selectedCountry = country
|
||||
presentationMode.wrappedValue.dismiss()
|
||||
}
|
||||
var body: some View {
|
||||
ScrollView(.vertical) {
|
||||
ForEach(countries) { country in
|
||||
Button(country.name) {
|
||||
selectedCountry = country
|
||||
presentationMode.wrappedValue.dismiss()
|
||||
}
|
||||
.frame(width: 800)
|
||||
}
|
||||
.searchable(text: $query)
|
||||
.frame(width: 800)
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.edgesIgnoringSafeArea(.all)
|
||||
.searchable(text: $query)
|
||||
.background(.thinMaterial)
|
||||
}
|
||||
|
||||
var countries: [Country] {
|
||||
|
||||
@@ -3,8 +3,6 @@ import SwiftUI
|
||||
struct TrendingView: View {
|
||||
@EnvironmentObject private var state: AppState
|
||||
|
||||
@Binding var tabSelection: TabSelection
|
||||
|
||||
@ObservedObject private var videosProvider = TrendingVideosProvider()
|
||||
|
||||
@SceneStorage("category") var category: TrendingCategory = .default
|
||||
@@ -26,7 +24,7 @@ struct TrendingView: View {
|
||||
}
|
||||
.scaleEffect(0.85)
|
||||
|
||||
VideosView(tabSelection: $tabSelection, videos: videos)
|
||||
VideosView(videos: videos)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import Defaults
|
||||
import SwiftUI
|
||||
|
||||
struct VideosListView: View {
|
||||
@EnvironmentObject private var state: AppState
|
||||
|
||||
@Binding var tabSelection: TabSelection
|
||||
@Default(.tabSelection) var tabSelection
|
||||
|
||||
var videos: [Video]
|
||||
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
import Defaults
|
||||
import SwiftUI
|
||||
|
||||
struct VideosView: View {
|
||||
@EnvironmentObject private var profile: Profile
|
||||
|
||||
@Binding var tabSelection: TabSelection
|
||||
var videos: [Video]
|
||||
|
||||
@Default(.layout) var layout
|
||||
@Default(.tabSelection) var tabSelection
|
||||
|
||||
@State private var showingViewOptions = false
|
||||
|
||||
var body: some View {
|
||||
Section {
|
||||
if self.profile.listing == .list {
|
||||
VideosListView(tabSelection: $tabSelection, videos: videos)
|
||||
if layout == .list {
|
||||
VideosListView(videos: videos)
|
||||
} else {
|
||||
VideosCellsView(videos: videos, columns: self.profile.cellsColumns)
|
||||
}
|
||||
|
||||
@@ -1,32 +1,45 @@
|
||||
import Defaults
|
||||
import SwiftUI
|
||||
|
||||
struct ViewOptionsView: View {
|
||||
@EnvironmentObject private var profile: Profile
|
||||
|
||||
@Environment(\.presentationMode) private var presentationMode
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@Default(.layout) var layout
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
VisualEffectView(effect: UIBlurEffect(style: .dark))
|
||||
|
||||
HStack {
|
||||
VStack {
|
||||
Spacer()
|
||||
|
||||
ScrollView(.vertical) {
|
||||
Button(profile.listing == .list ? "Cells" : "List") {
|
||||
profile.listing = (profile.listing == .list ? .cells : .list)
|
||||
presentationMode.wrappedValue.dismiss()
|
||||
HStack(alignment: .center) {
|
||||
Spacer()
|
||||
|
||||
VStack {
|
||||
nextLayoutButton
|
||||
|
||||
Button("Close") {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
Button("Close") {
|
||||
presentationMode.wrappedValue.dismiss()
|
||||
}
|
||||
.frame(width: 800)
|
||||
Spacer()
|
||||
}
|
||||
|
||||
Spacer()
|
||||
}
|
||||
|
||||
Spacer()
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.edgesIgnoringSafeArea(.all)
|
||||
.background(.thinMaterial)
|
||||
}
|
||||
|
||||
var nextLayoutButton: some View {
|
||||
Button(layout.next().name, action: nextLayout)
|
||||
}
|
||||
|
||||
func nextLayout() {
|
||||
Defaults[.layout] = layout.next()
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
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