Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add releasePlusNewBetas XcodeListCategory #403

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions Xcodes/Backend/Version+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
13 changes: 12 additions & 1 deletion Xcodes/Frontend/XcodeList/MainToolbar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,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 {
Expand All @@ -53,6 +54,16 @@ struct MainToolbarModifier: ViewModifier {
.labelStyle(TitleOnlyLabelStyle())
.foregroundColor(.accentColor)
}
case .releasePlusNewBetas:
if #available(macOS 11.3, *) {
Label("ReleasePlusNewBetas", systemImage: "line.horizontal.3.decrease.circle.fill")
.labelStyle(TitleAndIconLabelStyle())
.foregroundColor(.accentColor)
} else {
Label("ReleasePlusNewBetas", systemImage: "line.horizontal.3.decrease.circle.fill")
.labelStyle(TitleOnlyLabelStyle())
.foregroundColor(.accentColor)
}
}
}
.help("FilterAvailableDescription")
Expand Down
2 changes: 2 additions & 0 deletions Xcodes/Frontend/XcodeList/XcodeListCategory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ enum XcodeListCategory: String, CaseIterable, Identifiable, CustomStringConverti
case all
case release
case beta
case releasePlusNewBetas

var id: Self { self }

Expand All @@ -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")
}
}
}
9 changes: 9 additions & 0 deletions Xcodes/Frontend/XcodeList/XcodeListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 11 additions & 0 deletions Xcodes/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -15955,6 +15955,17 @@
}
}
},
"ReleasePlusNewBetas" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Release & New Betas"
}
}
}
},
"Required" : {
"localizations" : {
"ca" : {
Expand Down