diff --git a/Xcodes.xcodeproj/project.pbxproj b/Xcodes.xcodeproj/project.pbxproj index e016f2f..88c61ec 100644 --- a/Xcodes.xcodeproj/project.pbxproj +++ b/Xcodes.xcodeproj/project.pbxproj @@ -95,7 +95,6 @@ CAFBDC68259A308B003DCC5A /* InfoPane.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAFBDC67259A308B003DCC5A /* InfoPane.swift */; }; CAFBDC6C259A3098003DCC5A /* View+Conditional.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAFBDC6B259A3098003DCC5A /* View+Conditional.swift */; }; CAFE4A9A25B7C7A30064FE51 /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = CAFE4A9925B7C7A30064FE51 /* Sparkle */; }; - CAFE4AA325B7CF960064FE51 /* Preferences in Frameworks */ = {isa = PBXBuildFile; productRef = CAFE4AA225B7CF960064FE51 /* Preferences */; }; CAFE4AAC25B7D2C70064FE51 /* GeneralPreferencePane.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAFE4AAB25B7D2C70064FE51 /* GeneralPreferencePane.swift */; }; CAFE4AB425B7D3AF0064FE51 /* AdvancedPreferencePane.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAFE4AB325B7D3AF0064FE51 /* AdvancedPreferencePane.swift */; }; CAFE4ABC25B7D54B0064FE51 /* UpdatesPreferencePane.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAFE4ABB25B7D54B0064FE51 /* UpdatesPreferencePane.swift */; }; @@ -277,7 +276,6 @@ buildActionMask = 2147483647; files = ( CAFE4A9A25B7C7A30064FE51 /* Sparkle in Frameworks */, - CAFE4AA325B7CF960064FE51 /* Preferences in Frameworks */, CABFA9E42592F08E00380FEE /* Version in Frameworks */, CABFA9FD2592F13300380FEE /* LegibleError in Frameworks */, CA9FF86D25951C6E00E47BAF /* XCModel in Frameworks */, @@ -596,7 +594,6 @@ CA9FF86C25951C6E00E47BAF /* XCModel */, CAA858CC25A3D8BC00ACF8C0 /* ErrorHandling */, CAFE4A9925B7C7A30064FE51 /* Sparkle */, - CAFE4AA225B7CF960064FE51 /* Preferences */, ); productName = XcodesMac; productReference = CAD2E79E2449574E00113D76 /* Xcodes.app */; @@ -664,7 +661,6 @@ CAA858CB25A3D8BC00ACF8C0 /* XCRemoteSwiftPackageReference "ErrorHandling" */, CAC28186259EE27200B8AB0B /* XCRemoteSwiftPackageReference "CombineExpectations" */, CAFE4A9825B7C7A30064FE51 /* XCRemoteSwiftPackageReference "Sparkle" */, - CAFE4AA125B7CF960064FE51 /* XCRemoteSwiftPackageReference "Preferences" */, ); productRefGroup = CAD2E79F2449574E00113D76 /* Products */; projectDirPath = ""; @@ -1341,14 +1337,6 @@ version = "1.24.0-spm"; }; }; - CAFE4AA125B7CF960064FE51 /* XCRemoteSwiftPackageReference "Preferences" */ = { - isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/sindresorhus/Preferences"; - requirement = { - kind = upToNextMinorVersion; - minimumVersion = 2.2.0; - }; - }; /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ @@ -1401,11 +1389,6 @@ package = CAFE4A9825B7C7A30064FE51 /* XCRemoteSwiftPackageReference "Sparkle" */; productName = Sparkle; }; - CAFE4AA225B7CF960064FE51 /* Preferences */ = { - isa = XCSwiftPackageProductDependency; - package = CAFE4AA125B7CF960064FE51 /* XCRemoteSwiftPackageReference "Preferences" */; - productName = Preferences; - }; /* End XCSwiftPackageProductDependency section */ }; rootObject = CAD2E7962449574E00113D76 /* Project object */; diff --git a/Xcodes.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Xcodes.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 525b323..c92db7b 100644 --- a/Xcodes.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Xcodes.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -55,15 +55,6 @@ "version": "0.16.3" } }, - { - "package": "Preferences", - "repositoryURL": "https://github.com/sindresorhus/Preferences", - "state": { - "branch": null, - "revision": "4802a493acef50c814e4eb63e9a44e0941ec8883", - "version": "2.2.0" - } - }, { "package": "Sparkle", "repositoryURL": "https://github.com/sparkle-project/Sparkle/", diff --git a/Xcodes/Frontend/Preferences/AdvancedPreferencePane.swift b/Xcodes/Frontend/Preferences/AdvancedPreferencePane.swift index 1b1d90d..95df7ac 100644 --- a/Xcodes/Frontend/Preferences/AdvancedPreferencePane.swift +++ b/Xcodes/Frontend/Preferences/AdvancedPreferencePane.swift @@ -1,5 +1,4 @@ import AppleAPI -import Preferences import SwiftUI struct AdvancedPreferencePane: View { @@ -8,8 +7,8 @@ struct AdvancedPreferencePane: View { @AppStorage("downloader") var downloader: Downloader = .aria2 var body: some View { - Preferences.Container(contentWidth: 400.0) { - Preferences.Section(title: "Data Source") { + VStack(alignment: .leading, spacing: 20) { + GroupBox(label: Text("DataSource")) { VStack(alignment: .leading) { Picker("Data Source", selection: $dataSource) { ForEach(DataSource.allCases) { dataSource in @@ -21,10 +20,11 @@ struct AdvancedPreferencePane: View { AttributedText(dataSourceFootnote) } - .frame(maxWidth: .infinity, alignment: .leading) + } + .groupBoxStyle(PreferencesGroupBoxStyle()) - Preferences.Section(title: "Downloader") { + GroupBox(label: Text("Downloader")) { VStack(alignment: .leading) { Picker("Downloader", selection: $downloader) { ForEach(Downloader.allCases) { downloader in @@ -36,10 +36,11 @@ struct AdvancedPreferencePane: View { AttributedText(downloaderFootnote) } - .frame(maxWidth: .infinity, alignment: .leading) + } + .groupBoxStyle(PreferencesGroupBoxStyle()) - Preferences.Section(title: "Privileged Helper") { + GroupBox(label: Text("Privileged Helper")) { VStack(alignment: .leading, spacing: 8) { switch appState.helperInstallState { case .unknown: @@ -63,8 +64,10 @@ struct AdvancedPreferencePane: View { Spacer() } } + .groupBoxStyle(PreferencesGroupBoxStyle()) } - .padding(.trailing) + .padding() + .frame(width: 500) } private var dataSourceFootnote: NSAttributedString { @@ -110,3 +113,20 @@ struct AdvancedPreferencePane_Previews: PreviewProvider { } } } + +// A group style for the preferences +struct PreferencesGroupBoxStyle: GroupBoxStyle { + func makeBody(configuration: Configuration) -> some View { + HStack(alignment: .top, spacing: 20) { + HStack { + Spacer() + configuration.label + } + .frame(width: 120) + + VStack(alignment: .leading) { + configuration.content + } + } + } +} diff --git a/Xcodes/Frontend/Preferences/GeneralPreferencePane.swift b/Xcodes/Frontend/Preferences/GeneralPreferencePane.swift index 2bb7e81..a8a1ebe 100644 --- a/Xcodes/Frontend/Preferences/GeneralPreferencePane.swift +++ b/Xcodes/Frontend/Preferences/GeneralPreferencePane.swift @@ -1,36 +1,36 @@ import AppleAPI -import Preferences import SwiftUI struct GeneralPreferencePane: View { @EnvironmentObject var appState: AppState var body: some View { - Preferences.Container(contentWidth: 400.0) { - Preferences.Section(title: "Apple ID") { - VStack(alignment: .leading) { + VStack(alignment: .leading) { + GroupBox(label: Text("Apple ID")) { // If we have saved a username then we will show it here, // even if we don't have a valid session right now, // because we should be able to get a valid session if needed with the password in the keychain // and a 2FA code from the user. // Note that AppState.authenticationState is not necessarily .authenticated in this case, though. if let username = Current.defaults.string(forKey: "username") { - Text(username) - Button("Sign Out", action: appState.signOut) + HStack(alignment:.top, spacing: 10) { + Text(username) + Button("Sign Out", action: appState.signOut) + } + .frame(maxWidth: .infinity, alignment: .leading) } else { Button("Sign In", action: { self.appState.presentingSignInAlert = true }) + .frame(maxWidth: .infinity, alignment: .leading) } - - Spacer() - } - .frame(maxWidth: .infinity, alignment: .leading) - .sheet(isPresented: $appState.presentingSignInAlert) { - SignInCredentialsView(isPresented: $appState.presentingSignInAlert) - .environmentObject(appState) - } + } + .groupBoxStyle(PreferencesGroupBoxStyle()) + .sheet(isPresented: $appState.presentingSignInAlert) { + SignInCredentialsView(isPresented: $appState.presentingSignInAlert) + .environmentObject(appState) } } - .padding(.trailing) + .padding() + .frame(width: 500) } } diff --git a/Xcodes/Frontend/Preferences/UpdatesPreferencePane.swift b/Xcodes/Frontend/Preferences/UpdatesPreferencePane.swift index 4a29e6e..c557f6c 100644 --- a/Xcodes/Frontend/Preferences/UpdatesPreferencePane.swift +++ b/Xcodes/Frontend/Preferences/UpdatesPreferencePane.swift @@ -1,5 +1,4 @@ import AppleAPI -import Preferences import Sparkle import SwiftUI @@ -7,30 +6,30 @@ struct UpdatesPreferencePane: View { @StateObject var updater = ObservableUpdater() var body: some View { - Preferences.Container(contentWidth: 400.0) { - Preferences.Section(title: "Updates") { - VStack(alignment: .leading) { - Toggle( - "Automatically check for app updates", - isOn: $updater.automaticallyChecksForUpdates - ) - - Toggle( - "Include prerelease app versions", - isOn: $updater.includePrereleaseVersions - ) - - Button("Check Now") { - SUUpdater.shared()?.checkForUpdates(nil) - } - - Text("Last checked: \(lastUpdatedString)") - .font(.footnote) + GroupBox(label: Text("Updates")) { + VStack(alignment: .leading) { + Toggle( + "Automatically check for app updates", + isOn: $updater.automaticallyChecksForUpdates + ) + + Toggle( + "Include prerelease app versions", + isOn: $updater.includePrereleaseVersions + ) + + Button("Check Now") { + SUUpdater.shared()?.checkForUpdates(nil) } - .frame(maxWidth: .infinity, alignment: .leading) + + Text("Last checked: \(lastUpdatedString)") + .font(.footnote) } + .frame(maxWidth: .infinity, alignment: .leading) } - .padding(.trailing) + .groupBoxStyle(PreferencesGroupBoxStyle()) + .padding() + .frame(width: 500) } private var lastUpdatedString: String { diff --git a/Xcodes/XcodesApp.swift b/Xcodes/XcodesApp.swift index 188fbe9..76f5186 100644 --- a/Xcodes/XcodesApp.swift +++ b/Xcodes/XcodesApp.swift @@ -1,5 +1,4 @@ import AppKit -import Preferences import Sparkle import SwiftUI