From 91b1f1f6ec89fce47b63e49efff48f977c311444 Mon Sep 17 00:00:00 2001 From: Ivan Zorin <6960799+zorikon@users.noreply.github.com> Date: Mon, 8 Apr 2024 18:46:44 +0400 Subject: [PATCH] Revert unrelated changes --- .../Views/Bottle/Pins/PinCreationView.swift | 51 ++++++++----------- 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/Whisky/Views/Bottle/Pins/PinCreationView.swift b/Whisky/Views/Bottle/Pins/PinCreationView.swift index 0316d17e..eada6be9 100644 --- a/Whisky/Views/Bottle/Pins/PinCreationView.swift +++ b/Whisky/Views/Bottle/Pins/PinCreationView.swift @@ -35,24 +35,36 @@ struct PinCreationView: View { Form { TextField("pin.name", text: $newPinName) - HStack(alignment: .top) { + HStack { VStack(alignment: .leading) { Text("pin.path") .foregroundStyle(.primary) - if !pinPath.isEmpty { - Text(pinPath) - .font(.callout) - .foregroundStyle(.secondary) - .truncationMode(.middle) - .lineLimit(2) - .help(pinPath) - } + Text(pinPath) + .foregroundStyle(.secondary) + .truncationMode(.middle) + .lineLimit(2) + .help(pinPath) } Spacer() Button("create.browse") { - openPanel() + let panel = NSOpenPanel() + panel.canChooseFiles = true + panel.allowedContentTypes = [UTType.exe, + UTType(exportedAs: "com.microsoft.msi-installer"), + UTType(exportedAs: "com.microsoft.bat")] + panel.directoryURL = newPinURL ?? bottle.url.appending(path: "drive_c") + panel.canChooseDirectories = false + panel.allowsMultipleSelection = false + panel.canCreateDirectories = false + panel.begin { result in + if result == .OK { + if let url = panel.urls.first { + newPinURL = url + } + } + } } } } @@ -72,7 +84,6 @@ struct PinCreationView: View { .keyboardShortcut(.defaultAction) .disabled(newPinName.isEmpty || newPinURL == nil) .alert("pin.error.title", isPresented: $isDuplicate) { - // no actions } message: { Text("pin.error.duplicate.\(newPinURL?.lastPathComponent ?? "unknown")") } @@ -114,24 +125,6 @@ struct PinCreationView: View { bottle.updateInstalledPrograms() dismiss() } - - private func openPanel() { - let panel = NSOpenPanel() - panel.canChooseFiles = true - panel.allowedContentTypes = [ - UTType.exe, - UTType(exportedAs: "com.microsoft.msi-installer"), - UTType(exportedAs: "com.microsoft.bat")] - panel.directoryURL = newPinURL ?? bottle.url.appending(path: "drive_c") - panel.canChooseDirectories = false - panel.allowsMultipleSelection = false - panel.canCreateDirectories = false - panel.begin { result in - if result == .OK, let url = panel.urls.first { - newPinURL = url - } - } - } } #Preview {