Merge pull request #530 from huihuisang/feature/replace-default-icon-in-info

replace default icon in info page
This commit is contained in:
Matt Kiazyk 2024-03-16 18:52:11 -05:00 committed by GitHub
commit dbf30000ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 11 deletions

View file

@ -6,17 +6,18 @@
// Copyright © 2023 Robots and Pencils. All rights reserved.
//
import SwiftUI
import Path
import SwiftUI
import Version
struct IconView: View {
let installState: XcodeInstallState
let xcode: Xcode
var body: some View {
if case let .installed(path) = installState {
if case let .installed(path) = xcode.installState {
Image(nsImage: NSWorkspace.shared.icon(forFile: path.string))
} else {
Image(systemName: "app.fill")
Image(xcode.version.isPrerelease ? "xcode-beta" : "xcode")
.resizable()
.frame(width: 32, height: 32)
.foregroundColor(.secondary)
@ -25,13 +26,19 @@ struct IconView: View {
}
#Preview("Installed") {
IconView(installState: XcodeInstallState.installed(Path("/Applications/Xcode.app")!))
IconView(xcode: Xcode(version: Version("12.3.0")!, installState: .installed(Path("/Applications/Xcode-12.3.0.app")!), selected: true, icon: nil))
.frame(width: 300, height: 100)
.padding()
}
#Preview("Installed") {
IconView(xcode: Xcode(version: Version("12.3.0")!, installState: .notInstalled, selected: true, icon: nil))
.frame(width: 300, height: 100)
.padding()
}
#Preview("Not Installed") {
IconView(installState: XcodeInstallState.notInstalled)
IconView(xcode: Xcode(version: Version("12.0.0-1234A")!, installState: .notInstalled, selected: false, icon: nil))
.frame(width: 300, height: 100)
.padding()
}

View file

@ -14,7 +14,7 @@ struct InfoPane: View {
VStack {
VStack(spacing: 5) {
HStack {
IconView(installState: xcode.installState)
IconView(xcode: xcode)
Text(verbatim: "Xcode \(xcode.description) \(xcode.version.buildMetadataIdentifiersDisplay)")
.font(.title)