@@ -4,19 +4,16 @@ import Path
44
55struct 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
199139struct AdvancedPreferencePane_Previews : PreviewProvider {
0 commit comments