Merge pull request #73 from RobotsAndPencils/matt/fixbuildMetadataIdentifiers

Don't show brackets when buildMetadataIdentifiers is empty
This commit is contained in:
Brandon Evans 2021-01-21 08:18:48 -07:00 committed by GitHub
commit d834f3ed74
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 4 deletions

View file

@ -47,5 +47,9 @@ extension Version {
self.init(versionString)
}
var buildMetadataIdentifiersDisplay: String {
return !buildMetadataIdentifiers.isEmpty ? "(\(buildMetadataIdentifiers.joined(separator: " ")))" : ""
}
}

View file

@ -17,7 +17,7 @@ struct InfoPane: View {
icon(for: xcode)
VStack(alignment: .leading) {
Text(verbatim: "Xcode \(xcode.description) (\(xcode.version.buildMetadataIdentifiers.joined(separator: " ")))")
Text(verbatim: "Xcode \(xcode.description) \(xcode.version.buildMetadataIdentifiersDisplay)")
.font(.title)
.frame(maxWidth: .infinity, alignment: .leading)
@ -254,11 +254,11 @@ struct InfoPane_Previews: PreviewProvider {
})
.previewDisplayName("Populated, Uninstalled")
InfoPane(selectedXcodeID: Version(major: 12, minor: 3, patch: 0))
InfoPane(selectedXcodeID: Version(major: 12, minor: 3, patch: 1, buildMetadataIdentifiers: ["1234A"]))
.environmentObject(configure(AppState()) {
$0.allXcodes = [
.init(
version: Version(major: 12, minor: 3, patch: 0),
version: Version(major: 12, minor: 3, patch: 1, buildMetadataIdentifiers: ["1234A"]),
installState: .installed(Path("/Applications/Xcode-12.3.0.app")!),
selected: false,
icon: nil,

View file

@ -12,7 +12,7 @@ struct XcodeListViewRow: View {
appIconView(for: xcode)
VStack(alignment: .leading) {
Text(verbatim: "\(xcode.description) (\(xcode.version.buildMetadataIdentifiers.joined(separator: " ")))")
Text(verbatim: "\(xcode.description) \(xcode.version.buildMetadataIdentifiersDisplay)")
.font(.body)
if case let .installed(path) = xcode.installState {
@ -122,6 +122,11 @@ struct XcodeListViewRow_Previews: PreviewProvider {
xcode: Xcode(version: Version("12.0.0")!, installState: .installed(Path("/Applications/Xcode-12.3.0.app")!), selected: false, icon: nil),
selected: false
)
XcodeListViewRow(
xcode: Xcode(version: Version("12.0.0+1234A")!, installState: .installed(Path("/Applications/Xcode-12.3.0.app")!), selected: false, icon: nil),
selected: false
)
}
.environmentObject(AppState())
}