Skip to content

Commit cdf3675

Browse files
committed
Improve filtering UI
1 parent 4ccb6e7 commit cdf3675

3 files changed

Lines changed: 51 additions & 61 deletions

File tree

Xcodes/Frontend/InfoPane/PlatformsView.swift

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,18 @@ struct PlatformsView: View {
3535
.frame(maxWidth: .infinity, alignment: .leading)
3636
if !architectures.isEmpty {
3737
Spacer()
38-
Button {
39-
switch selectedRuntimeArchitecture {
40-
case .arm64: selectedRuntimeArchitecture = .x86_64
41-
case .x86_64: selectedRuntimeArchitecture = .arm64
42-
}
43-
} label: {
44-
switch selectedRuntimeArchitecture {
45-
case .arm64:
46-
Label(selectedRuntimeArchitecture.displayString, systemImage: "m4.button.horizontal")
47-
.labelStyle(.trailingIcon)
48-
case .x86_64:
49-
Label(selectedRuntimeArchitecture.displayString, systemImage: "cpu.fill")
50-
.labelStyle(.trailingIcon)
38+
Picker("Architecture", selection: $selectedRuntimeArchitecture) {
39+
ForEach(Architecture.allCases, id: \.self) { arch in
40+
Label(arch.displayString, systemImage: arch.iconName)
41+
.tag(arch)
5142
}
43+
.labelStyle(.trailingIcon)
5244
}
45+
.pickerStyle(.menu)
46+
.menuStyle(.button)
47+
.buttonStyle(.borderless)
48+
.fixedSize()
49+
.labelsHidden()
5350
}
5451
}
5552

Xcodes/Frontend/XcodeList/MainToolbar.swift

Lines changed: 31 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -22,60 +22,44 @@ struct MainToolbarModifier: ViewModifier {
2222
}
2323
.keyboardShortcut(KeyEquivalent("r"))
2424
.help("RefreshDescription")
25+
2526
Spacer()
26-
27-
Button(action: {
28-
switch architectures {
29-
case .universal: architectures = .appleSilicon
30-
case .appleSilicon: architectures = .universal
31-
}
32-
}) {
33-
switch architectures {
34-
case .universal:
35-
Label("Universal", systemImage: "cpu.fill")
36-
case .appleSilicon:
37-
Label("Apple Silicon", systemImage: "m4.button.horizontal")
38-
.labelStyle(.trailingIcon)
39-
.foregroundColor(.accentColor)
40-
}
41-
}
42-
.help("FilterAvailableDescription")
43-
.disabled(architectures.isManaged)
4427

45-
Button(action: {
46-
switch category {
47-
case .all: category = .release
48-
case .release: category = .beta
49-
case .beta: category = .all
28+
let isFiltering = isInstalledOnly || category != .all || architectures != .universal
29+
Menu("Filter", systemImage: "line.horizontal.3.decrease.circle") {
30+
Section {
31+
Toggle("Installed Only", isOn: $isInstalledOnly)
5032
}
51-
}) {
52-
switch category {
53-
case .all:
54-
Label("All", systemImage: "line.horizontal.3.decrease.circle")
55-
case .release:
33+
.help("FilterInstalledDescription")
34+
35+
Section {
36+
Picker("Category", selection: $category) {
37+
Label("All", systemImage: "line.horizontal.3.decrease.circle")
38+
.tag(XcodeListCategory.all)
5639
Label("ReleaseOnly", systemImage: "line.horizontal.3.decrease.circle.fill")
57-
.labelStyle(.trailingIcon)
58-
.foregroundColor(.accentColor)
59-
case .beta:
60-
Label("BetaOnly", systemImage: "line.horizontal.3.decrease.circle.fill")
61-
.labelStyle(.trailingIcon)
62-
.foregroundColor(.accentColor)
40+
.tag(XcodeListCategory.release)
41+
Label("BetaOnly", systemImage: "line.horizontal.3.decrease.circle.fill")
42+
.tag(XcodeListCategory.beta)
43+
}
6344
}
64-
}
65-
.help("FilterAvailableDescription")
66-
.disabled(category.isManaged)
67-
68-
Button(action: {
69-
isInstalledOnly.toggle()
70-
}) {
71-
if isInstalledOnly {
72-
Label("Filter", systemImage: "arrow.down.app.fill")
73-
.foregroundColor(.accentColor)
74-
} else {
75-
Label("Filter", systemImage: "arrow.down.app")
45+
.help("FilterAvailableDescription")
46+
.disabled(category.isManaged)
47+
48+
Section {
49+
Picker("Architecture", selection: $architectures) {
50+
Label("Universal", systemImage: "cpu.fill")
51+
.tag(XcodeListArchitecture.universal)
52+
Label("Apple Silicon", systemImage: "m4.button.horizontal")
53+
.foregroundColor(.accentColor)
54+
.tag(XcodeListArchitecture.appleSilicon)
55+
}
56+
.help("FilterArchitecturesDescription")
57+
.disabled(architectures.isManaged)
7658
}
59+
.labelStyle(.trailingIcon)
7760
}
78-
.help("FilterInstalledDescription")
61+
.pickerStyle(.inline)
62+
.symbolVariant(isFiltering ? .fill : .none)
7963
}
8064
}
8165
}

Xcodes/XcodesKit/Sources/XcodesKit/Models/XcodeReleases/Architecture.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import Foundation
99

1010
/// The name of an Architecture.
11-
public enum Architecture: String, Codable, Equatable, Hashable, Identifiable {
11+
public enum Architecture: String, Codable, Equatable, Hashable, Identifiable, CaseIterable {
1212
public var id: Self { self }
1313

1414
/// The Arm64 architecture (Apple Silicon)
@@ -24,6 +24,15 @@ public enum Architecture: String, Codable, Equatable, Hashable, Identifiable {
2424
return "Intel"
2525
}
2626
}
27+
28+
public var iconName: String {
29+
switch self {
30+
case .arm64:
31+
return "m4.button.horizontal"
32+
case .x86_64:
33+
return "cpu.fill"
34+
}
35+
}
2736
}
2837

2938
extension Array where Element == Architecture {

0 commit comments

Comments
 (0)