yattee/tvOS/Options/OptionsView.swift
2021-09-25 11:34:46 +02:00

76 lines
1.8 KiB
Swift

import Defaults
import SwiftUI
struct OptionsView: View {
@EnvironmentObject<NavigationModel> private var navigation
@Default(.layout) private var layout
@Environment(\.dismiss) private var dismiss
var body: some View {
HStack {
VStack {
HStack {
Spacer()
VStack(alignment: .leading) {
Spacer()
tabSelectionOptions
CoverSectionView("View Options") {
CoverSectionRowView("Show videos as") { nextLayoutButton }
}
CoverSectionView(divider: false) {
CoverSectionRowView("Close View Options") { Button("Close") { dismiss() } }
}
Spacer()
SettingsView()
}
.frame(maxWidth: 800)
Spacer()
}
Spacer()
}
}
.background(.thinMaterial)
}
var tabSelectionOptions: some View {
VStack {
switch navigation.tabSelection {
case .search:
SearchOptionsView()
default:
EmptyView()
}
}
}
var nextLayoutButton: some View {
Button(layout.name) {
self.layout = layout.next()
}
.contextMenu {
ForEach(ListingLayout.allCases) { layout in
Button(layout.name) {
Defaults[.layout] = layout
}
}
}
}
}
struct OptionsView_Previews: PreviewProvider {
static var previews: some View {
OptionsView()
}
}