Add Show in Finder button to download view

This commit is contained in:
Nindi Gill 2023-04-16 19:08:45 +10:00
parent e9543a4a8a
commit 0392412d3e
No known key found for this signature in database
GPG key ID: FF9A7FD590D4F4B1

View file

@ -16,6 +16,8 @@ struct DownloadView: View {
var presentationMode: Binding<PresentationMode> var presentationMode: Binding<PresentationMode>
@AppStorage("enableNotifications") @AppStorage("enableNotifications")
private var enableNotifications: Bool = false private var enableNotifications: Bool = false
@AppStorage("showInFinder")
private var showInFinder: Bool = false
var downloadType: DownloadType var downloadType: DownloadType
var imageName: String var imageName: String
var name: String var name: String
@ -63,9 +65,13 @@ struct DownloadView: View {
} }
} }
Divider() Divider()
HStack {
Toggle("Show in Finder upon completion", isOn: $showInFinder)
Spacer()
Button(buttonText) { Button(buttonText) {
stop() stop()
} }
}
.padding() .padding()
} }
.frame(width: width, height: height) .frame(width: width, height: height)
@ -137,6 +143,14 @@ struct DownloadView: View {
if enableNotifications { if enableNotifications {
sendNotification(for: downloadType, name: name, version: version, build: build, success: true) sendNotification(for: downloadType, name: name, version: version, build: build, success: true)
} }
if showInFinder {
guard let url: URL = destinationURL else {
return
}
NSWorkspace.shared.selectFile(url.path, inFileViewerRootedAtPath: "")
}
} }
private func checkForUserCancellation(_ failure: Error) -> Bool { private func checkForUserCancellation(_ failure: Error) -> Bool {