mirror of
https://github.com/XcodesOrg/XcodesApp.git
synced 2026-03-25 08:55:46 +00:00
move the control section to InfoPaneControls, fix the layout to make it self-contain
This commit is contained in:
parent
a2379583ef
commit
2f7d45c67a
3 changed files with 79 additions and 15 deletions
|
|
@ -20,6 +20,7 @@
|
|||
B0403CF82AD991F800137C09 /* UnselectedView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0403CF72AD991F800137C09 /* UnselectedView.swift */; };
|
||||
B0403CFA2AD9942A00137C09 /* NotInstalledStateButtons.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0403CF92AD9942A00137C09 /* NotInstalledStateButtons.swift */; };
|
||||
B0403CFC2AD9A6BF00137C09 /* InstalledStateButtons.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0403CFB2AD9A6BF00137C09 /* InstalledStateButtons.swift */; };
|
||||
B0403CFE2ADA712C00137C09 /* InfoPaneControls.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0403CFD2ADA712C00137C09 /* InfoPaneControls.swift */; };
|
||||
B0C6AD042AD6E65700E64698 /* ReleaseDateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0C6AD032AD6E65700E64698 /* ReleaseDateView.swift */; };
|
||||
B0C6AD0B2AD9178E00E64698 /* IdenticalBuildView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0C6AD0A2AD9178E00E64698 /* IdenticalBuildView.swift */; };
|
||||
B0C6AD0D2AD91D7900E64698 /* IconView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0C6AD0C2AD91D7900E64698 /* IconView.swift */; };
|
||||
|
|
@ -209,6 +210,7 @@
|
|||
B0403CF72AD991F800137C09 /* UnselectedView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnselectedView.swift; sourceTree = "<group>"; };
|
||||
B0403CF92AD9942A00137C09 /* NotInstalledStateButtons.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotInstalledStateButtons.swift; sourceTree = "<group>"; };
|
||||
B0403CFB2AD9A6BF00137C09 /* InstalledStateButtons.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstalledStateButtons.swift; sourceTree = "<group>"; };
|
||||
B0403CFD2ADA712C00137C09 /* InfoPaneControls.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoPaneControls.swift; sourceTree = "<group>"; };
|
||||
B0C6AD032AD6E65700E64698 /* ReleaseDateView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReleaseDateView.swift; sourceTree = "<group>"; };
|
||||
B0C6AD0A2AD9178E00E64698 /* IdenticalBuildView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IdenticalBuildView.swift; sourceTree = "<group>"; };
|
||||
B0C6AD0C2AD91D7900E64698 /* IconView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IconView.swift; sourceTree = "<group>"; };
|
||||
|
|
@ -640,6 +642,7 @@
|
|||
B0403CF52AD9849E00137C09 /* CompilersView.swift */,
|
||||
B0403CF12AD934B600137C09 /* CompatibilityView.swift */,
|
||||
CAFBDC67259A308B003DCC5A /* InfoPane.swift */,
|
||||
B0403CFD2ADA712C00137C09 /* InfoPaneControls.swift */,
|
||||
B0403CF72AD991F800137C09 /* UnselectedView.swift */,
|
||||
B0403CF92AD9942A00137C09 /* NotInstalledStateButtons.swift */,
|
||||
B0403CFB2AD9A6BF00137C09 /* InstalledStateButtons.swift */,
|
||||
|
|
@ -895,6 +898,7 @@
|
|||
36741BFF291E50F500A85AAE /* FileError.swift in Sources */,
|
||||
CA9FF8872595607900E47BAF /* InstalledXcode.swift in Sources */,
|
||||
B0403CF22AD934B600137C09 /* CompatibilityView.swift in Sources */,
|
||||
B0403CFE2ADA712C00137C09 /* InfoPaneControls.swift in Sources */,
|
||||
53CBAB2C263DCC9100410495 /* XcodesAlert.swift in Sources */,
|
||||
CA42DD6E25AEA8B200BC0B0C /* Logger.swift in Sources */,
|
||||
CA61A6E0259835580008926E /* Xcode.swift in Sources */,
|
||||
|
|
|
|||
|
|
@ -17,18 +17,7 @@ struct InfoPane: View {
|
|||
Text(verbatim: "Xcode \(xcode.description) \(xcode.version.buildMetadataIdentifiersDisplay)")
|
||||
.font(.title)
|
||||
|
||||
switch xcode.installState {
|
||||
case .notInstalled:
|
||||
NotInstalledStateButtons(
|
||||
downloadFileSizeString: xcode.downloadFileSizeString,
|
||||
id: xcode.id
|
||||
)
|
||||
case let .installing(installationStep):
|
||||
InstallationStepDetailView(installationStep: installationStep)
|
||||
CancelInstallButton(xcode: xcode)
|
||||
case .installed:
|
||||
InstalledStateButtons(xcode: xcode)
|
||||
}
|
||||
InfoPaneControls(xcode: xcode)
|
||||
|
||||
Divider()
|
||||
|
||||
|
|
@ -79,7 +68,7 @@ private struct WrapperView: View {
|
|||
var xcode: Xcode { xcodeDict[name]! }
|
||||
}
|
||||
|
||||
private enum PreviewName: String, CaseIterable, Identifiable {
|
||||
enum PreviewName: String, CaseIterable, Identifiable {
|
||||
case Populated_Installed_Selected
|
||||
case Populated_Installed_Unselected
|
||||
case Populated_Uninstalled
|
||||
|
|
@ -89,7 +78,7 @@ private enum PreviewName: String, CaseIterable, Identifiable {
|
|||
var id: PreviewName { self }
|
||||
}
|
||||
|
||||
private var xcodeDict: [PreviewName: Xcode] = [
|
||||
var xcodeDict: [PreviewName: Xcode] = [
|
||||
.Populated_Installed_Selected: .init(
|
||||
version: _versionNoMeta,
|
||||
installState: .installed(Path(_path)!),
|
||||
|
|
@ -130,7 +119,16 @@ private var xcodeDict: [PreviewName: Xcode] = [
|
|||
),
|
||||
.Basic_Installing: .init(
|
||||
version: _versionWithMeta,
|
||||
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 })),
|
||||
installState: .installing(.downloading(
|
||||
progress: configure(Progress()) {
|
||||
$0.kind = .file
|
||||
$0.fileOperationKind = .downloading
|
||||
$0.estimatedTimeRemaining = 123
|
||||
$0.totalUnitCount = 11_944_848_484
|
||||
$0.completedUnitCount = 848_444_920
|
||||
$0.throughput = 9_211_681
|
||||
}
|
||||
)),
|
||||
selected: false,
|
||||
icon: nil,
|
||||
sdks: nil,
|
||||
|
|
|
|||
62
Xcodes/Frontend/InfoPane/InfoPaneControls.swift
Normal file
62
Xcodes/Frontend/InfoPane/InfoPaneControls.swift
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
//
|
||||
// InfoPaneControls.swift
|
||||
// Xcodes
|
||||
//
|
||||
// Created by Duong Thai on 14/10/2023.
|
||||
// Copyright © 2023 Robots and Pencils. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct InfoPaneControls: View {
|
||||
let xcode: Xcode
|
||||
|
||||
var body: some View {
|
||||
VStack (alignment: .leading) {
|
||||
switch xcode.installState {
|
||||
case .notInstalled:
|
||||
NotInstalledStateButtons(
|
||||
downloadFileSizeString: xcode.downloadFileSizeString,
|
||||
id: xcode.id)
|
||||
case .installing(let installationStep):
|
||||
InstallationStepDetailView(installationStep: installationStep)
|
||||
CancelInstallButton(xcode: xcode)
|
||||
case .installed(_):
|
||||
InstalledStateButtons(xcode: xcode)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct InfoPaneControls_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
WrapperView()
|
||||
}
|
||||
}
|
||||
|
||||
private struct WrapperView: View {
|
||||
@State var name: PreviewName = .Populated_Installed_Selected
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
InfoPaneControls(xcode: xcode)
|
||||
.environmentObject(configure(AppState()) {
|
||||
$0.allXcodes = [xcode]
|
||||
})
|
||||
.border(.red)
|
||||
.frame(width: 300, height: 400)
|
||||
Spacer()
|
||||
Picker("Preview Name", selection: $name) {
|
||||
ForEach(PreviewName.allCases) {
|
||||
Text($0.rawValue).tag($0)
|
||||
}
|
||||
}
|
||||
.pickerStyle(.inline)
|
||||
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding()
|
||||
}
|
||||
|
||||
var xcode: Xcode { xcodeDict[name]! }
|
||||
}
|
||||
Loading…
Reference in a new issue