feat: add Finder, ranking reset, and quit actions
This commit is contained in:
@@ -6,9 +6,12 @@ final class ApplicationActionsController: NSViewController, NSSearchFieldDelegat
|
||||
private let search = ActionsSearchField()
|
||||
private let entries = [
|
||||
ActionEntry(title: "Open", symbol: "arrow.up.forward.app", color: SunsetPalette.text),
|
||||
ActionEntry(title: "Show in Finder", symbol: "folder", color: SunsetPalette.text),
|
||||
ActionEntry(title: "Reset ranking", symbol: "arrow.counterclockwise", color: SunsetPalette.text),
|
||||
ActionEntry(title: "Quit application", symbol: "stop.circle", color: SunsetPalette.text),
|
||||
ActionEntry(title: "Uninstall application", symbol: "trash", color: .systemRed)
|
||||
]
|
||||
private var visibleEntries = [0, 1]
|
||||
private var visibleEntries: [Int] = []
|
||||
private var selectedEntry: Int? = 0
|
||||
private var rowTopConstraints: [NSLayoutConstraint] = []
|
||||
private var heightConstraint: NSLayoutConstraint?
|
||||
@@ -21,6 +24,9 @@ final class ApplicationActionsController: NSViewController, NSSearchFieldDelegat
|
||||
private var transitionGeneration = 0
|
||||
private var panel: ActionsPanelView { view as! ActionsPanelView }
|
||||
var open: (() -> Void)?
|
||||
var showInFinder: (() -> Void)?
|
||||
var resetRanking: (() -> Void)?
|
||||
var quit: (() -> Void)?
|
||||
var uninstall: (() -> Void)?
|
||||
var closed: (() -> Void)?
|
||||
var isShown: Bool { viewIfLoaded?.superview != nil && !isClosing }
|
||||
@@ -88,7 +94,7 @@ final class ApplicationActionsController: NSViewController, NSSearchFieldDelegat
|
||||
top
|
||||
])
|
||||
}
|
||||
let height = view.heightAnchor.constraint(equalToConstant: 116 + LauncherRowView.rowHeight)
|
||||
let height = view.heightAnchor.constraint(equalToConstant: 116 + CGFloat(entries.count - 1) * LauncherRowView.rowHeight)
|
||||
heightConstraint = height
|
||||
NSLayoutConstraint.activate([
|
||||
view.widthAnchor.constraint(equalToConstant: 360), height,
|
||||
@@ -234,7 +240,14 @@ final class ApplicationActionsController: NSViewController, NSSearchFieldDelegat
|
||||
private func chooseAction(at index: Int) {
|
||||
guard isShown, visibleEntries.contains(index) else { return }
|
||||
close()
|
||||
if index == 0 { open?() } else { uninstall?() }
|
||||
switch index {
|
||||
case 0: open?()
|
||||
case 1: showInFinder?()
|
||||
case 2: resetRanking?()
|
||||
case 3: quit?()
|
||||
case 4: uninstall?()
|
||||
default: break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user