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