Skip to content

Commit

Permalink
Spruce up Bottle Context Menu + Closure Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacMarovitz committed Nov 3, 2023
1 parent 8f3ad21 commit 6f7075a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 24 deletions.
6 changes: 3 additions & 3 deletions Whisky/Views/Common/BottomBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ private struct BottomBarViewModifier<BarContent>: ViewModifier where BarContent:

struct BottomBarButtonStyle: PrimitiveButtonStyle {
func makeBody(configuration: Configuration) -> some View {
Button(action: {
Button {
configuration.trigger()
}, label: {
} label: {
configuration.label
.foregroundStyle(.foreground)
})
}
}
}

Expand Down
20 changes: 12 additions & 8 deletions Whisky/Views/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,17 @@ struct BottleListEntry: View {
BottleRenameView(bottle: bottle, name: $name)
}
.contextMenu {
Button("button.rename") {
Button("button.rename", systemImage: "pencil.line") {
showBottleRename.toggle()
}
.disabled(!bottle.isActive)
.labelStyle(.titleAndIcon)
Button("button.removeAlert", systemImage: "trash") {
showRemoveAlert(bottle: bottle)
}
.labelStyle(.titleAndIcon)
Divider()
Button("button.moveBottle") {
Button("button.moveBottle", systemImage: "shippingbox.and.arrow.backward") {
let panel = NSOpenPanel()
panel.canChooseFiles = false
panel.canChooseDirectories = true
Expand All @@ -218,7 +223,8 @@ struct BottleListEntry: View {
}
}
.disabled(!bottle.isActive)
Button("button.exportBottle") {
.labelStyle(.titleAndIcon)
Button("button.exportBottle", systemImage: "arrowshape.turn.up.right") {
let panel = NSSavePanel()
panel.canCreateDirectories = true
panel.allowedContentTypes = [UTType.gzip]
Expand All @@ -236,15 +242,13 @@ struct BottleListEntry: View {
}
}
.disabled(!bottle.isActive)
.labelStyle(.titleAndIcon)
Divider()
Button("button.showInFinder") {
Button("button.showInFinder", systemImage: "folder") {
NSWorkspace.shared.activateFileViewerSelecting([bottle.url])
}
.disabled(!bottle.isActive)
Divider()
Button("button.removeAlert") {
showRemoveAlert(bottle: bottle)
}
.labelStyle(.titleAndIcon)
}
}

Expand Down
16 changes: 9 additions & 7 deletions Whisky/Views/Programs/ProgramMenuView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,27 @@ struct ProgramMenuView: View {
@Binding var path: NavigationPath

var body: some View {
Button("button.run", systemImage: "play", action: {
Button("button.run", systemImage: "play") {
Task {
await program.run()
}
}).labelStyle(.titleAndIcon)

}
.labelStyle(.titleAndIcon)
Section("program.settings") {
Button("program.config", systemImage: "gearshape", action: {
Button("program.config", systemImage: "gearshape") {
path.append(program)
}).labelStyle(.titleAndIcon)
}
.labelStyle(.titleAndIcon)

let buttonName = program.pinned
? String(localized: "button.unpin")
: String(localized: "button.pin")

let iconName = program.pinned ? "pin.slash" : "pin"
Button(buttonName, systemImage: iconName, action: {
Button(buttonName, systemImage: iconName) {
program.pinned.toggle()
}).labelStyle(.titleAndIcon)
}
.labelStyle(.titleAndIcon)
}
}
}
12 changes: 6 additions & 6 deletions Whisky/Views/Programs/ProgramsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,18 +158,18 @@ struct ProgramItemView: View {
)
}

Button("program.config", systemImage: "gearshape", action: {
Button("program.config", systemImage: "gearshape") {
path.append(program)
})
}
.labelStyle(.iconOnly)
.buttonStyle(.plain)
.foregroundStyle(.secondary)
.help("program.config")
Button("button.run", systemImage: "play", action: {
Button("button.run", systemImage: "play") {
Task {
await program.run()
}
})
}
.labelStyle(.iconOnly)
.buttonStyle(.plain)
.foregroundStyle(.secondary)
Expand All @@ -193,9 +193,9 @@ struct BlocklistItemView: View {
Text(blockedUrl.prettyPath(bottle))
Spacer()
if showButtons {
Button("program.remove.blocklist", systemImage: "xmark.circle.fill", action: {
Button("program.remove.blocklist", systemImage: "xmark.circle.fill") {
bottle.settings.blocklist.removeAll { $0 == blockedUrl }
})
}
.labelStyle(.iconOnly)
.buttonStyle(.plain)
.foregroundColor(.secondary)
Expand Down

0 comments on commit 6f7075a

Please sign in to comment.