diff --git a/Xcodes/Frontend/InfoPane/PlatformsView.swift b/Xcodes/Frontend/InfoPane/PlatformsView.swift index 92358702..6fe2134b 100644 --- a/Xcodes/Frontend/InfoPane/PlatformsView.swift +++ b/Xcodes/Frontend/InfoPane/PlatformsView.swift @@ -35,21 +35,18 @@ struct PlatformsView: View { .frame(maxWidth: .infinity, alignment: .leading) if !architectures.isEmpty { Spacer() - Button { - switch selectedRuntimeArchitecture { - case .arm64: selectedRuntimeArchitecture = .x86_64 - case .x86_64: selectedRuntimeArchitecture = .arm64 - } - } label: { - switch selectedRuntimeArchitecture { - case .arm64: - Label(selectedRuntimeArchitecture.displayString, systemImage: "m4.button.horizontal") - .labelStyle(.trailingIcon) - case .x86_64: - Label(selectedRuntimeArchitecture.displayString, systemImage: "cpu.fill") - .labelStyle(.trailingIcon) + Picker("Architecture", selection: $selectedRuntimeArchitecture) { + ForEach(Architecture.allCases, id: \.self) { arch in + Label(arch.displayString, systemImage: arch.iconName) + .tag(arch) } + .labelStyle(.trailingIcon) } + .pickerStyle(.menu) + .menuStyle(.button) + .buttonStyle(.borderless) + .fixedSize() + .labelsHidden() } } diff --git a/Xcodes/Frontend/XcodeList/MainToolbar.swift b/Xcodes/Frontend/XcodeList/MainToolbar.swift index c4511ded..b0ad763e 100644 --- a/Xcodes/Frontend/XcodeList/MainToolbar.swift +++ b/Xcodes/Frontend/XcodeList/MainToolbar.swift @@ -22,60 +22,44 @@ struct MainToolbarModifier: ViewModifier { } .keyboardShortcut(KeyEquivalent("r")) .help("RefreshDescription") + Spacer() - - Button(action: { - switch architectures { - case .universal: architectures = .appleSilicon - case .appleSilicon: architectures = .universal - } - }) { - switch architectures { - case .universal: - Label("Universal", systemImage: "cpu.fill") - case .appleSilicon: - Label("Apple Silicon", systemImage: "m4.button.horizontal") - .labelStyle(.trailingIcon) - .foregroundColor(.accentColor) - } - } - .help("FilterAvailableDescription") - .disabled(architectures.isManaged) - Button(action: { - switch category { - case .all: category = .release - case .release: category = .beta - case .beta: category = .all + let isFiltering = isInstalledOnly || category != .all || architectures != .universal + Menu("Filter", systemImage: "line.horizontal.3.decrease.circle") { + Section { + Toggle("Installed Only", systemImage: "arrow.down.app", isOn: $isInstalledOnly) .labelStyle(.titleAndIcon) } - }) { - switch category { - case .all: - Label("All", systemImage: "line.horizontal.3.decrease.circle") - case .release: + .help("FilterInstalledDescription") + + Section { + Picker("Category", selection: $category) { + Label("All", systemImage: "line.horizontal.3.decrease.circle") + .tag(XcodeListCategory.all) Label("ReleaseOnly", systemImage: "line.horizontal.3.decrease.circle.fill") - .labelStyle(.trailingIcon) - .foregroundColor(.accentColor) - case .beta: - Label("BetaOnly", systemImage: "line.horizontal.3.decrease.circle.fill") - .labelStyle(.trailingIcon) - .foregroundColor(.accentColor) + .tag(XcodeListCategory.release) + Label("BetaOnly", systemImage: "line.horizontal.3.decrease.circle.fill") + .tag(XcodeListCategory.beta) + } } - } - .help("FilterAvailableDescription") - .disabled(category.isManaged) - - Button(action: { - isInstalledOnly.toggle() - }) { - if isInstalledOnly { - Label("Filter", systemImage: "arrow.down.app.fill") - .foregroundColor(.accentColor) - } else { - Label("Filter", systemImage: "arrow.down.app") + .help("FilterAvailableDescription") + .disabled(category.isManaged) + + Section { + Picker("Architecture", selection: $architectures) { + Label("Universal", systemImage: "cpu.fill") + .tag(XcodeListArchitecture.universal) + Label("Apple Silicon", systemImage: "m4.button.horizontal") + .foregroundColor(.accentColor) + .tag(XcodeListArchitecture.appleSilicon) + } + .help("FilterArchitecturesDescription") + .disabled(architectures.isManaged) } + .labelStyle(.titleAndIcon) } - .help("FilterInstalledDescription") + .pickerStyle(.inline) + .symbolVariant(isFiltering ? .fill : .none) } } } diff --git a/Xcodes/XcodesKit/Sources/XcodesKit/Models/XcodeReleases/Architecture.swift b/Xcodes/XcodesKit/Sources/XcodesKit/Models/XcodeReleases/Architecture.swift index eb3ab40c..834ebeee 100644 --- a/Xcodes/XcodesKit/Sources/XcodesKit/Models/XcodeReleases/Architecture.swift +++ b/Xcodes/XcodesKit/Sources/XcodesKit/Models/XcodeReleases/Architecture.swift @@ -8,7 +8,7 @@ import Foundation /// The name of an Architecture. -public enum Architecture: String, Codable, Equatable, Hashable, Identifiable { +public enum Architecture: String, Codable, Equatable, Hashable, Identifiable, CaseIterable { public var id: Self { self } /// The Arm64 architecture (Apple Silicon) @@ -24,6 +24,15 @@ public enum Architecture: String, Codable, Equatable, Hashable, Identifiable { return "Intel" } } + + public var iconName: String { + switch self { + case .arm64: + return "m4.button.horizontal" + case .x86_64: + return "cpu.fill" + } + } } extension Array where Element == Architecture {