Changes Preferences to use TabBar
This appears to crash when selecting a different pane.
This commit is contained in:
parent
4067e1edd7
commit
1d0c47a1bd
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue