Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit fcc3133

Browse files
committed
changing Seed preference now reloads catalog
1 parent d8fb608 commit fcc3133

7 files changed

Lines changed: 38 additions & 23 deletions

File tree

FetchInstallerPkg.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@
105105
isa = PBXGroup;
106106
children = (
107107
C636436F2670E1F700301DC8 /* SUCatalog.swift */,
108+
C69C80D126788B8D00E20E20 /* Catalog.swift */,
109+
C69C80CD26788B1400E20E20 /* Product.swift */,
108110
C69C80D726788BC900E20E20 /* BuildManifest.swift */,
109111
C69C80D526788BB600E20E20 /* MetaInfo.swift */,
110112
C69C80D326788BA100E20E20 /* Package.swift */,
111-
C69C80D126788B8D00E20E20 /* Catalog.swift */,
112113
C69C80CF26788B6B00E20E20 /* DistParserDelegate.swift */,
113-
C69C80CD26788B1400E20E20 /* Product.swift */,
114114
C635B0AB26789F5F001EEA82 /* SeedProgram.swift */,
115115
);
116116
path = Model;
@@ -270,7 +270,7 @@
270270
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
271271
GCC_WARN_UNUSED_FUNCTION = YES;
272272
GCC_WARN_UNUSED_VARIABLE = YES;
273-
MACOSX_DEPLOYMENT_TARGET = 11.4;
273+
MACOSX_DEPLOYMENT_TARGET = 11.0;
274274
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
275275
MTL_FAST_MATH = YES;
276276
ONLY_ACTIVE_ARCH = YES;
@@ -325,7 +325,7 @@
325325
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
326326
GCC_WARN_UNUSED_FUNCTION = YES;
327327
GCC_WARN_UNUSED_VARIABLE = YES;
328-
MACOSX_DEPLOYMENT_TARGET = 11.4;
328+
MACOSX_DEPLOYMENT_TARGET = 11.0;
329329
MTL_ENABLE_DEBUG_INFO = NO;
330330
MTL_FAST_MATH = YES;
331331
SDKROOT = macosx;

FetchInstallerPkg/FetchInstallerPkgApp.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import SwiftUI
1010
@main
1111
struct FetchInstallerPkgApp: App {
1212
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
13-
13+
@StateObject var sucatalog = SUCatalog()
1414
var body: some Scene {
1515
WindowGroup {
16-
ContentView()
16+
ContentView().environmentObject(sucatalog)
1717
}
1818
Settings {
19-
PreferencesView()
19+
PreferencesView().environmentObject(sucatalog)
2020
}
2121
}
2222
}

FetchInstallerPkg/Model/SUCatalog.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class SUCatalog: ObservableObject {
2020
load()
2121
}
2222

23-
private func load() {
23+
func load() {
2424
let catalogURL = catalogURL(for: Prefs.seedProgram)
2525
print(catalogURL.absoluteString)
2626

@@ -48,6 +48,7 @@ class SUCatalog: ObservableObject {
4848
isLoading = true
4949
hasLoaded = false
5050
self.catalog = nil
51+
self.installers = [Product]()
5152
task.resume()
5253
}
5354

FetchInstallerPkg/View/ContentView.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@ import SwiftUI
99

1010

1111
struct ContentView: View {
12-
@StateObject var catalog = SUCatalog()
12+
@EnvironmentObject var sucatalog: SUCatalog
13+
@AppStorage(Prefs.key(.seedProgram)) var seedProgram: String = ""
1314

1415
var body: some View {
1516
VStack(alignment: .leading){
1617
Text("Download Full Installer")
1718
.font(.title)
1819
.multilineTextAlignment(.leading)
1920

20-
List(catalog.installers, id: \.id) { installer in
21+
List(sucatalog.installers, id: \.id) { installer in
2122
InstallerView(product: installer)
2223
}.padding(4)
2324
DownloadView()

FetchInstallerPkg/View/DownloadView.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ struct DownloadView: View {
1515
VStack(alignment: .leading) {
1616
HStack {
1717
Text("Downloading:")
18+
Text(downloadManager.progressString)
19+
.font(.footnote)
20+
.lineLimit(1)
21+
.truncationMode(.middle)
1822
}
19-
Text(downloadManager.progressString)
20-
.font(.footnote)
21-
.lineLimit(1)
22-
.truncationMode(.middle)
2323
HStack {
2424
ProgressView(value: downloadManager.progress)
2525
Button(action: {downloadManager.cancel()}) {
2626
Image(systemName: "xmark.circle.fill").accentColor(.gray)
27-
}
27+
}.buttonStyle(.borderless)
2828
}
2929

3030
}

FetchInstallerPkg/View/InstallerView.swift

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,34 @@ struct InstallerView: View {
1919
.resizable(resizingMode: .stretch)
2020
.aspectRatio(contentMode: .fit)
2121
.foregroundColor(Color.blue)
22-
.frame(width: 40.0, height: 40.0)
22+
.frame(width: 50.0, height: 40.0)
2323
VStack(alignment: .leading) {
2424
HStack {
25-
Text(product.title ?? "<no title>").font(.headline)
25+
Text(product.title ?? "<no title>")
26+
.font(.headline)
27+
Spacer()
2628
Text(product.productVersion ?? "<no version>")
27-
.multilineTextAlignment(.leading)
28-
.frame(width: 60.0)
29-
Text(product.buildVersion ?? "<no build>")
29+
.frame(alignment: .trailing)
3030
}
3131
HStack {
3232
Text(product.postDate, style: .date)
3333
.font(.footnote)
34+
Spacer()
35+
Text(product.buildVersion ?? "<no build>")
36+
.frame(alignment: .trailing)
37+
.font(.footnote)
3438
}
3539
}
36-
Spacer()
40+
41+
3742
Button(action: {
3843
DownloadManager.shared.download(url: product.installAssistantURL)
3944
}) {
40-
Image(systemName: "arrow.down.circle")
41-
}.disabled(downloadManager.isDownloading)
45+
Image(systemName: "arrow.down.circle").font(.title)
46+
}
47+
.disabled(downloadManager.isDownloading)
48+
.buttonStyle(.borderless)
49+
.controlSize(/*@START_MENU_TOKEN@*/.large/*@END_MENU_TOKEN@*/)
4250
}
4351
}
4452
}

FetchInstallerPkg/View/PreferencesView.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import SwiftUI
1010
struct PreferencesView: View {
1111
@AppStorage(Prefs.key(.seedProgram)) var seedProgram: String = ""
1212
@AppStorage(Prefs.key(.downloadPath)) var downloadPath: String = ""
13+
@EnvironmentObject var sucatalog: SUCatalog
1314

1415
let labelWidth = 100.0
1516
var body: some View {
@@ -21,6 +22,10 @@ struct PreferencesView: View {
2122
Text(program.rawValue)
2223
}
2324
}
25+
.onChange(of: seedProgram) { _ in
26+
sucatalog.load()
27+
}
28+
2429
}
2530
HStack {
2631
Text("Download to:")

0 commit comments

Comments
 (0)