yattee/tvOS/Options/OptionsView.swift

74 lines
1.7 KiB
Swift
Raw Normal View History

2021-07-07 22:39:18 +00:00
import Defaults
import SwiftUI
struct OptionsView: View {
2021-07-11 20:52:49 +00:00
@EnvironmentObject<NavigationState> private var navigationState
2021-07-07 22:39:18 +00:00
@Default(.layout) private var layout
2021-07-11 20:52:49 +00:00
@Environment(\.dismiss) private var dismiss
2021-07-07 22:39:18 +00:00
var body: some View {
HStack {
VStack {
HStack {
Spacer()
VStack(alignment: .leading) {
Spacer()
tabSelectionOptions
2021-07-08 15:14:54 +00:00
CoverSectionView("View Options") {
CoverSectionRowView("Show videos as") { nextLayoutButton }
2021-07-07 22:39:18 +00:00
}
2021-07-08 15:14:54 +00:00
CoverSectionView(divider: false) {
CoverSectionRowView("Close View Options") { Button("Close") { dismiss() } }
2021-07-07 22:39:18 +00:00
}
Spacer()
}
.frame(maxWidth: 800)
Spacer()
}
Spacer()
}
}
.background(.thinMaterial)
}
var tabSelectionOptions: some View {
VStack {
2021-07-11 20:52:49 +00:00
switch navigationState.tabSelection {
2021-07-07 22:39:18 +00:00
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()
}
}