1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-13 22:00:31 +05:30
yattee/tvOS/Options/OptionsView.swift

74 lines
1.7 KiB
Swift
Raw Normal View History

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