mirror of
https://github.com/XcodesOrg/XcodesApp.git
synced 2026-03-25 08:55:46 +00:00
Merge pull request #746 from LiYanan2004/filter-ux
Improve filtering UI/UX on Xcode List
This commit is contained in:
commit
be2eea0532
3 changed files with 52 additions and 62 deletions
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
Spacer()
|
||||
|
||||
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)
|
||||
.tag(XcodeListCategory.release)
|
||||
Label("BetaOnly", systemImage: "line.horizontal.3.decrease.circle.fill")
|
||||
.tag(XcodeListCategory.beta)
|
||||
}
|
||||
}
|
||||
.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)
|
||||
case .beta:
|
||||
Label("BetaOnly", systemImage: "line.horizontal.3.decrease.circle.fill")
|
||||
.labelStyle(.trailingIcon)
|
||||
.foregroundColor(.accentColor)
|
||||
.tag(XcodeListArchitecture.appleSilicon)
|
||||
}
|
||||
.help("FilterArchitecturesDescription")
|
||||
.disabled(architectures.isManaged)
|
||||
}
|
||||
.labelStyle(.titleAndIcon)
|
||||
}
|
||||
.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("FilterInstalledDescription")
|
||||
.pickerStyle(.inline)
|
||||
.symbolVariant(isFiltering ? .fill : .none)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue