Saves the list category to userdefaults on top tab

This commit is contained in:
Matt Kiazyk 2020-12-23 16:20:03 -06:00
parent 155c62de77
commit 46c5399b36
No known key found for this signature in database
GPG key ID: 967DBC53389132D7

View file

@ -6,9 +6,10 @@ struct XcodeListView: View {
@EnvironmentObject var appState: AppState
@State private var selection = Set<String>()
@State private var rowBeingConfirmedForUninstallation: AppState.XcodeVersion?
@State private var category: Category = .all
@State private var searchText: String = ""
@AppStorage("listCategory") private var category: Category = .all
var visibleVersions: [AppState.XcodeVersion] {
var versions: [AppState.XcodeVersion]
switch category {
@ -25,8 +26,9 @@ struct XcodeListView: View {
return versions
}
enum Category {
case all, installed
enum Category: String, CaseIterable {
case all = "All"
case installed = "Installed"
}
var body: some View {
@ -79,10 +81,9 @@ struct XcodeListView: View {
}
ToolbarItem(placement: .principal) {
Picker("", selection: $category) {
Text("All")
.tag(Category.all)
Text("Installed")
.tag(Category.installed)
ForEach(Category.allCases, id: \.self) {
Text($0.rawValue).tag($0)
}
}
.pickerStyle(SegmentedPickerStyle())
}