NetNewsWire/Multiplatform/macOS/Preferences/MacPreferencesView.swift

97 lines
1.9 KiB
Swift
Raw Normal View History

//
// MacPreferencesView.swift
// macOS
//
// Created by Stuart Breckenridge on 27/6/20.
//
import SwiftUI
2020-07-15 04:54:18 +02:00
enum PreferencePane: Int, CaseIterable {
case general = 0
case accounts = 1
case advanced = 2
var description: String {
switch self {
case .general:
return "General"
case .accounts:
return "Accounts"
case .advanced:
return "Advanced"
}
}
}
struct MacPreferencesView: View {
2020-07-12 08:07:52 +02:00
@EnvironmentObject var defaults: AppDefaults
2020-07-15 04:54:18 +02:00
@State private var preferencePane: PreferencePane = .general
2020-07-12 08:07:52 +02:00
var body: some View {
VStack {
2020-07-15 04:54:18 +02:00
switch preferencePane {
2020-07-12 08:07:52 +02:00
case .general:
2020-07-15 04:54:18 +02:00
GeneralPreferencesView()
2020-07-12 08:07:52 +02:00
.environmentObject(defaults)
case .accounts:
AccountsPreferencesView()
.environmentObject(defaults)
case .advanced:
AdvancedPreferencesView()
.environmentObject(defaults)
}
}
.toolbar {
ToolbarItem {
2020-07-13 16:29:33 +02:00
HStack {
Button(action: {
2020-07-15 04:54:18 +02:00
preferencePane = .general
2020-07-13 16:29:33 +02:00
}, label: {
VStack {
Image(systemName: "gearshape")
.font(.title2)
Text("General")
}.foregroundColor(
2020-07-15 04:54:18 +02:00
preferencePane == .general ? Color("AccentColor") : Color.gray
2020-07-13 16:29:33 +02:00
)
2020-07-13 16:51:09 +02:00
}).frame(width: 70)
2020-07-13 16:29:33 +02:00
Button(action: {
2020-07-15 04:54:18 +02:00
preferencePane = .accounts
2020-07-13 16:29:33 +02:00
}, label: {
VStack {
Image(systemName: "at")
.font(.title2)
Text("Accounts")
}.foregroundColor(
2020-07-15 04:54:18 +02:00
preferencePane == .accounts ? Color("AccentColor") : Color.gray
2020-07-13 16:29:33 +02:00
)
2020-07-13 16:51:09 +02:00
}).frame(width: 70)
2020-07-13 16:29:33 +02:00
Button(action: {
2020-07-15 04:54:18 +02:00
preferencePane = .advanced
2020-07-13 16:29:33 +02:00
}, label: {
VStack {
Image(systemName: "scale.3d")
.font(.title2)
Text("Advanced")
}.foregroundColor(
2020-07-15 04:54:18 +02:00
preferencePane == .advanced ? Color("AccentColor") : Color.gray
2020-07-13 16:29:33 +02:00
)
2020-07-13 16:51:09 +02:00
}).frame(width: 70)
2020-07-13 16:29:33 +02:00
}
2020-07-12 08:07:52 +02:00
}
}
2020-07-14 08:57:55 +02:00
2020-07-12 08:07:52 +02:00
}
}
struct MacPreferencesView_Previews: PreviewProvider {
2020-07-12 08:07:52 +02:00
static var previews: some View {
MacPreferencesView()
}
}