Skip to content

Commit d172df6

Browse files
committed
move and fix the NotInstalledStateButtonsView
1 parent d08d2d3 commit d172df6

3 files changed

Lines changed: 76 additions & 2 deletions

File tree

Xcodes.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
B0403CF42AD9381D00137C09 /* SDKsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0403CF32AD9381D00137C09 /* SDKsView.swift */; };
1919
B0403CF62AD9849E00137C09 /* CompilersView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0403CF52AD9849E00137C09 /* CompilersView.swift */; };
2020
B0403CF82AD991F800137C09 /* UnselectedView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0403CF72AD991F800137C09 /* UnselectedView.swift */; };
21+
B0403CFA2AD9942A00137C09 /* NotInstalledStateButtonsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0403CF92AD9942A00137C09 /* NotInstalledStateButtonsView.swift */; };
2122
B0C6AD042AD6E65700E64698 /* ReleaseDateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0C6AD032AD6E65700E64698 /* ReleaseDateView.swift */; };
2223
B0C6AD0B2AD9178E00E64698 /* IdenticalBuildView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0C6AD0A2AD9178E00E64698 /* IdenticalBuildView.swift */; };
2324
B0C6AD0D2AD91D7900E64698 /* IconView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0C6AD0C2AD91D7900E64698 /* IconView.swift */; };
@@ -205,6 +206,7 @@
205206
B0403CF32AD9381D00137C09 /* SDKsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SDKsView.swift; sourceTree = "<group>"; };
206207
B0403CF52AD9849E00137C09 /* CompilersView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompilersView.swift; sourceTree = "<group>"; };
207208
B0403CF72AD991F800137C09 /* UnselectedView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnselectedView.swift; sourceTree = "<group>"; };
209+
B0403CF92AD9942A00137C09 /* NotInstalledStateButtonsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotInstalledStateButtonsView.swift; sourceTree = "<group>"; };
208210
B0C6AD032AD6E65700E64698 /* ReleaseDateView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReleaseDateView.swift; sourceTree = "<group>"; };
209211
B0C6AD0A2AD9178E00E64698 /* IdenticalBuildView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IdenticalBuildView.swift; sourceTree = "<group>"; };
210212
B0C6AD0C2AD91D7900E64698 /* IconView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IconView.swift; sourceTree = "<group>"; };
@@ -637,6 +639,7 @@
637639
B0403CF12AD934B600137C09 /* CompatibilityView.swift */,
638640
CAFBDC67259A308B003DCC5A /* InfoPane.swift */,
639641
B0403CF72AD991F800137C09 /* UnselectedView.swift */,
642+
B0403CF92AD9942A00137C09 /* NotInstalledStateButtonsView.swift */,
640643
E8E98A9525D863D700EC89A0 /* InstallationStepDetailView.swift */,
641644
B0C6AD032AD6E65700E64698 /* ReleaseDateView.swift */,
642645
B0C6AD0A2AD9178E00E64698 /* IdenticalBuildView.swift */,
@@ -925,6 +928,7 @@
925928
CABFA9CF2592EEEA00380FEE /* Process.swift in Sources */,
926929
CAFFFED8259CDA5000903F81 /* XcodeListViewRow.swift in Sources */,
927930
CABFA9C72592EEEA00380FEE /* Entry+.swift in Sources */,
931+
B0403CFA2AD9942A00137C09 /* NotInstalledStateButtonsView.swift in Sources */,
928932
CAE424B4259A764700B8B246 /* AppState+Install.swift in Sources */,
929933
CAE42487259A68A300B8B246 /* XcodeListCategory.swift in Sources */,
930934
CAA858C425A2BE4E00ACF8C0 /* Downloader.swift in Sources */,

Xcodes/Frontend/InfoPane/InfoPane.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ struct InfoPane: View {
2121

2222
switch xcode.installState {
2323
case .notInstalled:
24-
InstallButton(xcode: xcode)
25-
downloadFileSize(for: xcode)
24+
NotInstalledStateButtonsView(
25+
downloadFileSizeString: xcode.downloadFileSizeString,
26+
id: xcode.id
27+
)
2628
case let .installing(installationStep):
2729
InstallationStepDetailView(installationStep: installationStep)
2830
.fixedSize(horizontal: false, vertical: true)
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
//
2+
// NotInstalledStateButtonsView.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 Version
11+
12+
struct NotInstalledStateButtonsView: View {
13+
let downloadFileSizeString: String?
14+
let id: Version
15+
16+
@EnvironmentObject var appState: AppState
17+
18+
var body: some View {
19+
VStack(alignment: .leading) {
20+
Button {
21+
appState.checkMinVersionAndInstall(id: id)
22+
} label: {
23+
Text("Install") .help("Install")
24+
}
25+
if let size = downloadFileSizeString {
26+
27+
Text("DownloadSize")
28+
.font(.headline)
29+
Text(size)
30+
.font(.subheadline)
31+
} else {
32+
EmptyView()
33+
}
34+
}
35+
}
36+
}
37+
38+
struct NotInstalledStateButtonsView_Preview: PreviewProvider {
39+
static var previews: some View {
40+
WrapperView()
41+
}
42+
}
43+
44+
private struct WrapperView: View {
45+
@State var isSizeNil = false
46+
47+
var downloadFileSizeString: String? {
48+
isSizeNil
49+
? nil
50+
: "1,19 GB"
51+
}
52+
53+
var body: some View {
54+
VStack {
55+
NotInstalledStateButtonsView(
56+
downloadFileSizeString: downloadFileSizeString,
57+
id: Version(major: 12, minor: 3, patch: 0)
58+
)
59+
.border(.red)
60+
Spacer()
61+
Toggle(isOn: $isSizeNil) {
62+
Text("Is Size Nil?")
63+
}
64+
}
65+
.frame(width: 200, height: 100)
66+
.padding()
67+
}
68+
}

0 commit comments

Comments
 (0)