Skip to content

Commit

Permalink
feat: Open folders from the context menu (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbmorley authored Jun 24, 2024
1 parent aeb3a06 commit 36402a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Reconnect/Extensions/String.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ import Foundation

extension String {

var isDirectory: Bool {
return hasSuffix("\\")
}

var windowsLastPathComponent: String {
return components(separatedBy: "\\").filter { !$0.isEmpty }.last ?? ""
}
Expand Down
8 changes: 5 additions & 3 deletions Reconnect/Views/BrowserView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,15 @@ struct BrowserView: View {
}
}
.contextMenu(forSelectionType: FileServer.DirectoryEntry.ID.self) { items in
Button("Hello, World!") {

Button("Open") {
model.navigate(to: items.first!)
}
.disabled(items.count != 1 || !(items.first?.isDirectory ?? false))
} primaryAction: { items in
guard
items.count == 1,
let item = items.first
let item = items.first,
item.isDirectory
else {
return
}
Expand Down

0 comments on commit 36402a0

Please sign in to comment.