forked from XcodesOrg/XcodesApp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into matt/runtimeDownload
- Loading branch information
Showing
18 changed files
with
743 additions
and
460 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// CompatibilityView.swift | ||
// Xcodes | ||
// | ||
// Created by Duong Thai on 13/10/2023. | ||
// Copyright © 2023 Robots and Pencils. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct CompatibilityView: View { | ||
let requiredMacOSVersion: String? | ||
|
||
var body: some View { | ||
if let requiredMacOSVersion = requiredMacOSVersion { | ||
VStack(alignment: .leading) { | ||
Text("Compatibility") | ||
.font(.headline) | ||
Text(String(format: localizeString("MacOSRequirement"), requiredMacOSVersion)) | ||
.font(.subheadline) | ||
} | ||
} else { | ||
EmptyView() | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
CompatibilityView(requiredMacOSVersion: "10.15.4") | ||
.padding() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// CompilersView.swift | ||
// Xcodes | ||
// | ||
// Created by Duong Thai on 13/10/2023. | ||
// Copyright © 2023 Robots and Pencils. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import struct XCModel.Compilers | ||
|
||
struct CompilersView: View { | ||
let compilers: Compilers? | ||
|
||
var body: some View { | ||
if let compilers = compilers { | ||
VStack(alignment: .leading) { | ||
Text("Compilers").font(.headline) | ||
Text(Self.content(from: compilers)).font(.subheadline) | ||
} | ||
} else { | ||
EmptyView() | ||
} | ||
} | ||
|
||
static func content(from compilers: Compilers) -> String { | ||
[ ("Swift", compilers.swift), | ||
("Clang", compilers.clang), | ||
("LLVM", compilers.llvm), | ||
("LLVM GCC", compilers.llvm_gcc), | ||
("GCC", compilers.gcc) | ||
].compactMap { // remove nil compiler | ||
guard $0.1 != nil, // has version array | ||
!$0.1!.isEmpty // has at least 1 version | ||
else { return nil } | ||
|
||
let numbers = $0.1!.compactMap { $0.number } // remove nil number | ||
guard !numbers.isEmpty // has at least 1 number | ||
else { return nil } | ||
|
||
// description for each type of compilers | ||
return "\($0.0): \(numbers.joined(separator: ", "))" | ||
}.joined(separator: "\n") | ||
} | ||
} | ||
|
||
#Preview { | ||
let compilers = Compilers( | ||
gcc: .init(number: "4"), | ||
llvm_gcc: .init(number: "213"), | ||
llvm: .init(number: "2.3"), | ||
clang: .init(number: "7.3"), | ||
swift: .init(number: "5.3.2") | ||
) | ||
|
||
return CompilersView(compilers: compilers) | ||
.padding() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// IconView.swift | ||
// Xcodes | ||
// | ||
// Created by Duong Thai on 11/10/2023. | ||
// Copyright © 2023 Robots and Pencils. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import Path | ||
|
||
struct IconView: View { | ||
let installState: XcodeInstallState | ||
|
||
var body: some View { | ||
if case let .installed(path) = installState { | ||
Image(nsImage: NSWorkspace.shared.icon(forFile: path.string)) | ||
} else { | ||
Image(systemName: "app.fill") | ||
.resizable() | ||
.frame(width: 32, height: 32) | ||
.foregroundColor(.secondary) | ||
} | ||
} | ||
} | ||
|
||
#Preview("Installed") { | ||
IconView(installState: XcodeInstallState.installed(Path("/Applications/Xcode.app")!)) | ||
.frame(width: 300, height: 100) | ||
.padding() | ||
} | ||
|
||
#Preview("Not Installed") { | ||
IconView(installState: XcodeInstallState.notInstalled) | ||
.frame(width: 300, height: 100) | ||
.padding() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// | ||
// IdenticalBuildView.swift | ||
// Xcodes | ||
// | ||
// Created by Duong Thai on 11/10/2023. | ||
// Copyright © 2023 Robots and Pencils. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import Version | ||
|
||
struct IdenticalBuildsView: View { | ||
let builds: [Version] | ||
private let isEmpty: Bool | ||
private let accessibilityDescription: String | ||
|
||
var body: some View { | ||
if isEmpty { | ||
EmptyView() | ||
} else { | ||
VStack(alignment: .leading) { | ||
HStack { | ||
Text("IdenticalBuilds") | ||
Image(systemName: "square.fill.on.square.fill") | ||
.foregroundColor(.secondary) | ||
.accessibility(hidden: true) | ||
.help("IdenticalBuilds.help") | ||
} | ||
.font(.headline) | ||
|
||
ForEach(builds, id: \.description) { version in | ||
Text("• \(version.appleDescription)") | ||
.font(.subheadline) | ||
} | ||
} | ||
.accessibilityElement() | ||
.accessibility(label: Text("IdenticalBuilds")) | ||
.accessibility(value: Text(accessibilityDescription)) | ||
.accessibility(hint: Text("IdenticalBuilds.help")) | ||
} | ||
} | ||
|
||
init(builds: [Version]) { | ||
self.builds = builds | ||
self.isEmpty = builds.isEmpty | ||
self.accessibilityDescription = builds | ||
.map(\.appleDescription) | ||
.joined(separator: ", ") | ||
} | ||
} | ||
|
||
let builds: [Version] = [.init(xcodeVersion: "15.0")!, .init(xcodeVersion: "15.1")!] | ||
|
||
#Preview("Has Some Builds") { | ||
IdenticalBuildsView(builds: builds) | ||
.padding() | ||
} | ||
|
||
#Preview("No Build") { | ||
IdenticalBuildsView(builds: []) | ||
.padding() | ||
} |
Oops, something went wrong.