Skip to content

Commit 05f5c2c

Browse files
committed
rebase main
1 parent cecceea commit 05f5c2c

3 files changed

Lines changed: 111 additions & 49 deletions

File tree

Xcodes.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
63EAA4EB259944450046AB8F /* ProgressButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63EAA4EA259944450046AB8F /* ProgressButton.swift */; };
1616
B0403CF02AD92D7B00137C09 /* ReleaseNotesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0403CEF2AD92D7B00137C09 /* ReleaseNotesView.swift */; };
1717
B0403CF22AD934B600137C09 /* CompatibilityView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0403CF12AD934B600137C09 /* CompatibilityView.swift */; };
18+
B0403CF42AD9381D00137C09 /* SDKsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0403CF32AD9381D00137C09 /* SDKsView.swift */; };
1819
B0C6AD042AD6E65700E64698 /* ReleaseDateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0C6AD032AD6E65700E64698 /* ReleaseDateView.swift */; };
1920
B0C6AD0B2AD9178E00E64698 /* IdenticalBuildView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0C6AD0A2AD9178E00E64698 /* IdenticalBuildView.swift */; };
2021
B0C6AD0D2AD91D7900E64698 /* IconView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0C6AD0C2AD91D7900E64698 /* IconView.swift */; };
@@ -199,6 +200,7 @@
199200
AB4EB0DE28541FA000FF3B1D /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Localizable.strings; sourceTree = "<group>"; };
200201
B0403CEF2AD92D7B00137C09 /* ReleaseNotesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReleaseNotesView.swift; sourceTree = "<group>"; };
201202
B0403CF12AD934B600137C09 /* CompatibilityView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompatibilityView.swift; sourceTree = "<group>"; };
203+
B0403CF32AD9381D00137C09 /* SDKsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SDKsView.swift; sourceTree = "<group>"; };
202204
B0C6AD032AD6E65700E64698 /* ReleaseDateView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReleaseDateView.swift; sourceTree = "<group>"; };
203205
B0C6AD0A2AD9178E00E64698 /* IdenticalBuildView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IdenticalBuildView.swift; sourceTree = "<group>"; };
204206
B0C6AD0C2AD91D7900E64698 /* IconView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IconView.swift; sourceTree = "<group>"; };
@@ -626,6 +628,7 @@
626628
isa = PBXGroup;
627629
children = (
628630
B0403CEF2AD92D7B00137C09 /* ReleaseNotesView.swift */,
631+
B0403CF32AD9381D00137C09 /* SDKsView.swift */,
629632
B0403CF12AD934B600137C09 /* CompatibilityView.swift */,
630633
CAFBDC67259A308B003DCC5A /* InfoPane.swift */,
631634
E8E98A9525D863D700EC89A0 /* InstallationStepDetailView.swift */,
@@ -902,6 +905,7 @@
902905
CABFAA2D2592FBFC00380FEE /* Configure.swift in Sources */,
903906
CA73510D257BFCEF00EA9CF8 /* NSAttributedString+.swift in Sources */,
904907
CAFBDB952598FE96003DCC5A /* FocusedValues.swift in Sources */,
908+
B0403CF42AD9381D00137C09 /* SDKsView.swift in Sources */,
905909
CAC9F92D25BCDA4400B4965F /* HelperInstallState.swift in Sources */,
906910
E87DD6EB25D053FA00D86808 /* Progress+.swift in Sources */,
907911
CAC281CD259F97FA00B8AB0B /* ObservingProgressIndicator.swift in Sources */,

Xcodes/Frontend/InfoPane/InfoPane.swift

Lines changed: 26 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import AppKit
22
import Path
33
import SwiftUI
44
import Version
5-
import struct XCModel.SDKs
65
import struct XCModel.Compilers
6+
import struct XCModel.SDKs
77

88
struct InfoPane: View {
99
@EnvironmentObject var appState: AppState
@@ -18,12 +18,12 @@ struct InfoPane: View {
1818

1919
Text(verbatim: "Xcode \(xcode.description) \(xcode.version.buildMetadataIdentifiersDisplay)")
2020
.font(.title)
21-
21+
2222
switch xcode.installState {
2323
case .notInstalled:
2424
InstallButton(xcode: xcode)
2525
downloadFileSize(for: xcode)
26-
case .installing(let installationStep):
26+
case let .installing(installationStep):
2727
InstallationStepDetailView(installationStep: installationStep)
2828
.fixedSize(horizontal: false, vertical: true)
2929
CancelInstallButton(xcode: xcode)
@@ -36,32 +36,32 @@ struct InfoPane: View {
3636
.buttonStyle(PlainButtonStyle())
3737
.help("RevealInFinder")
3838
}
39-
39+
4040
HStack {
4141
SelectButton(xcode: xcode)
4242
.disabled(xcode.selected)
4343
.help("Selected")
44-
44+
4545
OpenButton(xcode: xcode)
4646
.help("Open")
47-
47+
4848
Spacer()
4949
UninstallButton(xcode: xcode)
5050
}
5151
}
52-
52+
5353
Divider()
5454

55-
Group{
55+
Group {
5656
ReleaseNotesView(url: xcode.releaseNotesURL)
5757
ReleaseDateView(date: xcode.releaseDate)
5858
.frame(maxWidth: .infinity, alignment: .leading)
5959
IdenticalBuildsView(builds: xcode.identicalBuilds)
6060
CompatibilityView(requiredMacOSVersion: xcode.requiredMacOSVersion)
61-
sdks(for: xcode)
61+
SDKsView(sdks: xcode.sdks)
6262
compilers(for: xcode)
6363
}
64-
64+
6565
Spacer()
6666
}
6767
.padding()
@@ -72,42 +72,15 @@ struct InfoPane: View {
7272
.frame(minWidth: 200, maxWidth: .infinity)
7373
}
7474
}
75-
76-
@ViewBuilder
77-
private func sdks(for xcode: Xcode) -> some View {
78-
if let sdks = xcode.sdks {
79-
VStack(alignment: .leading) {
80-
Text("SDKs")
81-
.font(.headline)
82-
.frame(maxWidth: .infinity, alignment: .leading)
83-
84-
ForEach([
85-
("macOS", \SDKs.macOS),
86-
("iOS", \.iOS),
87-
("watchOS", \.watchOS),
88-
("tvOS", \.tvOS),
89-
("visionOS", \.visionOS),
90-
], id: \.0) { row in
91-
if let sdk = sdks[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-
75+
10376
@ViewBuilder
10477
private func compilers(for xcode: Xcode) -> some View {
10578
if let compilers = xcode.compilers {
10679
VStack(alignment: .leading) {
10780
Text("Compilers")
10881
.font(.headline)
10982
.frame(maxWidth: .infinity, alignment: .leading)
110-
83+
11184
ForEach([
11285
("Swift", \Compilers.swift),
11386
("Clang", \.clang),
@@ -126,7 +99,7 @@ struct InfoPane: View {
12699
EmptyView()
127100
}
128101
}
129-
102+
130103
@ViewBuilder
131104
private func downloadFileSize(for xcode: Xcode) -> some View {
132105
// if we've downloaded it no need to show the download size
@@ -143,7 +116,7 @@ struct InfoPane: View {
143116
EmptyView()
144117
}
145118
}
146-
119+
147120
@ViewBuilder
148121
private var empty: some View {
149122
Text("NoXcodeSelected")
@@ -181,8 +154,8 @@ struct InfoPane_Previews: PreviewProvider {
181154
clang: .init(number: "7.3"),
182155
swift: .init(number: "5.3.2")
183156
),
184-
downloadFileSize: 242342424
185-
)
157+
downloadFileSize: 242_342_424
158+
),
186159
]
187160
})
188161
.previewDisplayName("Populated, Installed, Selected")
@@ -208,7 +181,8 @@ struct InfoPane_Previews: PreviewProvider {
208181
clang: .init(number: "7.3"),
209182
swift: .init(number: "5.3.2")
210183
),
211-
downloadFileSize: 242342424)
184+
downloadFileSize: 242_342_424
185+
),
212186
]
213187
})
214188
.previewDisplayName("Populated, Installed, Unselected")
@@ -234,7 +208,8 @@ struct InfoPane_Previews: PreviewProvider {
234208
clang: .init(number: "7.3"),
235209
swift: .init(number: "5.3.2")
236210
),
237-
downloadFileSize: 242342424)
211+
downloadFileSize: 242_342_424
212+
),
238213
]
239214
})
240215
.previewDisplayName("Populated, Uninstalled")
@@ -248,7 +223,8 @@ struct InfoPane_Previews: PreviewProvider {
248223
selected: false,
249224
icon: nil,
250225
sdks: nil,
251-
compilers: nil)
226+
compilers: nil
227+
),
252228
]
253229
})
254230
.previewDisplayName("Basic, installed")
@@ -258,15 +234,16 @@ struct InfoPane_Previews: PreviewProvider {
258234
$0.allXcodes = [
259235
.init(
260236
version: Version(major: 12, minor: 3, patch: 1, buildMetadataIdentifiers: ["1234A"]),
261-
installState: .installing(.downloading(progress: configure(Progress(totalUnitCount: 100)) { $0.completedUnitCount = 40; $0.throughput = 232323232; $0.fileCompletedCount = 2323004; $0.fileTotalCount = 1193939393 })),
237+
installState: .installing(.downloading(progress: configure(Progress(totalUnitCount: 100)) { $0.completedUnitCount = 40; $0.throughput = 232_323_232; $0.fileCompletedCount = 2_323_004; $0.fileTotalCount = 1_193_939_393 })),
262238
selected: false,
263239
icon: nil,
264240
sdks: nil,
265-
compilers: nil)
241+
compilers: nil
242+
),
266243
]
267244
})
268245
.previewDisplayName("Basic, installing")
269-
246+
270247
InfoPane(selectedXcodeID: nil)
271248
.environmentObject(configure(AppState()) {
272249
$0.allXcodes = [
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
//
2+
// SDKsView.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.SDKs
11+
12+
struct SDKsView: View {
13+
let sdks: SDKs?
14+
15+
var body: some View {
16+
if let sdks = sdks {
17+
VStack(alignment: .leading) {
18+
Text("SDKs").font(.headline)
19+
Text(Self.content(from: sdks)).font(.subheadline)
20+
}
21+
} else {
22+
EmptyView()
23+
}
24+
}
25+
26+
static private func content(from sdks: SDKs) -> String {
27+
let content: String = [
28+
("macOS", sdks.macOS),
29+
("iOS", sdks.iOS),
30+
("watchOS", sdks.watchOS),
31+
("tvOS", sdks.tvOS)
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+
return content
46+
}
47+
}
48+
49+
struct SDKsView_Preview: PreviewProvider {
50+
static var previews: some View {
51+
WrapperView()
52+
}
53+
}
54+
55+
private struct WrapperView: View {
56+
@State var isNil = false
57+
var sdks: SDKs? {
58+
isNil
59+
? nil
60+
: SDKs(macOS: .init(number: "11.1"),
61+
iOS: .init(number: "14.3"),
62+
watchOS: .init(number: "7.3"),
63+
tvOS: .init(number: "14.3"))
64+
}
65+
66+
var body: some View {
67+
VStack {
68+
HStack {
69+
SDKsView(sdks: sdks)
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+
}

0 commit comments

Comments
 (0)