2021-09-25 08:18:22 +00:00
|
|
|
import Defaults
|
|
|
|
import Foundation
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct SettingsView: View {
|
2021-09-29 14:29:17 +00:00
|
|
|
#if os(macOS)
|
|
|
|
private enum Tabs: Hashable {
|
2021-11-03 23:00:17 +00:00
|
|
|
case instances, playback, services
|
2021-09-29 14:29:17 +00:00
|
|
|
}
|
|
|
|
#endif
|
2021-09-25 08:18:22 +00:00
|
|
|
|
2021-09-29 14:29:17 +00:00
|
|
|
#if os(iOS)
|
|
|
|
@Environment(\.dismiss) private var dismiss
|
|
|
|
#endif
|
2021-09-25 08:18:22 +00:00
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
#if os(macOS)
|
|
|
|
TabView {
|
|
|
|
Form {
|
2021-10-23 11:51:02 +00:00
|
|
|
InstancesSettings()
|
2021-09-25 08:18:22 +00:00
|
|
|
}
|
|
|
|
.tabItem {
|
|
|
|
Label("Instances", systemImage: "server.rack")
|
|
|
|
}
|
|
|
|
.tag(Tabs.instances)
|
|
|
|
|
2021-10-23 12:12:53 +00:00
|
|
|
Form {
|
2021-11-03 23:00:17 +00:00
|
|
|
PlaybackSettings()
|
2021-10-23 12:12:53 +00:00
|
|
|
}
|
|
|
|
.tabItem {
|
2021-11-03 23:00:17 +00:00
|
|
|
Label("Playback", systemImage: "play.rectangle.on.rectangle.fill")
|
2021-10-23 12:12:53 +00:00
|
|
|
}
|
2021-11-03 23:00:17 +00:00
|
|
|
.tag(Tabs.playback)
|
2021-10-23 12:12:53 +00:00
|
|
|
|
2021-09-25 08:18:22 +00:00
|
|
|
Form {
|
2021-11-03 23:00:17 +00:00
|
|
|
ServicesSettings()
|
2021-09-25 08:18:22 +00:00
|
|
|
}
|
|
|
|
.tabItem {
|
2021-11-03 23:00:17 +00:00
|
|
|
Label("Services", systemImage: "puzzlepiece.extension")
|
2021-09-25 08:18:22 +00:00
|
|
|
}
|
2021-11-03 23:00:17 +00:00
|
|
|
.tag(Tabs.services)
|
2021-09-25 08:18:22 +00:00
|
|
|
}
|
|
|
|
.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 {
|
2021-09-28 18:06:05 +00:00
|
|
|
#if os(tvOS)
|
|
|
|
AccountSelectionView()
|
|
|
|
#endif
|
2021-10-23 11:51:02 +00:00
|
|
|
InstancesSettings()
|
|
|
|
PlaybackSettings()
|
2021-11-03 23:00:17 +00:00
|
|
|
ServicesSettings()
|
2021-09-25 08:18:22 +00:00
|
|
|
}
|
|
|
|
.navigationTitle("Settings")
|
2021-09-26 22:03:33 +00:00
|
|
|
.toolbar {
|
|
|
|
ToolbarItem(placement: .navigationBarTrailing) {
|
|
|
|
#if !os(tvOS)
|
2021-09-28 18:06:05 +00:00
|
|
|
Button("Done") {
|
|
|
|
dismiss()
|
|
|
|
}
|
2021-09-26 22:03:33 +00:00
|
|
|
.keyboardShortcut(.cancelAction)
|
|
|
|
#endif
|
2021-09-25 08:18:22 +00:00
|
|
|
}
|
2021-09-26 22:03:33 +00:00
|
|
|
}
|
2021-09-28 18:06:05 +00:00
|
|
|
.frame(maxWidth: 1000)
|
2021-09-26 22:03:33 +00:00
|
|
|
#if os(iOS)
|
|
|
|
.listStyle(.insetGrouped)
|
|
|
|
#endif
|
2021-09-25 08:18:22 +00:00
|
|
|
}
|
2021-09-28 18:06:05 +00:00
|
|
|
#if os(tvOS)
|
|
|
|
.background(.thickMaterial)
|
|
|
|
#endif
|
2021-09-25 08:18:22 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SettingsView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
SettingsView()
|
2021-09-29 11:45:00 +00:00
|
|
|
.injectFixtureEnvironmentObjects()
|
2021-09-25 08:18:22 +00:00
|
|
|
#if os(macOS)
|
|
|
|
.frame(width: 600, height: 300)
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|