Skip to content

Commit e56d83d

Browse files
committed
move identical builds view to IdenticalBuildView.swift
1 parent 7079e06 commit e56d83d

3 files changed

Lines changed: 88 additions & 29 deletions

File tree

Xcodes.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
53CBAB2C263DCC9100410495 /* XcodesAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53CBAB2B263DCC9100410495 /* XcodesAlert.swift */; };
1515
63EAA4EB259944450046AB8F /* ProgressButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63EAA4EA259944450046AB8F /* ProgressButton.swift */; };
1616
B0C6AD042AD6E65700E64698 /* ReleaseDateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0C6AD032AD6E65700E64698 /* ReleaseDateView.swift */; };
17+
B0C6AD0B2AD9178E00E64698 /* IdenticalBuildView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0C6AD0A2AD9178E00E64698 /* IdenticalBuildView.swift */; };
1718
CA11E7BA2598476C00D2EE1C /* XcodeCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA11E7B92598476C00D2EE1C /* XcodeCommands.swift */; };
1819
CA2518EC25A7FF2B00F08414 /* AppStateUpdateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA2518EB25A7FF2B00F08414 /* AppStateUpdateTests.swift */; };
1920
CA25192A25A9644800F08414 /* XcodeInstallState.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA25192925A9644800F08414 /* XcodeInstallState.swift */; };
@@ -194,6 +195,7 @@
194195
AAB037D32839BD4700017680 /* ko */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ko; path = ko.lproj/Localizable.strings; sourceTree = "<group>"; };
195196
AB4EB0DE28541FA000FF3B1D /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Localizable.strings; sourceTree = "<group>"; };
196197
B0C6AD032AD6E65700E64698 /* ReleaseDateView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReleaseDateView.swift; sourceTree = "<group>"; };
198+
B0C6AD0A2AD9178E00E64698 /* IdenticalBuildView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IdenticalBuildView.swift; sourceTree = "<group>"; };
197199
B648F22B2810C1130096781B /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = "<group>"; };
198200
C0AE7FA4283002DC00DA63D2 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = "<group>"; };
199201
CA11E7B92598476C00D2EE1C /* XcodeCommands.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XcodeCommands.swift; sourceTree = "<group>"; };
@@ -620,6 +622,7 @@
620622
CAFBDC67259A308B003DCC5A /* InfoPane.swift */,
621623
E8E98A9525D863D700EC89A0 /* InstallationStepDetailView.swift */,
622624
B0C6AD032AD6E65700E64698 /* ReleaseDateView.swift */,
625+
B0C6AD0A2AD9178E00E64698 /* IdenticalBuildView.swift */,
623626
);
624627
path = InfoPane;
625628
sourceTree = "<group>";
@@ -891,6 +894,7 @@
891894
E87DD6EB25D053FA00D86808 /* Progress+.swift in Sources */,
892895
CAC281CD259F97FA00B8AB0B /* ObservingProgressIndicator.swift in Sources */,
893896
CABFA9C22592EEEA00380FEE /* Publisher+Resumable.swift in Sources */,
897+
B0C6AD0B2AD9178E00E64698 /* IdenticalBuildView.swift in Sources */,
894898
CAFBDC68259A308B003DCC5A /* InfoPane.swift in Sources */,
895899
E87AB3C52939B65E00D72F43 /* Hardware.swift in Sources */,
896900
CAA1CB4D255A5CFD003FD669 /* SignInPhoneListView.swift in Sources */,
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
//
2+
// IdenticalBuildView.swift
3+
// Xcodes
4+
//
5+
// Created by Duong Thai on 11/10/2023.
6+
// Copyright © 2023 Robots and Pencils. All rights reserved.
7+
//
8+
9+
import SwiftUI
10+
import Version
11+
12+
struct IdenticalBuildsView: View {
13+
let builds: [Version]
14+
private let isEmpty: Bool
15+
private let accessibilityDescription: String
16+
17+
var body: some View {
18+
if isEmpty {
19+
EmptyView()
20+
} else {
21+
VStack(alignment: .leading) {
22+
HStack {
23+
Text("IdenticalBuilds")
24+
Image(systemName: "square.fill.on.square.fill")
25+
.foregroundColor(.secondary)
26+
.accessibility(hidden: true)
27+
.help("IdenticalBuilds.help")
28+
}
29+
.font(.headline)
30+
31+
ForEach(builds, id: \.description) { version in
32+
Text("\(version.appleDescription)")
33+
.font(.subheadline)
34+
}
35+
}
36+
.frame(maxWidth: .infinity, alignment: .leading)
37+
.accessibilityElement()
38+
.accessibility(label: Text("IdenticalBuilds"))
39+
.accessibility(value: Text(accessibilityDescription))
40+
.accessibility(hint: Text("IdenticalBuilds.help"))
41+
}
42+
}
43+
44+
init(builds: [Version]) {
45+
self.builds = builds
46+
self.isEmpty = builds.isEmpty
47+
self.accessibilityDescription = builds
48+
.map(\.appleDescription)
49+
.joined(separator: ", ")
50+
}
51+
}
52+
53+
struct IdenticalBuildsView_Preview: PreviewProvider {
54+
static var previews: some View {
55+
WrapperView()
56+
}
57+
}
58+
59+
private struct WrapperView: View {
60+
@State var isEmpty = false
61+
var builds: [Version] {
62+
isEmpty
63+
? []
64+
: [.init(xcodeVersion: "15.0")!,
65+
.init(xcodeVersion: "15.1")!]
66+
}
67+
68+
var body: some View {
69+
VStack {
70+
HStack {
71+
IdenticalBuildsView(builds: builds)
72+
.border(.red)
73+
}
74+
Spacer()
75+
Toggle(isOn: $isEmpty) {
76+
Text("Is Empty?")
77+
}
78+
}
79+
.animation(.default)
80+
.frame(width: 300, height: 100)
81+
.padding()
82+
}
83+
}

Xcodes/Frontend/InfoPane/InfoPane.swift

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct InfoPane: View {
5757
releaseNotes(for: xcode)
5858
ReleaseDateView(date: xcode.releaseDate)
5959
.frame(maxWidth: .infinity, alignment: .leading)
60-
identicalBuilds(for: xcode)
60+
IdenticalBuildsView(builds: xcode.identicalBuilds)
6161
compatibility(for: xcode)
6262
sdks(for: xcode)
6363
compilers(for: xcode)
@@ -86,34 +86,6 @@ struct InfoPane: View {
8686
}
8787
}
8888

89-
@ViewBuilder
90-
private func identicalBuilds(for xcode: Xcode) -> some View {
91-
if !xcode.identicalBuilds.isEmpty {
92-
VStack(alignment: .leading) {
93-
HStack {
94-
Text("IdenticalBuilds")
95-
Image(systemName: "square.fill.on.square.fill")
96-
.foregroundColor(.secondary)
97-
.accessibility(hidden: true)
98-
.help("IdenticalBuilds.help")
99-
}
100-
.font(.headline)
101-
102-
ForEach(xcode.identicalBuilds, id: \.description) { version in
103-
Text("\(version.appleDescription)")
104-
.font(.subheadline)
105-
}
106-
}
107-
.frame(maxWidth: .infinity, alignment: .leading)
108-
.accessibilityElement()
109-
.accessibility(label: Text("IdenticalBuilds"))
110-
.accessibility(value: Text(xcode.identicalBuilds.map(\.appleDescription).joined(separator: ", ")))
111-
.accessibility(hint: Text("IdenticalBuilds.help"))
112-
} else {
113-
EmptyView()
114-
}
115-
}
116-
11789
@ViewBuilder
11890
private func releaseNotes(for xcode: Xcode) -> some View {
11991
if let releaseNotesURL = xcode.releaseNotesURL {

0 commit comments

Comments
 (0)