Skip to content

Commit b9ba988

Browse files
authored
Merge pull request #305 from leon-wolf/feature/291-cleanup-preferences
move download settings to own PreferencePane
2 parents 25460b9 + e533012 commit b9ba988

18 files changed

Lines changed: 198 additions & 126 deletions

File tree

Xcodes.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
36741BFD291E4FDB00A85AAE /* DownloadPreferencePane.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36741BFC291E4FDB00A85AAE /* DownloadPreferencePane.swift */; };
1011
536CFDD2263C94DE00026CE0 /* SignedInView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 536CFDD1263C94DE00026CE0 /* SignedInView.swift */; };
1112
536CFDD4263C9A8000026CE0 /* XcodesSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 536CFDD3263C9A8000026CE0 /* XcodesSheet.swift */; };
1213
53CBAB2C263DCC9100410495 /* XcodesAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53CBAB2B263DCC9100410495 /* XcodesAlert.swift */; };
@@ -170,6 +171,7 @@
170171
/* Begin PBXFileReference section */
171172
15FAD1652811D15600B63259 /* hi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = hi; path = hi.lproj/Localizable.strings; sourceTree = "<group>"; };
172173
25E2FA26284769A00014A318 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/Localizable.strings; sourceTree = "<group>"; };
174+
36741BFC291E4FDB00A85AAE /* DownloadPreferencePane.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DownloadPreferencePane.swift; sourceTree = "<group>"; };
173175
4A5AAA1D28118FAD00528958 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/Localizable.strings; sourceTree = "<group>"; };
174176
536CFDD1263C94DE00026CE0 /* SignedInView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignedInView.swift; sourceTree = "<group>"; };
175177
536CFDD3263C9A8000026CE0 /* XcodesSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XcodesSheet.swift; sourceTree = "<group>"; };
@@ -588,6 +590,7 @@
588590
isa = PBXGroup;
589591
children = (
590592
CAFE4AB325B7D3AF0064FE51 /* AdvancedPreferencePane.swift */,
593+
36741BFC291E4FDB00A85AAE /* DownloadPreferencePane.swift */,
591594
CAFE4AAB25B7D2C70064FE51 /* GeneralPreferencePane.swift */,
592595
CAFE4ABB25B7D54B0064FE51 /* UpdatesPreferencePane.swift */,
593596
E8977EA225C11E1500835F80 /* PreferencesView.swift */,
@@ -848,6 +851,7 @@
848851
CA9FF84E2595079F00E47BAF /* ScrollingTextView.swift in Sources */,
849852
CABFA9C12592EEEA00380FEE /* Version+.swift in Sources */,
850853
E8D655C0288DD04700A139C2 /* SelectedActionType.swift in Sources */,
854+
36741BFD291E4FDB00A85AAE /* DownloadPreferencePane.swift in Sources */,
851855
CA9FF8522595080100E47BAF /* AcknowledgementsView.swift in Sources */,
852856
CABFA9CE2592EEEA00380FEE /* Version+Xcode.swift in Sources */,
853857
CAFBDB912598FE80003DCC5A /* SelectedXcode.swift in Sources */,

Xcodes/Frontend/Preferences/AdvancedPreferencePane.swift

Lines changed: 9 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,16 @@ import Path
44

55
struct AdvancedPreferencePane: View {
66
@EnvironmentObject var appState: AppState
7-
8-
@AppStorage("dataSource") var dataSource: DataSource = .xcodeReleases
9-
@AppStorage("downloader") var downloader: Downloader = .aria2
107

118
var body: some View {
129
VStack(alignment: .leading, spacing: 20) {
13-
10+
1411
GroupBox(label: Text("InstallDirectory")) {
1512
VStack(alignment: .leading) {
1613
HStack(alignment: .top, spacing: 5) {
1714
Text(appState.installPath).font(.footnote)
18-
.fixedSize(horizontal: false, vertical: true)
19-
.lineLimit(2)
15+
.fixedSize(horizontal: false, vertical: true)
16+
.lineLimit(2)
2017
Button(action: { appState.reveal(path: appState.installPath) }) {
2118
Image(systemName: "arrow.right.circle.fill")
2219
}
@@ -34,7 +31,7 @@ struct AdvancedPreferencePane: View {
3431
panel.directoryURL = URL(fileURLWithPath: appState.installPath)
3532

3633
if panel.runModal() == .OK {
37-
34+
3835
guard let pathURL = panel.url, let path = Path(url: pathURL) else { return }
3936
self.appState.installPath = path.string
4037
}
@@ -50,8 +47,8 @@ struct AdvancedPreferencePane: View {
5047
VStack(alignment: .leading) {
5148
HStack(alignment: .top, spacing: 5) {
5249
Text(appState.localPath).font(.footnote)
53-
.fixedSize(horizontal: false, vertical: true)
54-
.lineLimit(2)
50+
.fixedSize(horizontal: false, vertical: true)
51+
.lineLimit(2)
5552
Button(action: { appState.reveal(path: appState.localPath) }) {
5653
Image(systemName: "arrow.right.circle.fill")
5754
}
@@ -69,7 +66,7 @@ struct AdvancedPreferencePane: View {
6966
panel.directoryURL = URL(fileURLWithPath: appState.localPath)
7067

7168
if panel.runModal() == .OK {
72-
69+
7370
guard let pathURL = panel.url, let path = Path(url: pathURL) else { return }
7471
self.appState.localPath = path.string
7572
}
@@ -102,44 +99,13 @@ struct AdvancedPreferencePane: View {
10299
Toggle("AutomaticallyCreateSymbolicLink", isOn: $appState.createSymLinkOnSelect)
103100
.disabled(appState.createSymLinkOnSelectDisabled)
104101
Text("AutomaticallyCreateSymbolicLinkDescription")
105-
.font(.footnote)
106-
.fixedSize(horizontal: false, vertical: true)
102+
.font(.footnote)
103+
.fixedSize(horizontal: false, vertical: true)
107104
}
108105
.fixedSize(horizontal: false, vertical: true)
109106
}
110107
.groupBoxStyle(PreferencesGroupBoxStyle())
111108

112-
GroupBox(label: Text("DataSource")) {
113-
VStack(alignment: .leading) {
114-
Picker("DataSource", selection: $dataSource) {
115-
ForEach(DataSource.allCases) { dataSource in
116-
Text(dataSource.description)
117-
.tag(dataSource)
118-
}
119-
}
120-
.labelsHidden()
121-
122-
AttributedText(dataSourceFootnote)
123-
}
124-
125-
}
126-
.groupBoxStyle(PreferencesGroupBoxStyle())
127-
128-
GroupBox(label: Text("Downloader")) {
129-
VStack(alignment: .leading) {
130-
Picker("Downloader", selection: $downloader) {
131-
ForEach(Downloader.allCases) { downloader in
132-
Text(downloader.description)
133-
.tag(downloader)
134-
}
135-
}
136-
.labelsHidden()
137-
138-
AttributedText(downloaderFootnote)
139-
}
140-
141-
}
142-
.groupBoxStyle(PreferencesGroupBoxStyle())
143109

144110
GroupBox(label: Text("PrivilegedHelper")) {
145111
VStack(alignment: .leading, spacing: 8) {
@@ -168,32 +134,6 @@ struct AdvancedPreferencePane: View {
168134
.groupBoxStyle(PreferencesGroupBoxStyle())
169135
}
170136
}
171-
172-
private var dataSourceFootnote: NSAttributedString {
173-
let string = localizeString("DataSourceDescription")
174-
let attributedString = NSMutableAttributedString(
175-
string: string,
176-
attributes: [
177-
.font: NSFont.preferredFont(forTextStyle: .footnote, options: [:]),
178-
.foregroundColor: NSColor.labelColor
179-
]
180-
)
181-
attributedString.addAttribute(.link, value: URL(string: "https://xcodereleases.com")!, range: NSRange(string.range(of: "Xcode Releases")!, in: string))
182-
return attributedString
183-
}
184-
185-
private var downloaderFootnote: NSAttributedString {
186-
let string = localizeString("DownloaderDescription")
187-
let attributedString = NSMutableAttributedString(
188-
string: string,
189-
attributes: [
190-
.font: NSFont.preferredFont(forTextStyle: .footnote, options: [:]),
191-
.foregroundColor: NSColor.labelColor
192-
]
193-
)
194-
attributedString.addAttribute(.link, value: URL(string: "https://github.com/aria2/aria2")!, range: NSRange(string.range(of: "aria2")!, in: string))
195-
return attributedString
196-
}
197137
}
198138

199139
struct AdvancedPreferencePane_Previews: PreviewProvider {
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import AppleAPI
2+
import SwiftUI
3+
4+
struct DownloadPreferencePane: View {
5+
@EnvironmentObject var appState: AppState
6+
7+
@AppStorage("dataSource") var dataSource: DataSource = .xcodeReleases
8+
@AppStorage("downloader") var downloader: Downloader = .aria2
9+
10+
var body: some View {
11+
VStack(alignment: .leading) {
12+
GroupBox(label: Text("DataSource")) {
13+
VStack(alignment: .leading) {
14+
Picker("DataSource", selection: $dataSource) {
15+
ForEach(DataSource.allCases) { dataSource in
16+
Text(dataSource.description)
17+
.tag(dataSource)
18+
}
19+
}
20+
.labelsHidden()
21+
22+
AttributedText(dataSourceFootnote)
23+
}
24+
25+
}
26+
.groupBoxStyle(PreferencesGroupBoxStyle())
27+
28+
GroupBox(label: Text("Downloader")) {
29+
VStack(alignment: .leading) {
30+
Picker("Downloader", selection: $downloader) {
31+
ForEach(Downloader.allCases) { downloader in
32+
Text(downloader.description)
33+
.tag(downloader)
34+
}
35+
}
36+
.labelsHidden()
37+
38+
AttributedText(downloaderFootnote)
39+
}
40+
41+
}
42+
.groupBoxStyle(PreferencesGroupBoxStyle())
43+
44+
}
45+
}
46+
47+
private var dataSourceFootnote: NSAttributedString {
48+
let string = localizeString("DataSourceDescription")
49+
let attributedString = NSMutableAttributedString(
50+
string: string,
51+
attributes: [
52+
.font: NSFont.preferredFont(forTextStyle: .footnote, options: [:]),
53+
.foregroundColor: NSColor.labelColor
54+
]
55+
)
56+
attributedString.addAttribute(.link, value: URL(string: "https://xcodereleases.com")!, range: NSRange(string.range(of: "Xcode Releases")!, in: string))
57+
return attributedString
58+
}
59+
60+
private var downloaderFootnote: NSAttributedString {
61+
let string = localizeString("DownloaderDescription")
62+
let attributedString = NSMutableAttributedString(
63+
string: string,
64+
attributes: [
65+
.font: NSFont.preferredFont(forTextStyle: .footnote, options: [:]),
66+
.foregroundColor: NSColor.labelColor
67+
]
68+
)
69+
attributedString.addAttribute(.link, value: URL(string: "https://github.com/aria2/aria2")!, range: NSRange(string.range(of: "aria2")!, in: string))
70+
return attributedString
71+
}
72+
}
73+
74+
struct DownloadPreferencePane_Previews: PreviewProvider {
75+
static var previews: some View {
76+
Group {
77+
GeneralPreferencePane()
78+
.environmentObject(AppState())
79+
.frame(maxWidth: 500)
80+
}
81+
}
82+
}

Xcodes/Frontend/Preferences/PreferencesView.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ struct PreferencesView: View {
2121
Label("Updates", systemImage: "arrow.triangle.2.circlepath.circle")
2222
}
2323
.tag(Tabs.updates)
24+
DownloadPreferencePane()
25+
.environmentObject(appState)
26+
.tabItem {
27+
Label("Downloads", systemImage: "icloud.and.arrow.down")
28+
}
2429
AdvancedPreferencePane()
2530
.environmentObject(appState)
2631
.tabItem {

Xcodes/Resources/de.lproj/Localizable.strings

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@
7272
"LastChecked" = "Letzte Prüfung: %@";
7373
"Never" = "Nie";
7474

75+
// Download Preference Pane
76+
"Downloads" = "Downloads";
77+
"DataSource" = "Datenquelle";
78+
"DataSourceDescription" = "Die Apple-Datenquelle liest die Apple Developer-Website aus. Sie zeigt immer die neuesten Releases an, die verfügbar sind, ist allerdings etwas instabiler.\n\nXcode Releases ist eine inoffizielle Liste von Xcode-Veröffentlichungen. Sie wird als formatierte Daten bereitsgestellt, enthält Extrainformationen die nicht ohne weiteres von Apple erhältlich sind und ist mit höherer Wahrscheinlichkeit weiter verfügbar, sollte Apple seine Entwickler-Website neu gestalten.";
79+
"Downloader" = "Downloader";
80+
"DownloaderDescription" = "aria2 verwendet bis zu 16 Verbindungen, um Xcode 3-5x schneller als URLSession herunterzuladen. Es ist zusammen mit seinem Quellcode in Xcode enthalten, um seiner GPLv2-Lizenz nachzukommen.\n\nURLSession ist Apples Standard-API für URL-Requests.";
81+
7582
// Advanced Preference Pane
7683
"Advanced" = "Erweitert";
7784
"LocalCachePath" = "Lokaler Cache-Pfad";
@@ -88,10 +95,6 @@
8895
"OnSelectRenameXcode" = "Immer in Xcode.app umbenennen";
8996
"OnSelectRenameXcodeDescription" = "Bei Auswahl wird versucht das aktive Xcode in Xcode.app umzubenennen. Die vorherige Xcode.app wird dazu in den Versionsnamen umbenannt.";
9097

91-
"DataSource" = "Datenquelle";
92-
"DataSourceDescription" = "Die Apple-Datenquelle liest die Apple Developer-Website aus. Sie zeigt immer die neuesten Releases an, die verfügbar sind, ist allerdings etwas instabiler.\n\nXcode Releases ist eine inoffizielle Liste von Xcode-Veröffentlichungen. Sie wird als formatierte Daten bereitsgestellt, enthält Extrainformationen die nicht ohne weiteres von Apple erhältlich sind und ist mit höherer Wahrscheinlichkeit weiter verfügbar, sollte Apple seine Entwickler-Website neu gestalten.";
93-
"Downloader" = "Downloader";
94-
"DownloaderDescription" = "aria2 verwendet bis zu 16 Verbindungen, um Xcode 3-5x schneller als URLSession herunterzuladen. Es ist zusammen mit seinem Quellcode in Xcode enthalten, um seiner GPLv2-Lizenz nachzukommen.\n\nURLSession ist Apples Standard-API für URL-Requests.";
9598
"PrivilegedHelper" = "Privilegierter Helfer";
9699
"PrivilegedHelperDescription" = "Xcodes verwendet einen separaten privilegierten Helfer, um Aufgaben als root zu erledigen. Das sind Dinge, die sudo in der Kommandozeile erfordern würden, einschließlich Post-Installationsschritte sowie das Umstellen von Xcode-Versionen mit xcode-select.\n\nUm ihn zu installieren, erfolgt eine Aufforderung zur Eingabe des Passworts für Dein macOS-Benutzerkonto.";
97100
"HelperInstalled" = "Helfer ist installiert";

Xcodes/Resources/en.lproj/Localizable.strings

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@
7272
"LastChecked" = "Last checked: %@";
7373
"Never" = "Never";
7474

75+
// Download Preference Pane
76+
"Downloads" = "Downloads";
77+
"DataSource" = "Data Source";
78+
"DataSourceDescription" = "The Apple data source scrapes the Apple Developer website. It will always show the latest releases that are available, but is more fragile.\n\nXcode Releases is an unofficial list of Xcode releases. It's provided as well-formed data, contains extra information that is not readily available from Apple, and is less likely to break if Apple redesigns their developer website.";
79+
"Downloader" = "Downloader";
80+
"DownloaderDescription" = "aria2 uses up to 16 connections to download Xcode 3-5x faster than URLSession. It's bundled as an executable along with its source code within Xcodes to comply with its GPLv2 license.\n\nURLSession is the default Apple API for making URL requests.";
81+
7582
// Advanced Preference Pane
7683
"Advanced" = "Advanced";
7784
"LocalCachePath" = "Local Cache Path";
@@ -88,10 +95,6 @@
8895
"OnSelectRenameXcode" = "Always rename to Xcode.app";
8996
"OnSelectRenameXcodeDescription" = "On select, will automatically try and rename the active Xcode to Xcode.app, renaming the previous Xcode.app to the version name.";
9097

91-
"DataSource" = "Data Source";
92-
"DataSourceDescription" = "The Apple data source scrapes the Apple Developer website. It will always show the latest releases that are available, but is more fragile.\n\nXcode Releases is an unofficial list of Xcode releases. It's provided as well-formed data, contains extra information that is not readily available from Apple, and is less likely to break if Apple redesigns their developer website.";
93-
"Downloader" = "Downloader";
94-
"DownloaderDescription" = "aria2 uses up to 16 connections to download Xcode 3-5x faster than URLSession. It's bundled as an executable along with its source code within Xcodes to comply with its GPLv2 license.\n\nURLSession is the default Apple API for making URL requests.";
9598
"PrivilegedHelper" = "Privileged Helper";
9699
"PrivilegedHelperDescription" = "Xcodes uses a separate privileged helper to perform tasks as root. These are things that would require sudo on the command line, including post-install steps and switching Xcode versions with xcode-select.\n\nYou'll be prompted for your macOS account password to install it.";
97100
"HelperInstalled" = "Helper is installed";

Xcodes/Resources/es.lproj/Localizable.strings

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@
7272
"LastChecked" = "Última comprobación: %@";
7373
"Never" = "Nunca";
7474

75+
// Download Preference Pane
76+
"Downloads" = "Descargas";
77+
"DataSource" = "Fuente de datos";
78+
"DataSourceDescription" = "La fuente de datos de Apple la extrae de el sitio web de Apple Developer. Siempre mostrará los últimos lanzamientos disponibles, pero es más frágil.\n\nXcode Releases es una lista no oficial de lanzamientos de Xcode. Se proporciona como datos bien estructurados, contiene información adicional que no está disponible fácilmente en Apple y es menos probable que se rompa si Apple rediseña su sitio web para desarrolladores.";
79+
"Downloader" = "Downloader";
80+
"DownloaderDescription" = "aria2 usa hasta 16 conexiones para descargar Xcode de 3 a 5 veces más rápido que URLSession. Se incluye como un ejecutable junto con su código fuente dentro de Xcodes para cumplir con su licencia GPLv2.\n\nURLSession es la API predeterminada de Apple para realizar solicitudes de URL.";
81+
7582
// Advanced Preference Pane
7683
"Advanced" = "Avanzado";
7784
"LocalCachePath" = "Ruta de caché local";
@@ -80,10 +87,6 @@
8087
"Active/Select" = "Activar/Seleccionar";
8188
"AutomaticallyCreateSymbolicLink" = "Crear automáticamente enlace simbólico a Xcode.app";
8289
"AutomaticallyCreateSymbolicLinkDescription" = "Al activar/seleccionar una versión de Xcode, intentará crear un enlace simbólico llamado Xcode.app en el directorio de instalación.";
83-
"DataSource" = "Fuente de datos";
84-
"DataSourceDescription" = "La fuente de datos de Apple la extrae de el sitio web de Apple Developer. Siempre mostrará los últimos lanzamientos disponibles, pero es más frágil.\n\nXcode Releases es una lista no oficial de lanzamientos de Xcode. Se proporciona como datos bien estructurados, contiene información adicional que no está disponible fácilmente en Apple y es menos probable que se rompa si Apple rediseña su sitio web para desarrolladores.";
85-
"Downloader" = "Downloader";
86-
"DownloaderDescription" = "aria2 usa hasta 16 conexiones para descargar Xcode de 3 a 5 veces más rápido que URLSession. Se incluye como un ejecutable junto con su código fuente dentro de Xcodes para cumplir con su licencia GPLv2.\n\nURLSession es la API predeterminada de Apple para realizar solicitudes de URL.";
8790
"PrivilegedHelper" = "Asistente privilegiado";
8891
"PrivilegedHelperDescription" = "Xcodes utiliza un asistente privilegiado independiente para realizar tareas como root. Estas son cosas que requerirían sudo en la línea de comandos, incluidos los pasos posteriores a la instalación y el cambio de versiones de Xcode con xcode-select.\n\nSe le pedirá la contraseña de su cuenta de macOS para instalarlo.";
8992
"HelperInstalled" = "El Asistente está instalado";

0 commit comments

Comments
 (0)