Add releasePlusNewBetas XcodeListCategory

This adds a new filter option that shows only releases, plus any betas that do not have a release version. So as of today (July 7, 2023 the Xcode 15 betas will be shown but the Xcode 14 betas won't. Note that this will also show betas for older Xcode versions if necessary, for example if an Xcode 14.3.2 beta is released it will be shown until the mainline Xcode 14.3.2 is released.
This commit is contained in:
Jayson Rhynas 2023-07-07 10:33:25 -04:00
parent 9cf10125ca
commit 98d1d30328
5 changed files with 30 additions and 1 deletions

View file

@ -31,4 +31,9 @@ public extension Version {
var isPrerelease: Bool { prereleaseIdentifiers.isEmpty == false }
var isNotPrerelease: Bool { prereleaseIdentifiers.isEmpty == true }
/// Returns a new Version instance without any `prereleaseIdentifiers` or `buildMetadataIdentifiers`
func withoutIdentifiers() -> Version {
Version(major, minor, patch)
}
}

View file

@ -32,7 +32,8 @@ struct MainToolbarModifier: ViewModifier {
switch category {
case .all: category = .release
case .release: category = .beta
case .beta: category = .all
case .beta: category = .releasePlusNewBetas
case .releasePlusNewBetas: category = .all
}
}) {
switch category {
@ -58,6 +59,16 @@ struct MainToolbarModifier: ViewModifier {
.labelStyle(TitleOnlyLabelStyle())
.foregroundColor(.accentColor)
}
case .releasePlusBeta:
if #available(macOS 11.3, *) {
Label("ReleasePlusBetaOnly", systemImage: "line.horizontal.3.decrease.circle.fill")
.labelStyle(TitleAndIconLabelStyle())
.foregroundColor(.accentColor)
} else {
Label("ReleasePlusBetaOnly", systemImage: "line.horizontal.3.decrease.circle.fill")
.labelStyle(TitleOnlyLabelStyle())
.foregroundColor(.accentColor)
}
}
}
.help("FilterAvailableDescription")

View file

@ -4,6 +4,7 @@ enum XcodeListCategory: String, CaseIterable, Identifiable, CustomStringConverti
case all
case release
case beta
case releasePlusNewBetas
var id: Self { self }
@ -12,6 +13,7 @@ enum XcodeListCategory: String, CaseIterable, Identifiable, CustomStringConverti
case .all: return localizeString("All")
case .release: return localizeString("Release")
case .beta: return localizeString("Beta")
case .releasePlusNewBetas: return localizeString("ReleasePlusNewBetas")
}
}
}

View file

@ -25,6 +25,15 @@ struct XcodeListView: View {
xcodes = appState.allXcodes.filter { $0.version.isNotPrerelease }
case .beta:
xcodes = appState.allXcodes.filter { $0.version.isPrerelease }
case .releasePlusNewBetas:
let releases = Set(
appState.allXcodes
.filter(\.version.isNotPrerelease)
.map { $0.version.withoutIdentifiers() }
)
xcodes = appState.allXcodes.filter {
$0.version.isNotPrerelease || !releases.contains($0.version.withoutIdentifiers())
}
}
if !searchText.isEmpty {

View file

@ -144,6 +144,8 @@
"ReleaseOnly" = "Release only";
"Beta" = "Beta";
"BetaOnly" = "Beta only";
"ReleasePlusNewBetas" = "Release & New Betas";
"ReleasePlusNewBetasOnly" = "Release & New Betas Only";
"Filter" = "Filter";
"FilterAvailableDescription" = "Filter available versions";
"FilterInstalledDescription" = "Filter installed versions";