Skip to content

Commit 112829b

Browse files
committed
rebase main
1 parent 05f5c2c commit 112829b

3 files changed

Lines changed: 87 additions & 28 deletions

File tree

Xcodes.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
B0403CF02AD92D7B00137C09 /* ReleaseNotesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0403CEF2AD92D7B00137C09 /* ReleaseNotesView.swift */; };
1717
B0403CF22AD934B600137C09 /* CompatibilityView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0403CF12AD934B600137C09 /* CompatibilityView.swift */; };
1818
B0403CF42AD9381D00137C09 /* SDKsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0403CF32AD9381D00137C09 /* SDKsView.swift */; };
19+
B0403CF62AD9849E00137C09 /* CompilersView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0403CF52AD9849E00137C09 /* CompilersView.swift */; };
1920
B0C6AD042AD6E65700E64698 /* ReleaseDateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0C6AD032AD6E65700E64698 /* ReleaseDateView.swift */; };
2021
B0C6AD0B2AD9178E00E64698 /* IdenticalBuildView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0C6AD0A2AD9178E00E64698 /* IdenticalBuildView.swift */; };
2122
B0C6AD0D2AD91D7900E64698 /* IconView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0C6AD0C2AD91D7900E64698 /* IconView.swift */; };
@@ -201,6 +202,7 @@
201202
B0403CEF2AD92D7B00137C09 /* ReleaseNotesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReleaseNotesView.swift; sourceTree = "<group>"; };
202203
B0403CF12AD934B600137C09 /* CompatibilityView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompatibilityView.swift; sourceTree = "<group>"; };
203204
B0403CF32AD9381D00137C09 /* SDKsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SDKsView.swift; sourceTree = "<group>"; };
205+
B0403CF52AD9849E00137C09 /* CompilersView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompilersView.swift; sourceTree = "<group>"; };
204206
B0C6AD032AD6E65700E64698 /* ReleaseDateView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReleaseDateView.swift; sourceTree = "<group>"; };
205207
B0C6AD0A2AD9178E00E64698 /* IdenticalBuildView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IdenticalBuildView.swift; sourceTree = "<group>"; };
206208
B0C6AD0C2AD91D7900E64698 /* IconView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IconView.swift; sourceTree = "<group>"; };
@@ -629,6 +631,7 @@
629631
children = (
630632
B0403CEF2AD92D7B00137C09 /* ReleaseNotesView.swift */,
631633
B0403CF32AD9381D00137C09 /* SDKsView.swift */,
634+
B0403CF52AD9849E00137C09 /* CompilersView.swift */,
632635
B0403CF12AD934B600137C09 /* CompatibilityView.swift */,
633636
CAFBDC67259A308B003DCC5A /* InfoPane.swift */,
634637
E8E98A9525D863D700EC89A0 /* InstallationStepDetailView.swift */,
@@ -921,6 +924,7 @@
921924
CAE424B4259A764700B8B246 /* AppState+Install.swift in Sources */,
922925
CAE42487259A68A300B8B246 /* XcodeListCategory.swift in Sources */,
923926
CAA858C425A2BE4E00ACF8C0 /* Downloader.swift in Sources */,
927+
B0403CF62AD9849E00137C09 /* CompilersView.swift in Sources */,
924928
E8977EA325C11E1500835F80 /* PreferencesView.swift in Sources */,
925929
CA9FF87B2595293E00E47BAF /* DataSource.swift in Sources */,
926930
CABFA9C92592EEEA00380FEE /* URLRequest+Apple.swift in Sources */,
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
//
2+
// CompilersView.swift
3+
// Xcodes
4+
//
5+
// Created by Duong Thai on 13/10/2023.
6+
// Copyright © 2023 Robots and Pencils. All rights reserved.
7+
//
8+
9+
import SwiftUI
10+
import struct XCModel.Compilers
11+
12+
struct CompilersView: View {
13+
let compilers: Compilers?
14+
15+
var body: some View {
16+
if let compilers = compilers {
17+
VStack(alignment: .leading) {
18+
Text("Compilers").font(.headline)
19+
Text(Self.content(from: compilers)).font(.subheadline)
20+
}
21+
} else {
22+
EmptyView()
23+
}
24+
}
25+
26+
static func content(from compilers: Compilers) -> String {
27+
[ ("Swift", compilers.swift),
28+
("Clang", compilers.clang),
29+
("LLVM", compilers.llvm),
30+
("LLVM GCC", compilers.llvm_gcc),
31+
("GCC", compilers.gcc)
32+
].compactMap { // remove nil compiler
33+
guard $0.1 != nil, // has version array
34+
!$0.1!.isEmpty // has at least 1 version
35+
else { return nil }
36+
37+
let numbers = $0.1!.compactMap { $0.number } // remove nil number
38+
guard !numbers.isEmpty // has at least 1 number
39+
else { return nil }
40+
41+
// description for each type of compilers
42+
return "\($0.0): \(numbers.joined(separator: ", "))"
43+
}.joined(separator: "\n")
44+
}
45+
}
46+
47+
struct CompilersView_Preview: PreviewProvider {
48+
static var previews: some View {
49+
WrapperView()
50+
}
51+
}
52+
53+
private struct WrapperView: View {
54+
@State var isNil = false
55+
var compilers: Compilers? {
56+
isNil
57+
? nil
58+
: Compilers(
59+
gcc: .init(number: "4"),
60+
llvm_gcc: .init(number: "213"),
61+
llvm: .init(number: "2.3"),
62+
clang: .init(number: "7.3"),
63+
swift: .init(number: "5.3.2"))
64+
}
65+
66+
var body: some View {
67+
VStack {
68+
HStack {
69+
CompilersView(compilers: compilers)
70+
.border(.red)
71+
}
72+
Spacer()
73+
Toggle(isOn: $isNil) {
74+
Text("Is Nil?")
75+
}
76+
}
77+
.animation(.default)
78+
.frame(width: 200, height: 100)
79+
.padding()
80+
}
81+
}
82+

Xcodes/Frontend/InfoPane/InfoPane.swift

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ struct InfoPane: View {
5959
IdenticalBuildsView(builds: xcode.identicalBuilds)
6060
CompatibilityView(requiredMacOSVersion: xcode.requiredMacOSVersion)
6161
SDKsView(sdks: xcode.sdks)
62-
compilers(for: xcode)
62+
CompilersView(compilers: xcode.compilers)
6363
}
6464

6565
Spacer()
@@ -73,33 +73,6 @@ struct InfoPane: View {
7373
}
7474
}
7575

76-
@ViewBuilder
77-
private func compilers(for xcode: Xcode) -> some View {
78-
if let compilers = xcode.compilers {
79-
VStack(alignment: .leading) {
80-
Text("Compilers")
81-
.font(.headline)
82-
.frame(maxWidth: .infinity, alignment: .leading)
83-
84-
ForEach([
85-
("Swift", \Compilers.swift),
86-
("Clang", \.clang),
87-
("LLVM", \.llvm),
88-
("LLVM GCC", \.llvm_gcc),
89-
("GCC", \.gcc),
90-
], id: \.0) { row in
91-
if let sdk = compilers[keyPath: row.1] {
92-
Text("\(row.0): \(sdk.compactMap { $0.number }.joined(separator: ", "))")
93-
.font(.subheadline)
94-
.frame(maxWidth: .infinity, alignment: .leading)
95-
}
96-
}
97-
}
98-
} else {
99-
EmptyView()
100-
}
101-
}
102-
10376
@ViewBuilder
10477
private func downloadFileSize(for xcode: Xcode) -> some View {
10578
// if we've downloaded it no need to show the download size

0 commit comments

Comments
 (0)