Skip to content

Commit

Permalink
Merge pull request #530 from huihuisang/feature/replace-default-icon-…
Browse files Browse the repository at this point in the history
…in-info

replace default icon in info page
  • Loading branch information
MattKiazyk authored Mar 16, 2024
2 parents 7359ae1 + f4c9a6d commit dbf3000
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
27 changes: 17 additions & 10 deletions Xcodes/Frontend/InfoPane/IconView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -25,13 +26,19 @@ struct IconView: View {
}

#Preview("Installed") {
IconView(installState: XcodeInstallState.installed(Path("/Applications/Xcode.app")!))
.frame(width: 300, height: 100)
.padding()
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)
.frame(width: 300, height: 100)
.padding()
IconView(xcode: Xcode(version: Version("12.0.0-1234A")!, installState: .notInstalled, selected: false, icon: nil))
.frame(width: 300, height: 100)
.padding()
}
2 changes: 1 addition & 1 deletion Xcodes/Frontend/InfoPane/InfoPane.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit dbf3000

Please sign in to comment.