Skip to content

Commit

Permalink
Revert unrelated changes
Browse files Browse the repository at this point in the history
  • Loading branch information
zorikon committed Apr 8, 2024
1 parent 8c4c029 commit 91b1f1f
Showing 1 changed file with 22 additions and 29 deletions.
51 changes: 22 additions & 29 deletions Whisky/Views/Bottle/Pins/PinCreationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
}
}
}
Expand All @@ -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")")
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 91b1f1f

Please sign in to comment.