From 10ce2b85119c725e6db79173ae92a7a40df2a3ba Mon Sep 17 00:00:00 2001 From: Matt Kiazyk Date: Mon, 7 Jul 2025 23:03:20 -0500 Subject: [PATCH] support filtering --- Xcodes.xcodeproj/project.pbxproj | 4 ++ Xcodes/Frontend/InfoPane/InfoPane.swift | 8 +-- Xcodes/Frontend/InfoPane/PlatformsView.swift | 52 +++++++++++++++---- .../InfoPane/RuntimeArchitecture.swift | 17 ++++++ 4 files changed, 65 insertions(+), 16 deletions(-) create mode 100644 Xcodes/Frontend/InfoPane/RuntimeArchitecture.swift diff --git a/Xcodes.xcodeproj/project.pbxproj b/Xcodes.xcodeproj/project.pbxproj index fafe433..7062ad2 100644 --- a/Xcodes.xcodeproj/project.pbxproj +++ b/Xcodes.xcodeproj/project.pbxproj @@ -140,6 +140,7 @@ E8DA461125FAF7FB002E85EF /* NotificationsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8DA461025FAF7FB002E85EF /* NotificationsView.swift */; }; E8E98A9025D8631800EC89A0 /* InstallationStepRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAFBC3FF259AC17F00E2A3D8 /* InstallationStepRowView.swift */; }; E8E98A9625D863D700EC89A0 /* InstallationStepDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8E98A9525D863D700EC89A0 /* InstallationStepDetailView.swift */; }; + E8EE58C02E1CC2A50003FA9F /* RuntimeArchitecture.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8EE58BF2E1CC2A50003FA9F /* RuntimeArchitecture.swift */; }; E8F44A1E296B4CD7002D6592 /* Path in Frameworks */ = {isa = PBXBuildFile; productRef = E8F44A1D296B4CD7002D6592 /* Path */; }; E8FA00542B5B109800769CE0 /* com.xcodesorg.xcodesapp.Helper in Copy Helper */ = {isa = PBXBuildFile; fileRef = CA9FF8AE2595967A00E47BAF /* com.xcodesorg.xcodesapp.Helper */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; E8FD5727291EE4AC001E004C /* AsyncNetworkService in Frameworks */ = {isa = PBXBuildFile; productRef = E8FD5726291EE4AC001E004C /* AsyncNetworkService */; }; @@ -342,6 +343,7 @@ E8D655BF288DD04700A139C2 /* SelectedActionType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectedActionType.swift; sourceTree = ""; }; E8DA461025FAF7FB002E85EF /* NotificationsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationsView.swift; sourceTree = ""; }; E8E98A9525D863D700EC89A0 /* InstallationStepDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstallationStepDetailView.swift; sourceTree = ""; }; + E8EE58BF2E1CC2A50003FA9F /* RuntimeArchitecture.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuntimeArchitecture.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -660,6 +662,7 @@ E8E98A9425D863B100EC89A0 /* InfoPane */ = { isa = PBXGroup; children = ( + E8EE58BF2E1CC2A50003FA9F /* RuntimeArchitecture.swift */, B0403CEF2AD92D7B00137C09 /* ReleaseNotesView.swift */, B0403CF32AD9381D00137C09 /* SDKsView.swift */, B0403CF52AD9849E00137C09 /* CompilersView.swift */, @@ -939,6 +942,7 @@ 53CBAB2C263DCC9100410495 /* XcodesAlert.swift in Sources */, 332807412CA5EA820036F691 /* SignInSecurityKeyTouchView.swift in Sources */, CA61A6E0259835580008926E /* Xcode.swift in Sources */, + E8EE58C02E1CC2A50003FA9F /* RuntimeArchitecture.swift in Sources */, CAE4247F259A666100B8B246 /* MainWindow.swift in Sources */, CA452BB0259FD9770072DFA4 /* ProgressIndicator.swift in Sources */, B0403CF02AD92D7B00137C09 /* ReleaseNotesView.swift in Sources */, diff --git a/Xcodes/Frontend/InfoPane/InfoPane.swift b/Xcodes/Frontend/InfoPane/InfoPane.swift index 962bbdd..f8753cf 100644 --- a/Xcodes/Frontend/InfoPane/InfoPane.swift +++ b/Xcodes/Frontend/InfoPane/InfoPane.swift @@ -35,13 +35,7 @@ struct InfoPane: View { } .xcodesBackground() - VStack { - Text("Platforms") - .font(.title3) - .frame(maxWidth: .infinity, alignment: .leading) - PlatformsView(xcode: xcode) - } - .xcodesBackground() + PlatformsView(xcode: xcode) } .frame(minWidth: 380) diff --git a/Xcodes/Frontend/InfoPane/PlatformsView.swift b/Xcodes/Frontend/InfoPane/PlatformsView.swift index 44aacae..6e0b9a1 100644 --- a/Xcodes/Frontend/InfoPane/PlatformsView.swift +++ b/Xcodes/Frontend/InfoPane/PlatformsView.swift @@ -11,7 +11,8 @@ import XcodesKit struct PlatformsView: View { @EnvironmentObject var appState: AppState - + @AppStorage("selectedRuntimeArchitecture") private var selectedRuntimeArchitecture: RuntimeArchitecture = .arm64 + let xcode: Xcode var body: some View { @@ -19,17 +20,50 @@ struct PlatformsView: View { let builds = xcode.sdks?.allBuilds() let runtimes = builds?.flatMap { sdkBuild in appState.downloadableRuntimes.filter { - $0.sdkBuildUpdate?.contains(sdkBuild) ?? false + $0.sdkBuildUpdate?.contains(sdkBuild) ?? false && + ($0.architectures?.isEmpty ?? true || + $0.architectures?.contains(selectedRuntimeArchitecture.rawValue) ?? false) } } - - ForEach(runtimes ?? [], id: \.identifier) { runtime in - runtimeView(runtime: runtime) - .frame(minWidth: 200) - .padding() - .background(.quinary) - .clipShape(RoundedRectangle(cornerRadius: 5, style: .continuous)) + + let architectures = Set((runtimes ?? []).flatMap { $0.architectures ?? [] }) + + VStack { + HStack { + Text("Platforms") + .font(.title3) + .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.displayValue, systemImage: "m4.button.horizontal") + .labelStyle(.trailingIcon) + case .x86_64: + Label(selectedRuntimeArchitecture.displayValue, systemImage: "cpu.fill") + .labelStyle(.trailingIcon) + } + } + } + } + + ForEach(runtimes ?? [], id: \.identifier) { runtime in + runtimeView(runtime: runtime) + .frame(minWidth: 200) + .padding() + .background(.quinary) + .clipShape(RoundedRectangle(cornerRadius: 5, style: .continuous)) + } } + .xcodesBackground() + + } @ViewBuilder diff --git a/Xcodes/Frontend/InfoPane/RuntimeArchitecture.swift b/Xcodes/Frontend/InfoPane/RuntimeArchitecture.swift new file mode 100644 index 0000000..abbdf45 --- /dev/null +++ b/Xcodes/Frontend/InfoPane/RuntimeArchitecture.swift @@ -0,0 +1,17 @@ +// +// RuntimeArchitecture.swift +// Xcodes +// +// Created by Matt Kiazyk on 2025-07-07. +// + +enum RuntimeArchitecture: String, CaseIterable, Identifiable { + case arm64 + case x86_64 + + var id: Self { self } + + var displayValue: String { + return rawValue + } +}