yattee/Shared/Settings/SettingsView.swift

66 lines
1.7 KiB
Swift
Raw Normal View History

2021-09-25 08:18:22 +00:00
import Defaults
import Foundation
import SwiftUI
struct SettingsView: View {
private enum Tabs: Hashable {
case playback, instances
}
@Environment(\.dismiss) private var dismiss
var body: some View {
#if os(macOS)
TabView {
Form {
InstancesSettingsView()
}
.tabItem {
Label("Instances", systemImage: "server.rack")
}
.tag(Tabs.instances)
Form {
PlaybackSettingsView()
}
.tabItem {
Label("Playback", systemImage: "play.rectangle.on.rectangle.fill")
}
.tag(Tabs.playback)
}
.padding(20)
2021-09-26 22:03:33 +00:00
.frame(width: 400, height: 310)
2021-09-25 08:18:22 +00:00
#else
NavigationView {
List {
InstancesSettingsView()
PlaybackSettingsView()
}
.navigationTitle("Settings")
2021-09-26 22:03:33 +00:00
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button("Done") {
dismiss()
2021-09-25 08:18:22 +00:00
}
2021-09-26 22:03:33 +00:00
#if !os(tvOS)
.keyboardShortcut(.cancelAction)
#endif
2021-09-25 08:18:22 +00:00
}
2021-09-26 22:03:33 +00:00
}
#if os(iOS)
.listStyle(.insetGrouped)
#endif
2021-09-25 08:18:22 +00:00
}
#endif
}
}
struct SettingsView_Previews: PreviewProvider {
static var previews: some View {
SettingsView()
#if os(macOS)
.frame(width: 600, height: 300)
#endif
}
}