diff --git a/Xcodes.xcodeproj/project.pbxproj b/Xcodes.xcodeproj/project.pbxproj index 7d23bd91..6da1dd12 100644 --- a/Xcodes.xcodeproj/project.pbxproj +++ b/Xcodes.xcodeproj/project.pbxproj @@ -99,6 +99,7 @@ CAFE4AB425B7D3AF0064FE51 /* AdvancedPreferencePane.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAFE4AB325B7D3AF0064FE51 /* AdvancedPreferencePane.swift */; }; CAFE4ABC25B7D54B0064FE51 /* UpdatesPreferencePane.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAFE4ABB25B7D54B0064FE51 /* UpdatesPreferencePane.swift */; }; CAFFFED8259CDA5000903F81 /* XcodeListViewRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAFFFED7259CDA5000903F81 /* XcodeListViewRow.swift */; }; + E689540325BE8C64000EBCEA /* DockProgress in Frameworks */ = {isa = PBXBuildFile; productRef = E689540225BE8C64000EBCEA /* DockProgress */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -276,6 +277,7 @@ CAFE4AA325B7CF960064FE51 /* Preferences in Frameworks */, CABFA9E42592F08E00380FEE /* Version in Frameworks */, CABFA9FD2592F13300380FEE /* LegibleError in Frameworks */, + E689540325BE8C64000EBCEA /* DockProgress in Frameworks */, CA9FF86D25951C6E00E47BAF /* XCModel in Frameworks */, CABFA9F82592F0F900380FEE /* KeychainAccess in Frameworks */, CAA858CD25A3D8BC00ACF8C0 /* ErrorHandling in Frameworks */, @@ -591,6 +593,7 @@ CAA858CC25A3D8BC00ACF8C0 /* ErrorHandling */, CAFE4A9925B7C7A30064FE51 /* Sparkle */, CAFE4AA225B7CF960064FE51 /* Preferences */, + E689540225BE8C64000EBCEA /* DockProgress */, ); productName = XcodesMac; productReference = CAD2E79E2449574E00113D76 /* Xcodes.app */; @@ -659,6 +662,7 @@ CAC28186259EE27200B8AB0B /* XCRemoteSwiftPackageReference "CombineExpectations" */, CAFE4A9825B7C7A30064FE51 /* XCRemoteSwiftPackageReference "Sparkle" */, CAFE4AA125B7CF960064FE51 /* XCRemoteSwiftPackageReference "Preferences" */, + E689540125BE8C64000EBCEA /* XCRemoteSwiftPackageReference "DockProgress" */, ); productRefGroup = CAD2E79F2449574E00113D76 /* Products */; projectDirPath = ""; @@ -1341,6 +1345,14 @@ minimumVersion = 2.2.0; }; }; + E689540125BE8C64000EBCEA /* XCRemoteSwiftPackageReference "DockProgress" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/sindresorhus/DockProgress"; + requirement = { + kind = upToNextMinorVersion; + minimumVersion = 3.2.0; + }; + }; /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ @@ -1398,6 +1410,11 @@ package = CAFE4AA125B7CF960064FE51 /* XCRemoteSwiftPackageReference "Preferences" */; productName = Preferences; }; + E689540225BE8C64000EBCEA /* DockProgress */ = { + isa = XCSwiftPackageProductDependency; + package = E689540125BE8C64000EBCEA /* XCRemoteSwiftPackageReference "DockProgress" */; + productName = DockProgress; + }; /* 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 525b3234..8fd5d662 100644 --- a/Xcodes.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Xcodes.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -19,6 +19,15 @@ "version": null } }, + { + "package": "DockProgress", + "repositoryURL": "https://github.com/sindresorhus/DockProgress", + "state": { + "branch": null, + "revision": "7100b68571e2dafe3a06ad5905b80fc3b0107b4b", + "version": "3.2.0" + } + }, { "package": "ErrorHandling", "repositoryURL": "https://github.com/RobotsAndPencils/ErrorHandling", diff --git a/Xcodes/Backend/AppState+Install.swift b/Xcodes/Backend/AppState+Install.swift index 8f41d670..685b8692 100644 --- a/Xcodes/Backend/AppState+Install.swift +++ b/Xcodes/Backend/AppState+Install.swift @@ -5,6 +5,7 @@ import AppleAPI import Version import LegibleError import os.log +import DockProgress /// Downloads and installs Xcodes extension AppState { @@ -119,6 +120,7 @@ extension AppState { cookies ) progressChanged(progress) + updateDockIcon(withProgress: progress) return publisher .map { _ in destination.url } .eraseToAnyPublisher() @@ -128,11 +130,12 @@ extension AppState { let resumeDataPath = Path.xcodesApplicationSupport/"Xcode-\(availableXcode.version).resumedata" let persistedResumeData = Current.files.contents(atPath: resumeDataPath.string) - return attemptResumableTask(maximumRetryCount: 3) { resumeData -> AnyPublisher in + return attemptResumableTask(maximumRetryCount: 3) { [weak self] resumeData -> AnyPublisher in let (progress, publisher) = Current.network.downloadTask(with: availableXcode.url, to: destination.url, resumingWith: resumeData ?? persistedResumeData) progressChanged(progress) + self?.updateDockIcon(withProgress: progress) return publisher .map { $0.saveLocation } .eraseToAnyPublisher() @@ -142,6 +145,11 @@ extension AppState { }) .eraseToAnyPublisher() } + + private func updateDockIcon(withProgress progress: Progress) { + DockProgress.style = .bar + DockProgress.progressInstance = progress + } public func installArchivedXcode(_ availableXcode: AvailableXcode, at archiveURL: URL) -> AnyPublisher { do { diff --git a/Xcodes/Backend/AppState.swift b/Xcodes/Backend/AppState.swift index 0f34ca84..16e659a3 100644 --- a/Xcodes/Backend/AppState.swift +++ b/Xcodes/Backend/AppState.swift @@ -6,6 +6,7 @@ import LegibleError import KeychainAccess import Path import Version +import DockProgress class AppState: ObservableObject { private let client = AppleAPI.Client() @@ -298,6 +299,9 @@ class AppState: ObservableObject { // Cancel the publisher installationPublishers[id] = nil + + // Remove dock icon progress indicator + DockProgress.progress = 1 // Only way to completely remove overlay with DockProgress is setting progress to complete // If the download is cancelled by the user, clean up the download files that aria2 creates. // This isn't done as part of the publisher with handleEvents(receiveCancel:) because it shouldn't happen when e.g. the app quits. diff --git a/Xcodes/Frontend/XcodeList/InstallationStepView.swift b/Xcodes/Frontend/XcodeList/InstallationStepView.swift index d88a775b..ecdc27e6 100644 --- a/Xcodes/Frontend/XcodeList/InstallationStepView.swift +++ b/Xcodes/Frontend/XcodeList/InstallationStepView.swift @@ -17,7 +17,7 @@ struct InstallationStepView: View { controlSize: .small, style: .spinning ) - .help("Dowloading: \(Int((progress.fractionCompleted * 100)))% complete") + .help("Downloading: \(Int((progress.fractionCompleted * 100)))% complete") case .unarchiving, .moving, .trashingArchive, .checkingSecurity, .finishing: ProgressView() .scaleEffect(0.5) diff --git a/Xcodes/Resources/Licenses.rtf b/Xcodes/Resources/Licenses.rtf index 9636214b..4345aa6b 100644 --- a/Xcodes/Resources/Licenses.rtf +++ b/Xcodes/Resources/Licenses.rtf @@ -323,6 +323,21 @@ For more information, please refer to <>\ otherwise be required by Sections 4(a), 4(b) and 4(d) of the License.\ \ +\fs34 DockProgress\ +\ + +\fs26 MIT License\ +\ +Copyright (c) Sindre Sorhus (sindresorhus.com)\ +\ +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\ +\ +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\ +\ +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\ +\ +\ + \fs34 KeychainAccess\ \