Changes Preferences to use TabBar

This appears to crash when selecting a different pane.
This commit is contained in:
Stuart Breckenridge 2020-08-05 11:45:24 +08:00
parent 4067e1edd7
commit 1d0c47a1bd
No known key found for this signature in database
GPG Key ID: 79BD673276AE83CE
1 changed files with 57 additions and 65 deletions

View File

@ -30,74 +30,66 @@ enum PreferencePane: Int, CaseIterable {
struct MacPreferencesView: View { struct MacPreferencesView: View {
@EnvironmentObject var defaults: AppDefaults @EnvironmentObject var defaults: AppDefaults
@State private var preferencePane: PreferencePane = .general @State private var selectedPane: PreferencePane = .general
var body: some View { var body: some View {
VStack { TabView(selection: $selectedPane) {
switch preferencePane {
case .general:
GeneralPreferencesView() GeneralPreferencesView()
.environmentObject(defaults) .environmentObject(defaults)
case .accounts: .tabItem {
AccountsPreferencesView()
.environmentObject(defaults)
case .viewing:
LayoutPreferencesView()
.environmentObject(defaults)
case .advanced:
AdvancedPreferencesView()
.environmentObject(defaults)
}
}
.toolbar {
ToolbarItem {
HStack {
Button(action: {
preferencePane = .general
}, label: {
VStack { VStack {
Image(systemName: "gearshape") Image(systemName: "gearshape")
.font(.title2) .font(.title2)
Text("General") Text("General")
}.foregroundColor( }
preferencePane == .general ? Color("AccentColor") : Color.gray }
) .onTapGesture {
}).frame(width: 70, height: 50) selectedPane = .general
Button(action: { }
preferencePane = .accounts .tag(PreferencePane.general)
}, label: {
AccountsPreferencesView()
.environmentObject(defaults)
.tabItem {
VStack { VStack {
Image(systemName: "at") Image(systemName: "at")
.font(.title2) .font(.title2)
Text("Accounts") Text("Accounts")
}.foregroundColor( }
preferencePane == .accounts ? Color("AccentColor") : Color.gray }
) .onTapGesture {
}).frame(width: 70, height: 50) selectedPane = .accounts
Button(action: { }
preferencePane = .viewing .tag(PreferencePane.accounts)
}, label: {
LayoutPreferencesView()
.environmentObject(defaults)
.tabItem {
VStack { VStack {
Image(systemName: "eyeglasses") Image(systemName: "eyeglasses")
.font(.title2) .font(.title2)
Text("Viewing") Text("Viewing")
}.foregroundColor( }
preferencePane == .viewing ? Color("AccentColor") : Color.gray }
) .onTapGesture {
}).frame(width: 70, height: 50) selectedPane = .viewing
Button(action: { }
preferencePane = .advanced .tag(PreferencePane.viewing)
}, label: {
AdvancedPreferencesView()
.environmentObject(defaults)
.tabItem {
VStack { VStack {
Image(systemName: "scale.3d") Image(systemName: "scale.3d")
.font(.title2) .font(.title2)
Text("Advanced") Text("Advanced")
}.foregroundColor(
preferencePane == .advanced ? Color("AccentColor") : Color.gray
)
}).frame(width: 70, height: 50)
} }
} }
.onTapGesture {
selectedPane = .advanced
}
.tag(PreferencePane.advanced)
} }
} }