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 1 commit
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 @@ -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 {
Expand All @@ -58,6 +59,16 @@ struct MainToolbarModifier: ViewModifier {
.labelStyle(TitleOnlyLabelStyle())
.foregroundColor(.accentColor)
}
case .releasePlusBeta:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's some errors here around the name. Looks like you may have changed around the enum name and it's invalid here.

if #available(macOS 11.3, *) {
Label("ReleasePlusBetaOnly", systemImage: "line.horizontal.3.decrease.circle.fill")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This localized string does not exist

.labelStyle(TitleAndIconLabelStyle())
.foregroundColor(.accentColor)
} else {
Label("ReleasePlusBetaOnly", 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
2 changes: 2 additions & 0 deletions Xcodes/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@
"ReleaseOnly" = "Release only";
"Beta" = "Beta";
"BetaOnly" = "Beta only";
"ReleasePlusNewBetas" = "Release & New Betas";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I like this one better - the only word is kind of redundant

"ReleasePlusNewBetasOnly" = "Release & New Betas Only";
"Filter" = "Filter";
"FilterAvailableDescription" = "Filter available versions";
"FilterInstalledDescription" = "Filter installed versions";
Expand Down