Skip to content

Commit 2f7d45c

Browse files
committed
move the control section to InfoPaneControls, fix the layout to make it self-contain
1 parent a237958 commit 2f7d45c

3 files changed

Lines changed: 79 additions & 15 deletions

File tree

Xcodes.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
B0403CF82AD991F800137C09 /* UnselectedView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0403CF72AD991F800137C09 /* UnselectedView.swift */; };
2121
B0403CFA2AD9942A00137C09 /* NotInstalledStateButtons.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0403CF92AD9942A00137C09 /* NotInstalledStateButtons.swift */; };
2222
B0403CFC2AD9A6BF00137C09 /* InstalledStateButtons.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0403CFB2AD9A6BF00137C09 /* InstalledStateButtons.swift */; };
23+
B0403CFE2ADA712C00137C09 /* InfoPaneControls.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0403CFD2ADA712C00137C09 /* InfoPaneControls.swift */; };
2324
B0C6AD042AD6E65700E64698 /* ReleaseDateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0C6AD032AD6E65700E64698 /* ReleaseDateView.swift */; };
2425
B0C6AD0B2AD9178E00E64698 /* IdenticalBuildView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0C6AD0A2AD9178E00E64698 /* IdenticalBuildView.swift */; };
2526
B0C6AD0D2AD91D7900E64698 /* IconView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0C6AD0C2AD91D7900E64698 /* IconView.swift */; };
@@ -209,6 +210,7 @@
209210
B0403CF72AD991F800137C09 /* UnselectedView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnselectedView.swift; sourceTree = "<group>"; };
210211
B0403CF92AD9942A00137C09 /* NotInstalledStateButtons.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotInstalledStateButtons.swift; sourceTree = "<group>"; };
211212
B0403CFB2AD9A6BF00137C09 /* InstalledStateButtons.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstalledStateButtons.swift; sourceTree = "<group>"; };
213+
B0403CFD2ADA712C00137C09 /* InfoPaneControls.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoPaneControls.swift; sourceTree = "<group>"; };
212214
B0C6AD032AD6E65700E64698 /* ReleaseDateView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReleaseDateView.swift; sourceTree = "<group>"; };
213215
B0C6AD0A2AD9178E00E64698 /* IdenticalBuildView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IdenticalBuildView.swift; sourceTree = "<group>"; };
214216
B0C6AD0C2AD91D7900E64698 /* IconView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IconView.swift; sourceTree = "<group>"; };
@@ -640,6 +642,7 @@
640642
B0403CF52AD9849E00137C09 /* CompilersView.swift */,
641643
B0403CF12AD934B600137C09 /* CompatibilityView.swift */,
642644
CAFBDC67259A308B003DCC5A /* InfoPane.swift */,
645+
B0403CFD2ADA712C00137C09 /* InfoPaneControls.swift */,
643646
B0403CF72AD991F800137C09 /* UnselectedView.swift */,
644647
B0403CF92AD9942A00137C09 /* NotInstalledStateButtons.swift */,
645648
B0403CFB2AD9A6BF00137C09 /* InstalledStateButtons.swift */,
@@ -895,6 +898,7 @@
895898
36741BFF291E50F500A85AAE /* FileError.swift in Sources */,
896899
CA9FF8872595607900E47BAF /* InstalledXcode.swift in Sources */,
897900
B0403CF22AD934B600137C09 /* CompatibilityView.swift in Sources */,
901+
B0403CFE2ADA712C00137C09 /* InfoPaneControls.swift in Sources */,
898902
53CBAB2C263DCC9100410495 /* XcodesAlert.swift in Sources */,
899903
CA42DD6E25AEA8B200BC0B0C /* Logger.swift in Sources */,
900904
CA61A6E0259835580008926E /* Xcode.swift in Sources */,

Xcodes/Frontend/InfoPane/InfoPane.swift

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,7 @@ struct InfoPane: View {
1717
Text(verbatim: "Xcode \(xcode.description) \(xcode.version.buildMetadataIdentifiersDisplay)")
1818
.font(.title)
1919

20-
switch xcode.installState {
21-
case .notInstalled:
22-
NotInstalledStateButtons(
23-
downloadFileSizeString: xcode.downloadFileSizeString,
24-
id: xcode.id
25-
)
26-
case let .installing(installationStep):
27-
InstallationStepDetailView(installationStep: installationStep)
28-
CancelInstallButton(xcode: xcode)
29-
case .installed:
30-
InstalledStateButtons(xcode: xcode)
31-
}
20+
InfoPaneControls(xcode: xcode)
3221

3322
Divider()
3423

@@ -79,7 +68,7 @@ private struct WrapperView: View {
7968
var xcode: Xcode { xcodeDict[name]! }
8069
}
8170

82-
private enum PreviewName: String, CaseIterable, Identifiable {
71+
enum PreviewName: String, CaseIterable, Identifiable {
8372
case Populated_Installed_Selected
8473
case Populated_Installed_Unselected
8574
case Populated_Uninstalled
@@ -89,7 +78,7 @@ private enum PreviewName: String, CaseIterable, Identifiable {
8978
var id: PreviewName { self }
9079
}
9180

92-
private var xcodeDict: [PreviewName: Xcode] = [
81+
var xcodeDict: [PreviewName: Xcode] = [
9382
.Populated_Installed_Selected: .init(
9483
version: _versionNoMeta,
9584
installState: .installed(Path(_path)!),
@@ -130,7 +119,16 @@ private var xcodeDict: [PreviewName: Xcode] = [
130119
),
131120
.Basic_Installing: .init(
132121
version: _versionWithMeta,
133-
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 })),
122+
installState: .installing(.downloading(
123+
progress: configure(Progress()) {
124+
$0.kind = .file
125+
$0.fileOperationKind = .downloading
126+
$0.estimatedTimeRemaining = 123
127+
$0.totalUnitCount = 11_944_848_484
128+
$0.completedUnitCount = 848_444_920
129+
$0.throughput = 9_211_681
130+
}
131+
)),
134132
selected: false,
135133
icon: nil,
136134
sdks: nil,
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//
2+
// InfoPaneControls.swift
3+
// Xcodes
4+
//
5+
// Created by Duong Thai on 14/10/2023.
6+
// Copyright © 2023 Robots and Pencils. All rights reserved.
7+
//
8+
9+
import SwiftUI
10+
11+
struct InfoPaneControls: View {
12+
let xcode: Xcode
13+
14+
var body: some View {
15+
VStack (alignment: .leading) {
16+
switch xcode.installState {
17+
case .notInstalled:
18+
NotInstalledStateButtons(
19+
downloadFileSizeString: xcode.downloadFileSizeString,
20+
id: xcode.id)
21+
case .installing(let installationStep):
22+
InstallationStepDetailView(installationStep: installationStep)
23+
CancelInstallButton(xcode: xcode)
24+
case .installed(_):
25+
InstalledStateButtons(xcode: xcode)
26+
}
27+
}
28+
}
29+
}
30+
31+
struct InfoPaneControls_Previews: PreviewProvider {
32+
static var previews: some View {
33+
WrapperView()
34+
}
35+
}
36+
37+
private struct WrapperView: View {
38+
@State var name: PreviewName = .Populated_Installed_Selected
39+
40+
var body: some View {
41+
VStack {
42+
InfoPaneControls(xcode: xcode)
43+
.environmentObject(configure(AppState()) {
44+
$0.allXcodes = [xcode]
45+
})
46+
.border(.red)
47+
.frame(width: 300, height: 400)
48+
Spacer()
49+
Picker("Preview Name", selection: $name) {
50+
ForEach(PreviewName.allCases) {
51+
Text($0.rawValue).tag($0)
52+
}
53+
}
54+
.pickerStyle(.inline)
55+
56+
}
57+
.frame(maxWidth: .infinity)
58+
.padding()
59+
}
60+
61+
var xcode: Xcode { xcodeDict[name]! }
62+
}

0 commit comments

Comments
 (0)