From 46c5399b36144757d6b4452938887fda0ba4154d Mon Sep 17 00:00:00 2001 From: Matt Kiazyk Date: Wed, 23 Dec 2020 16:20:03 -0600 Subject: [PATCH] Saves the list category to userdefaults on top tab --- Xcodes/Frontend/XcodeList/XcodeListView.swift | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Xcodes/Frontend/XcodeList/XcodeListView.swift b/Xcodes/Frontend/XcodeList/XcodeListView.swift index c6ab09a..e8dc8cd 100644 --- a/Xcodes/Frontend/XcodeList/XcodeListView.swift +++ b/Xcodes/Frontend/XcodeList/XcodeListView.swift @@ -6,9 +6,10 @@ struct XcodeListView: View { @EnvironmentObject var appState: AppState @State private var selection = Set() @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()) }