Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Give the buttons of every page one rule

Țugui Dragoș40e8d91a5469
diff --git a/AGENTS.md b/AGENTS.md
index b9cd3dbf..564bd98b 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -386,10 +386,13 @@ Peel runs on macOS 26 and later, and the two versions are treated differently in
accent color read under the 4.5:1 text needs on a light background. The color goes on a symbol beside the words,
which keep the style of the text around them: `StatusLabel` for a warning or a state, a `Badge`'s `tint`, and a
note's `caution`.
-- **The buttons at the foot of a page go in `ActionRow`:** of two, what leads elsewhere stands at the left end and the
- main action at the right, one alone is centered, and `keepsTogether` holds the ones that act on the item itself in
- the middle. It gives each button a line of its own when a language's words leave no room, so never lay such a row
- out by hand. A sheet's footer stays on the right, and buttons under a title stay in a `FlowLayout`.
+- **A page's buttons follow one rule:** they go in `PageActions`, under its last group at the right, with no box and
+ no symbol, the main action last, laid out by `ActionRow`, which takes a second line at the right when a language's
+ words leave no room, so never lay such a row out by hand. What concerns one row sits at that row's right end in an
+ `HStack`, `ShowInFinderButton` on the row that says where the item is, and a section heading with nothing under it
+ holds its button through `HeadingWithActions`. Adding to and removing from a list are `+` and `-` at its foot
+ (`ListEditingButtons`). One button a page is prominent. A sheet's footer stays on the right, and buttons under a title
+ stay in a `FlowLayout`.
- Rows of a long list stay cheap to build. A checkbox in a row is `NativeCheckbox` beside the item, with
`checkboxTitleLine()` on the first line of its title and `checkboxTitle()` on the title, rather than a checkbox
`Toggle` whose label is the row; Duplicates' rows keep their `Toggle`, where the AppKit checkbox costs as much. A
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 21a2475c..009b4981 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -178,6 +178,8 @@ its changes the way [Keep a Changelog](https://keepachangelog.com/) suggests.
- App Folders takes a folder deeper inside an Applications folder than Peel looks, such as the one Unity Hub keeps
its editors in.
- Sidebar is the first section of General.
+- App Folders and Exclusions add and remove with `+` and `-` at the foot of each list, and the Helper tab keeps its
+ state and its buttons on one row.
#### Applications
@@ -306,9 +308,11 @@ its changes the way [Keep a Changelog](https://keepachangelog.com/) suggests.
the room the sidebar covered.
- A message about what couldn't be read says when the permissions of what it names kept Peel out, in the app and
from `peel`.
-- The buttons at the foot of a page follow one rule in every language: two stand at the ends of the row, one is
- centered, and those that act on the item itself stay together in the middle. Where a language's words leave no room
- on one line, each takes a line of its own rather than having its title cut.
+- The buttons of a page follow one rule in every language: they stand under its last group at the right, with no box
+ around them and no symbols, the main action last, and take a second line at the right where a language's words leave
+ no room. What concerns one row sits at that row's right end, and a section heading with nothing under it keeps its
+ button beside it.
+- Show in Finder is Finder's own symbol at the end of the row that says where the item is.
#### `peel`
diff --git a/Packages/PeelCore/Sources/PeelCore/Support/ActionRowPlan.swift b/Packages/PeelCore/Sources/PeelCore/Support/ActionRowPlan.swift
index 143c5b7b..01250c93 100644
--- a/Packages/PeelCore/Sources/PeelCore/Support/ActionRowPlan.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Support/ActionRowPlan.swift
@@ -1,39 +1,46 @@
public import CoreGraphics
-/// Where the buttons at the foot of a page go. One is centered, and two stand at the ends of the row, unless they are
-/// kept together in the middle. When a language's words leave no room on one line, each is centered on a line of its
-/// own, so no title is cut.
+/// Where the buttons of a page go: together at the right edge, the last, its main action, at the edge itself. When a
+/// language's words leave no room on one line, the first ones take a line above, also at the right edge.
public struct ActionRowPlan: Equatable, Sendable {
public let frames: [CGRect]
public let size: CGSize
/// - Parameter sizes: Each button's own size. What has no width, a group with nothing to show, takes no room.
- public init(sizes: [CGSize], width: CGFloat?, keepsTogether: Bool = false, spacing: CGFloat = 8) {
+ public init(sizes: [CGSize], width: CGFloat?, spacing: CGFloat = 8, lineSpacing: CGFloat = 6) {
let shown = sizes.indices.filter { sizes[$0].width > 0 }
let needed = shown.reduce(0) { $0 + sizes[$1].width } + spacing * CGFloat(max(shown.count - 1, 0))
let room = width.flatMap { $0.isFinite ? $0 : nil } ?? needed
- var frames = [CGRect](repeating: .zero, count: sizes.count)
- var height: CGFloat = 0
- if needed <= room {
- height = shown.reduce(0) { max($0, sizes[$1].height) }
- let atTheEnds = shown.count == 2 && !keepsTogether
- var x = (room - needed) / 2
- for index in shown {
- let size = sizes[index]
- if atTheEnds { x = index == shown[0] ? 0 : room - size.width }
- frames[index] = CGRect(origin: CGPoint(x: x, y: (height - size.height) / 2), size: size)
- x += size.width + spacing
+ var lines: [[Int]] = []
+ var used: CGFloat = 0
+ for index in shown.reversed() {
+ let width = min(sizes[index].width, room)
+ if let line = lines.first, !line.isEmpty, used + spacing + width <= room {
+ lines[0].insert(index, at: 0)
+ used += spacing + width
+ } else {
+ lines.insert([index], at: 0)
+ used = width
}
- } else {
- for index in shown {
+ }
+
+ var frames = [CGRect](repeating: .zero, count: sizes.count)
+ var y: CGFloat = 0
+ for line in lines {
+ let height = line.reduce(0) { max($0, sizes[$1].height) }
+ var x = room
+ for index in line.reversed() {
let width = min(sizes[index].width, room)
- frames[index] = CGRect(x: (room - width) / 2, y: height, width: width, height: sizes[index].height)
- height += sizes[index].height + spacing
+ x -= width
+ frames[index] = CGRect(
+ x: x, y: y + (height - sizes[index].height) / 2, width: width, height: sizes[index].height
+ )
+ x -= spacing
}
- height -= spacing
+ y += height + lineSpacing
}
self.frames = frames
- size = CGSize(width: room, height: height)
+ size = CGSize(width: room, height: lines.isEmpty ? 0 : y - lineSpacing)
}
}
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/ActionRowPlanTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/ActionRowPlanTests.swift
index ef21c538..f6232d28 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/ActionRowPlanTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/ActionRowPlanTests.swift
@@ -6,49 +6,35 @@ struct ActionRowPlanTests {
private let small = CGSize(width: 100, height: 28)
private let wide = CGSize(width: 300, height: 28)
- @Test func oneActionIsCentered() {
+ @Test func oneActionStandsAtTheRightEdge() {
let plan = ActionRowPlan(sizes: [small], width: 400)
- #expect(plan.frames == [CGRect(x: 150, y: 0, width: 100, height: 28)])
+ #expect(plan.frames == [CGRect(x: 300, y: 0, width: 100, height: 28)])
#expect(plan.size == CGSize(width: 400, height: 28))
}
- @Test func twoActionsStandAtTheEndsOfTheRow() {
- let plan = ActionRowPlan(sizes: [small, small], width: 400)
- #expect(plan.frames[0] == CGRect(x: 0, y: 0, width: 100, height: 28))
- #expect(plan.frames[1] == CGRect(x: 300, y: 0, width: 100, height: 28))
+ @Test func actionsStandTogetherAtTheRightEdgeWithTheLastAtIt() {
+ let plan = ActionRowPlan(sizes: [small, small, small], width: 400, spacing: 8)
+ #expect(plan.frames.map(\.minX) == [84, 192, 300])
#expect(plan.size.height == 28)
}
- @Test func twoActionsWithoutRoomTakeACenteredLineEach() {
- let plan = ActionRowPlan(sizes: [wide, small], width: 400, spacing: 8)
- #expect(plan.frames[0] == CGRect(x: 50, y: 0, width: 300, height: 28))
- #expect(plan.frames[1] == CGRect(x: 150, y: 36, width: 100, height: 28))
- #expect(plan.size == CGSize(width: 400, height: 64))
- }
-
- @Test func twoActionsThatJustFitStayOnOneLine() {
+ @Test func actionsThatJustFitStayOnOneLine() {
let plan = ActionRowPlan(sizes: [wide, small], width: 408, spacing: 8)
- #expect(plan.frames[0].minX == 0)
- #expect(plan.frames[1].maxX == 408)
+ #expect(plan.frames.map(\.minX) == [0, 308])
#expect(plan.size.height == 28)
}
- @Test func actionsKeptTogetherStayInTheMiddleHoweverManyTheyAre() {
- let two = ActionRowPlan(sizes: [small, small], width: 400, keepsTogether: true, spacing: 8)
- #expect(two.frames.map(\.minX) == [96, 204])
- let three = ActionRowPlan(sizes: [small, small, small], width: 400, keepsTogether: true, spacing: 8)
- #expect(three.frames.map(\.minX) == [42, 150, 258])
- }
-
- @Test func actionsKeptTogetherWithoutRoomTakeACenteredLineEach() {
- let plan = ActionRowPlan(sizes: [wide, wide], width: 400, keepsTogether: true, spacing: 8)
- #expect(plan.frames.map(\.minX) == [50, 50])
- #expect(plan.frames.map(\.minY) == [0, 36])
+ @Test func actionsWithoutRoomTakeAnotherLineAboveTheLastOnes() {
+ let plan = ActionRowPlan(sizes: [wide, small, small], width: 400, spacing: 8, lineSpacing: 6)
+ #expect(plan.frames[0] == CGRect(x: 100, y: 0, width: 300, height: 28))
+ #expect(plan.frames[1] == CGRect(x: 192, y: 34, width: 100, height: 28))
+ #expect(plan.frames[2] == CGRect(x: 300, y: 34, width: 100, height: 28))
+ #expect(plan.size == CGSize(width: 400, height: 62))
}
@Test func whatHasNoWidthTakesNoRoom() {
let plan = ActionRowPlan(sizes: [.zero, small], width: 400)
- #expect(plan.frames[1] == CGRect(x: 150, y: 0, width: 100, height: 28))
+ #expect(plan.frames[1] == CGRect(x: 300, y: 0, width: 100, height: 28))
#expect(plan.frames[0].size == .zero)
#expect(plan.size.height == 28)
}
@@ -63,7 +49,7 @@ struct ActionRowPlanTests {
#expect(plan.frames == [CGRect(x: 0, y: 0, width: 400, height: 28)])
}
- @Test func aRowOfTallerActionsCentersTheShorterOnTheLine() {
+ @Test func aTallerActionCentersTheOthersOnItsLine() {
let plan = ActionRowPlan(sizes: [CGSize(width: 100, height: 40), small], width: 400)
#expect(plan.frames[1].minY == 6)
#expect(plan.size.height == 40)
diff --git a/Peel/Views/ActionRow.swift b/Peel/Views/ActionRow.swift
index 912f202f..a184b891 100644
--- a/Peel/Views/ActionRow.swift
+++ b/Peel/Views/ActionRow.swift
@@ -1,11 +1,8 @@
import PeelCore
import SwiftUI
-/// The buttons at the foot of a page, laid out by `ActionRowPlan`: one is centered, and of two, what leads elsewhere
-/// goes at the left end and the main action at the right. `keepsTogether` is for buttons that all act on one thing.
+/// Buttons together at the right edge, the last, the page's main action, at the edge itself, as `ActionRowPlan` says.
struct ActionRow: Layout {
- var keepsTogether = false
-
func makeCache(subviews: Subviews) -> [CGSize] {
subviews.map { $0.sizeThatFits(.unspecified) }
}
@@ -29,6 +26,20 @@ struct ActionRow: Layout {
guard let width, size.width > width else { return size }
return subview.sizeThatFits(ProposedViewSize(width: width, height: nil))
}
- return ActionRowPlan(sizes: fitted, width: width, keepsTogether: keepsTogether)
+ return ActionRowPlan(sizes: fitted, width: width)
+ }
+}
+
+/// The buttons of a page, under its last group and outside any box, as System Settings has them under a list of
+/// accounts. An action that concerns one row stays at that row's right end.
+struct PageActions<Buttons: View>: View {
+ @ViewBuilder let buttons: Buttons
+
+ var body: some View {
+ // A grouped form keeps the box around a section's rows whatever their background, and none around a footer.
+ Section {
+ } footer: {
+ ActionRow { buttons }
+ }
}
}
diff --git a/Peel/Views/AppPageHeader.swift b/Peel/Views/AppPageHeader.swift
index 0d6c4298..582969a0 100644
--- a/Peel/Views/AppPageHeader.swift
+++ b/Peel/Views/AppPageHeader.swift
@@ -52,7 +52,7 @@ struct AppPageHeader: View {
VStack(alignment: .leading, spacing: 6) {
FlowLayout {
if let uninstaller = plan.vendorUninstaller {
- Button("Open Uninstaller", systemImage: "arrow.up.forward.app") {
+ Button("Open Uninstaller") {
NSWorkspace.shared.open(uninstaller)
}
.buttonStyle(.bordered)
@@ -197,7 +197,7 @@ struct AppPageHeader: View {
private func updateAction(for source: UpdateSource, version: String) -> some View {
switch source {
case .appStore:
- Button("Open App Store", systemImage: "bag") {
+ Button("Open App Store") {
let page = library.updateStatuses[plan.app.id]?.releaseNotes
NSWorkspace.shared.open(page ?? URL(string: "macappstore://showUpdatesPage")!)
}
@@ -224,13 +224,13 @@ struct AppPageHeader: View {
Text("Upgrading\u{2026}")
}
} else {
- Label("Upgrade with Homebrew", systemImage: "mug")
+ Text("Upgrade with Homebrew")
}
}
.buttonStyle(.borderedProminent)
.disabled(homebrew.runningCommand != nil || homebrew.quittingToUpgrade.isWaiting)
case .developer, .automatic:
- Button("Open \(plan.app.name)", systemImage: "arrow.up.forward.app") {
+ Button("Open \(plan.app.name)") {
NSWorkspace.shared.open(plan.app.url)
}
.buttonStyle(.borderedProminent)
diff --git a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift
index 16547ba2..41a40909 100644
--- a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift
+++ b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift
@@ -78,6 +78,9 @@ struct BackgroundItemDetailView: View {
Text(verbatim: program)
.textSelection(.enabled)
.help(Text(verbatim: program))
+ if finderURL?.path(percentEncoded: false) == program {
+ ShowInFinderButton(url: URL(filePath: program))
+ }
}
.labeledContentStyle(.oneLine)
}
@@ -86,6 +89,9 @@ struct BackgroundItemDetailView: View {
Text(verbatim: plist.abbreviatedPath)
.textSelection(.enabled)
.help(Text(verbatim: plist.path(percentEncoded: false)))
+ if finderURL == plist {
+ ShowInFinderButton(url: plist)
+ }
}
.labeledContentStyle(.oneLine)
}
@@ -258,12 +264,16 @@ struct BackgroundItemDetailView: View {
}
}
- if hasOwnControls || finderURL != nil {
+ if item.canMoveToTrash {
Section {
- if item.canMoveToTrash {
- RemovalsHeldBanner()
- }
- controls
+ RemovalsHeldBanner()
+ }
+ }
+
+ if hasOwnControls || item.canMoveToTrash {
+ PageActions {
+ if hasOwnControls { ownControls }
+ moveToTrash
}
}
}
@@ -407,27 +417,16 @@ struct BackgroundItemDetailView: View {
private var hasOwnControls: Bool { item.offersControls }
- /// A row for what acts on the job, and a row for what acts on its file.
- @ViewBuilder
- private var controls: some View {
- if hasOwnControls {
- ActionRow(keepsTogether: true) { ownControls }
- }
- if finderURL != nil || item.canMoveToTrash {
- ActionRow { fileControls }
- }
- }
-
private var ownControls: some View {
Group {
// Stopping takes the job out of launchd, and nothing else removes one whose file or app is gone.
if item.canOnlyBeStopped {
- Button("Stop", systemImage: "stop.fill") {
+ Button("Stop") {
Task { await backgroundItems.perform(.stop, on: item) }
}
.help(item.isFileGone ? Text(verbatim: "") : Text("Takes it out of launchd. Its file stays where it is, and it runs again only if something loads it again."))
} else if #available(macOS 27, *), item.isLeftByAGoneApp {
- Button("Remove", systemImage: "xmark.circle") {
+ Button("Remove") {
Task { await backgroundItems.perform(.remove, on: item) }
}
.help(removeHelp)
@@ -437,21 +436,21 @@ struct BackgroundItemDetailView: View {
if !item.isSeenOnlyWhileLoaded {
let isRunning = if case .running = item.state { true } else { false }
if !isRunning {
- Button("Start", systemImage: "play.fill") {
+ Button("Start") {
Task { await backgroundItems.perform(.start, on: item) }
}
.help(startHelp)
}
// A job that waits for its schedule is loaded too, and only this takes it out for now.
if item.state != .notLoaded {
- Button("Stop", systemImage: "stop.fill") {
+ Button("Stop") {
Task { await backgroundItems.perform(.stop, on: item) }
}
.help(Text("Takes it out of launchd until the next login or restart. Its file stays where it is."))
}
}
if item.isDisabled || item.mayBeDisabled {
- Button(item.isDisabled ? "Enable" : "Disable", systemImage: item.isDisabled ? "checkmark.circle" : "minus.circle") {
+ Button(item.isDisabled ? "Enable" : "Disable") {
Task { await backgroundItems.perform(item.isDisabled ? .enable : .disable, on: item) }
}
.help(item.isDisabled ? Text(verbatim: "") : Text("macOS won’t load it again from the next login or restart. If it’s running now, it may keep running until then."))
@@ -478,14 +477,9 @@ struct BackgroundItemDetailView: View {
}
@ViewBuilder
- private var fileControls: some View {
- if let finderURL {
- Button("Show in Finder", systemImage: "folder") {
- NSWorkspace.shared.activateFileViewerSelecting([finderURL])
- }
- }
+ private var moveToTrash: some View {
if item.canMoveToTrash {
- Button("Move to Trash", systemImage: "trash") {
+ Button("Move to Trash") {
isConfirmingTrash = true
}
.buttonStyle(.borderedProminent)
diff --git a/Peel/Views/CenteredInRow.swift b/Peel/Views/CenteredInRow.swift
deleted file mode 100644
index 53fe5dad..00000000
--- a/Peel/Views/CenteredInRow.swift
+++ /dev/null
@@ -1,8 +0,0 @@
-import SwiftUI
-
-extension View {
- /// A control alone in its box, centered in the row rather than left against one edge.
- func centeredInRow() -> some View {
- ActionRow { self }
- }
-}
diff --git a/Peel/Views/Duplicates/DuplicateGroupView.swift b/Peel/Views/Duplicates/DuplicateGroupView.swift
index c6b3d97c..c6b865f7 100644
--- a/Peel/Views/Duplicates/DuplicateGroupView.swift
+++ b/Peel/Views/Duplicates/DuplicateGroupView.swift
@@ -143,12 +143,12 @@ private struct DuplicateFileRow: View {
.help(Text(heldBack.explanation(keptInStepBy: file.syncedBy)))
// Where the copy is matters more than a look at it: what is done with it is done in Finder or on
- // another device. The folder symbol, the menu's for Show in Finder, is close to the eye's width, so
+ // another device. Finder's symbol is close to the eye's width, so
// the two buttons read as one column.
Button {
NSWorkspace.shared.activateFileViewerSelecting([file.url])
} label: {
- Label("Show in Finder", systemImage: "folder")
+ Label("Show in Finder", systemImage: "finder")
.minimumTarget()
}
.labelStyle(.iconOnly)
diff --git a/Peel/Views/Extensions/ExtensionDetailView.swift b/Peel/Views/Extensions/ExtensionDetailView.swift
index 34736c58..37391fac 100644
--- a/Peel/Views/Extensions/ExtensionDetailView.swift
+++ b/Peel/Views/Extensions/ExtensionDetailView.swift
@@ -105,14 +105,10 @@ struct ExtensionDetailView: View {
Section {
} header: {
- HStack(spacing: 8) {
+ HeadingWithActions {
heading("Turning It On and Off", explanation)
- Spacer(minLength: 8)
+ } actions: {
switchButton
- .buttonStyle(.borderless)
- // In a form, a button in a section header is drawn lighter than the header's title (a list
- // draws them alike), so the button is set to the title's weight.
- .fontWeight(.semibold)
}
}
}
@@ -153,20 +149,14 @@ struct ExtensionDetailView: View {
private var switchButton: some View {
switch item.turnedOnAndOffIn {
case .systemSettings:
- Button {
+ Button("Open System Settings") {
NSWorkspace.shared.open(AppExtensions.settingsURL)
- } label: {
- Text("Open System Settings")
- .minimumTarget()
}
case .safari:
- Button {
+ Button("Open Safari") {
if let safari = NSWorkspace.shared.urlForApplication(withBundleIdentifier: "com.apple.Safari") {
NSWorkspace.shared.open(safari)
}
- } label: {
- Text("Open Safari")
- .minimumTarget()
}
case .widgetGallery, .nowhere:
EmptyView()
diff --git a/Peel/Views/FileSearch/FileSearchFileView.swift b/Peel/Views/FileSearch/FileSearchFileView.swift
index 8f4142fc..fb92af14 100644
--- a/Peel/Views/FileSearch/FileSearchFileView.swift
+++ b/Peel/Views/FileSearch/FileSearchFileView.swift
@@ -26,6 +26,7 @@ struct FileSearchFileView: View {
Text(verbatim: file.url.abbreviatedPath)
.textSelection(.enabled)
.help(Text(verbatim: file.url.path(percentEncoded: false)))
+ ShowInFinderButton(url: file.url)
}
.labeledContentStyle(.oneLine)
LabeledContent("Size") {
@@ -57,14 +58,6 @@ struct FileSearchFileView: View {
} header: {
Text("Details")
}
-
- Section {
- ActionRow {
- Button("Show in Finder", systemImage: "folder") {
- NSWorkspace.shared.activateFileViewerSelecting([file.url])
- }
- }
- }
}
.formStyle(.grouped)
.navigationTitle(Text(verbatim: file.url.lastPathComponent))
diff --git a/Peel/Views/HeadingWithActions.swift b/Peel/Views/HeadingWithActions.swift
new file mode 100644
index 00000000..2a9d7ec0
--- /dev/null
+++ b/Peel/Views/HeadingWithActions.swift
@@ -0,0 +1,22 @@
+import SwiftUI
+
+/// A section's heading with the section's buttons beside it, at the right, for a section that holds nothing else. Where
+/// a language's words leave no room on one line, the buttons go under the heading.
+struct HeadingWithActions<Heading: View, Actions: View>: View {
+ @ViewBuilder let heading: Heading
+ @ViewBuilder let actions: Actions
+
+ var body: some View {
+ ViewThatFits(in: .horizontal) {
+ HStack(spacing: 8) {
+ heading
+ Spacer(minLength: 8)
+ actions
+ }
+ VStack(alignment: .leading, spacing: 8) {
+ heading
+ ActionRow { actions }
+ }
+ }
+ }
+}
diff --git a/Peel/Views/History/HistoryList.swift b/Peel/Views/History/HistoryList.swift
index 01eec4e8..83b204f5 100644
--- a/Peel/Views/History/HistoryList.swift
+++ b/Peel/Views/History/HistoryList.swift
@@ -151,7 +151,7 @@ private struct HistoryProblemNotice: View {
title: Text("The record of past removals was damaged"),
detail: Text("Peel kept the old file and continued with what it could still read. Items already in the Trash are still there: you can drag them back out in Finder.")
) {
- Button("Show in Finder", systemImage: "folder") {
+ Button("Show in Finder") {
NSWorkspace.shared.activateFileViewerSelecting([setAside])
}
}
@@ -190,7 +190,7 @@ private struct RefusalProblemNotice: View {
title: Text("The Not Moved list was damaged"),
detail: Text("Peel kept the old file and continued with what it could still read.")
) {
- Button("Show in Finder", systemImage: "folder") {
+ Button("Show in Finder") {
NSWorkspace.shared.activateFileViewerSelecting([setAside])
}
}
diff --git a/Peel/Views/Homebrew/HomebrewDetailView.swift b/Peel/Views/Homebrew/HomebrewDetailView.swift
index 84761c4a..5bf005eb 100644
--- a/Peel/Views/Homebrew/HomebrewDetailView.swift
+++ b/Peel/Views/Homebrew/HomebrewDetailView.swift
@@ -120,39 +120,19 @@ struct HomebrewDetailView: View {
Section {
if let reason = homebrew.whyItCantChange {
- Text(reason.detail)
- .font(.callout)
- .foregroundStyle(.secondary)
- if let command = reason.command {
- CopyButton(text: command)
+ HStack(spacing: 8) {
+ Text(reason.detail)
+ .font(.callout)
+ .foregroundStyle(.secondary)
+ if let command = reason.command {
+ Spacer(minLength: 8)
+ CopyButton(text: command)
+ }
}
} else {
if package.isMissingWhatItInstalled {
RemovalsHeldBanner()
}
- ActionRow {
- if isUninstalledInTerminal {
- CopyButton(
- text: Homebrew.terminalCommand(
- "brew uninstall --cask \(package.fullName)", keeping: homebrew.keptFormulaeNow
- ),
- title: "Copy Uninstall Command"
- )
- } else {
- Button("Uninstall", systemImage: "trash", role: .destructive) {
- Task {
- await readWhatUsesIt()
- isConfirmingUninstall = true
- }
- }
- .disabled(uninstallRefusal != nil)
- }
- stateAndUpgrade
- }
- .disabled(
- homebrew.runningCommand != nil || homebrew.isForgetting || homebrew.quittingToUpgrade.isWaiting
- || homebrew.quittingToUninstall.isWaiting
- )
if package.waitsForAnUpgrade, package.isPeelItself {
Text("Peel updates itself, so it isn’t upgraded from here: Homebrew would have to quit Peel first.")
.font(.callout)
@@ -171,6 +151,32 @@ struct HomebrewDetailView: View {
}
}
+ if homebrew.whyItCantChange == nil {
+ PageActions {
+ if isUninstalledInTerminal {
+ CopyButton(
+ text: Homebrew.terminalCommand(
+ "brew uninstall --cask \(package.fullName)", keeping: homebrew.keptFormulaeNow
+ ),
+ title: "Copy Uninstall Command"
+ )
+ } else {
+ Button("Uninstall", role: .destructive) {
+ Task {
+ await readWhatUsesIt()
+ isConfirmingUninstall = true
+ }
+ }
+ .disabled(uninstallRefusal != nil)
+ }
+ stateAndUpgrade
+ }
+ .disabled(
+ homebrew.runningCommand != nil || homebrew.isForgetting || homebrew.quittingToUpgrade.isWaiting
+ || homebrew.quittingToUninstall.isWaiting
+ )
+ }
+
if let (version, notes) = caskNotes {
Section {
ReleaseNotesView(notes: notes, version: version)
@@ -223,7 +229,7 @@ struct HomebrewDetailView: View {
}
}
- /// The right end of the row: what is under way or in the way, and the step that brings the package up to date.
+ /// What is under way or in the way, and the step that brings the package up to date.
private var stateAndUpgrade: some View {
HStack {
if isRunning {
@@ -242,7 +248,7 @@ struct HomebrewDetailView: View {
.help(Text(verbatim: history.holdingReason?.explanation ?? ""))
} else if package.waitsForAnUpgrade {
if package.isPeelItself {
- Button("Check for Updates…", systemImage: "arrow.down.circle") {
+ Button("Check for Updates…") {
updater.checkForUpdates()
}
.buttonStyle(.borderedProminent)
@@ -257,7 +263,7 @@ struct HomebrewDetailView: View {
title: "Copy Upgrade Command"
)
} else {
- Button("Upgrade", systemImage: "arrow.down.circle") {
+ Button("Upgrade") {
isConfirmingUpgrade = true
}
.buttonStyle(.borderedProminent)
diff --git a/Peel/Views/Installers/InstallerDetailView.swift b/Peel/Views/Installers/InstallerDetailView.swift
index 6a8e4592..42471c13 100644
--- a/Peel/Views/Installers/InstallerDetailView.swift
+++ b/Peel/Views/Installers/InstallerDetailView.swift
@@ -61,19 +61,15 @@ struct InstallerDetailView: View {
if kind == .deviceBackup {
Section {
} header: {
- HStack(spacing: 8) {
+ HeadingWithActions {
heading(
"Device Backups",
"A backup is deleted in System Settings > General > Storage > iOS Files, or in Finder from a connected device’s General > Manage Backups. Peel doesn’t touch them: what is inside came off a device and may be the only copy."
)
- Spacer(minLength: 8)
- Button {
+ } actions: {
+ Button("Open System Settings") {
NSWorkspace.shared.open(Installers.storageSettingsURL)
- } label: {
- Text("Open System Settings")
- .minimumTarget()
}
- .buttonStyle(.borderless)
}
}
}
diff --git a/Peel/Views/Intel/IntelDetailView.swift b/Peel/Views/Intel/IntelDetailView.swift
index f0ffedc9..4ce979c7 100644
--- a/Peel/Views/Intel/IntelDetailView.swift
+++ b/Peel/Views/Intel/IntelDetailView.swift
@@ -64,11 +64,14 @@ struct IntelDetailView: View {
}
// The list also names Intel apps that are only installed, so it matters without Rosetta too.
if #available(macOS 27, *) {
- Text("The Intel-based Apps list in System Settings > General > About names the apps macOS 28 won’t run. Peel also looks inside apps and at plug-ins and drivers, which that list may leave out.")
- .font(.callout)
- .foregroundStyle(.secondary)
- Button("Open System Settings") {
- NSWorkspace.shared.open(DeviceInfo.aboutURL)
+ HStack(spacing: 8) {
+ Text("The Intel-based Apps list in System Settings > General > About names the apps macOS 28 won’t run. Peel also looks inside apps and at plug-ins and drivers, which that list may leave out.")
+ .font(.callout)
+ .foregroundStyle(.secondary)
+ Spacer(minLength: 8)
+ Button("Open System Settings") {
+ NSWorkspace.shared.open(DeviceInfo.aboutURL)
+ }
}
}
}
@@ -81,6 +84,7 @@ struct IntelDetailView: View {
Text(verbatim: finding.url.abbreviatedPath)
.textSelection(.enabled)
.help(Text(verbatim: finding.url.path(percentEncoded: false)))
+ ShowInFinderButton(url: finding.url)
}
.labeledContentStyle(.oneLine)
LabeledContent("Size") {
@@ -114,45 +118,22 @@ struct IntelDetailView: View {
Text("Details")
}
- Section {
- ActionRow {
- Button("Show in Finder", systemImage: "folder") {
- NSWorkspace.shared.activateFileViewerSelecting([finding.url])
- }
- if let app {
- let review = Button("Review in Applications", systemImage: "square.grid.2x2") {
- library.selection = [app.id]
- // Selecting the app does not switch tools by itself, so Applications is requested too.
- Navigator.shared.requestedTool = .applications
- }
- // A part inside the app never goes alone, so removing the app isn't the step to lead with.
- if finding.kind == .insideApp {
- review
- } else {
- review.buttonStyle(.borderedProminent)
- }
- } else if finding.isOnThePlugInsPage {
- Button("Review in Plug-ins", systemImage: "powerplug") {
- plugins.selection = finding.url
- Navigator.shared.requestedTool = .plugins
- }
- .buttonStyle(.borderedProminent)
- } else if let receipt {
- Button("Review in Package Receipts", systemImage: "shippingbox") {
- packages.selection = receipt
- Navigator.shared.requestedTool = .packages
- }
- .buttonStyle(.borderedProminent)
- } else if let job = finding.job {
- Button("Review in Background Items", systemImage: "gearshape.2") {
- backgroundItems.selection = job
- Navigator.shared.requestedTool = .backgroundItems
- }
- .buttonStyle(.borderedProminent)
+ if app == nil, !finding.isOnThePlugInsPage, finding.job == nil, receipt == nil {
+ Section {
+ Text(advice)
+ .font(.callout)
+ } header: {
+ Text("What to Do About It")
+ }
+ } else {
+ Section {
+ } header: {
+ HeadingWithActions {
+ heading("What to Do About It", advice)
+ } actions: {
+ review(of: app)
}
}
- } header: {
- heading("What to Do About It", advice)
}
}
.formStyle(.grouped)
@@ -164,6 +145,42 @@ struct IntelDetailView: View {
.toolbar(removing: .title)
}
+ /// The button that leads to the page where this can be dealt with.
+ @ViewBuilder
+ private func review(of app: InstalledApp?) -> some View {
+ if let app {
+ let button = Button("Review in Applications") {
+ library.selection = [app.id]
+ // Selecting the app does not switch tools by itself, so Applications is requested too.
+ Navigator.shared.requestedTool = .applications
+ }
+ // A part inside the app never goes alone, so removing the app isn't the step to lead with.
+ if finding.kind == .insideApp {
+ button
+ } else {
+ button.buttonStyle(.borderedProminent)
+ }
+ } else if finding.isOnThePlugInsPage {
+ Button("Review in Plug-ins") {
+ plugins.selection = finding.url
+ Navigator.shared.requestedTool = .plugins
+ }
+ .buttonStyle(.borderedProminent)
+ } else if let receipt {
+ Button("Review in Package Receipts") {
+ packages.selection = receipt
+ Navigator.shared.requestedTool = .packages
+ }
+ .buttonStyle(.borderedProminent)
+ } else if let job = finding.job {
+ Button("Review in Background Items") {
+ backgroundItems.selection = job
+ Navigator.shared.requestedTool = .backgroundItems
+ }
+ .buttonStyle(.borderedProminent)
+ }
+ }
+
/// The advice in the note beside the What to Do About It heading. A driver, a tool in `/usr/local`, or a plug-in
/// the Plug-ins page doesn't list is left to the software that installed it, which knows what else goes with it.
private var advice: LocalizedStringResource {
diff --git a/Peel/Views/Orphans/AdministratorItemsView.swift b/Peel/Views/Orphans/AdministratorItemsView.swift
index 03f7c3e2..79e1aa17 100644
--- a/Peel/Views/Orphans/AdministratorItemsView.swift
+++ b/Peel/Views/Orphans/AdministratorItemsView.swift
@@ -74,7 +74,7 @@ struct AdministratorItemsView: View {
.font(.callout)
.foregroundStyle(.secondary)
.fixedSize(horizontal: false, vertical: true)
- Button("Show in Finder", systemImage: "folder") {
+ Button("Show in Finder") {
NSWorkspace.shared.activateFileViewerSelecting(items.map(\.item.url))
}
}
diff --git a/Peel/Views/Orphans/OrphanDetailView.swift b/Peel/Views/Orphans/OrphanDetailView.swift
index c6be4a08..3909a7fa 100644
--- a/Peel/Views/Orphans/OrphanDetailView.swift
+++ b/Peel/Views/Orphans/OrphanDetailView.swift
@@ -124,7 +124,7 @@ struct OrphanDetailView: View {
.fixedSize(horizontal: false, vertical: true)
let documents = group.items.filter { $0.leftAlone == .holdsDocuments }.map(\.url)
if !documents.isEmpty {
- Button("Show in Finder", systemImage: "folder") {
+ Button("Show in Finder") {
NSWorkspace.shared.activateFileViewerSelecting(documents)
}
}
diff --git a/Peel/Views/Packages/PackageDetailView.swift b/Peel/Views/Packages/PackageDetailView.swift
index 6fa9586d..d67c8e4f 100644
--- a/Peel/Views/Packages/PackageDetailView.swift
+++ b/Peel/Views/Packages/PackageDetailView.swift
@@ -71,7 +71,7 @@ struct PackageDetailView: View {
kind: .note,
systemImage: "lock.shield"
) {
- Button("Show in Finder", systemImage: "folder") {
+ Button("Show in Finder") {
NSWorkspace.shared.activateFileViewerSelecting(forAnAdministrator.map(\.url))
}
}
@@ -82,6 +82,7 @@ struct PackageDetailView: View {
if receipt.items.isEmpty {
Text(emptyListReason)
.foregroundStyle(.secondary)
+ .listRowSeparator(.hidden)
}
ForEach(Array(receipt.items.enumerated()), id: \.element.id) { index, item in
RemovalRow(
@@ -109,19 +110,15 @@ struct PackageDetailView: View {
Section {
} header: {
- HStack(spacing: 8) {
+ HeadingWithActions {
heading(
"Installer Receipt",
"Forgetting it moves the receipt to the Trash, so macOS no longer counts the package as installed. What it installed stays where it is."
)
- Spacer(minLength: 8)
- Button {
+ } actions: {
+ Button("Forget Receipt") {
receiptToForget = receipt
- } label: {
- Text("Forget Receipt")
- .minimumTarget()
}
- .buttonStyle(.borderless)
.disabled(!helper.canAct || !history.mayMove || isForAnExcludedApp)
.help(forgetHelp)
}
diff --git a/Peel/Views/Plugins/PluginDetailView.swift b/Peel/Views/Plugins/PluginDetailView.swift
index 094773c1..c99974bc 100644
--- a/Peel/Views/Plugins/PluginDetailView.swift
+++ b/Peel/Views/Plugins/PluginDetailView.swift
@@ -66,6 +66,7 @@ struct PluginDetailView: View {
Text(verbatim: plugin.url.abbreviatedPath)
.textSelection(.enabled)
.help(Text(verbatim: plugin.url.path(percentEncoded: false)))
+ ShowInFinderButton(url: plugin.url)
}
.labeledContentStyle(.oneLine)
}
@@ -83,27 +84,23 @@ struct PluginDetailView: View {
.font(.callout)
.foregroundStyle(.secondary)
}
- ActionRow {
- Button("Show in Finder", systemImage: "folder") {
- NSWorkspace.shared.activateFileViewerSelecting([plugin.url])
- }
- HStack {
- BusyShown(isBusy: plugins.isRemoving) { isShown in
- if isShown {
- ProgressView()
- .controlSize(.small)
- }
- }
- Button("Move to Trash", systemImage: "trash") {
- isConfirmingRemoval = true
- }
- .buttonStyle(.borderedProminent)
- .disabled(
- isLocked || plugin.refusal != nil || plugins.isRemoving || plugins.isScanning
- || !history.mayMove
- )
+ }
+
+ PageActions {
+ BusyShown(isBusy: plugins.isRemoving) { isShown in
+ if isShown {
+ ProgressView()
+ .controlSize(.small)
}
}
+ Button("Move to Trash") {
+ isConfirmingRemoval = true
+ }
+ .buttonStyle(.borderedProminent)
+ .disabled(
+ isLocked || plugin.refusal != nil || plugins.isRemoving || plugins.isScanning
+ || !history.mayMove
+ )
}
}
.formStyle(.grouped)
diff --git a/Peel/Views/ResetSheet.swift b/Peel/Views/ResetSheet.swift
index e5ca4f13..1ed87a81 100644
--- a/Peel/Views/ResetSheet.swift
+++ b/Peel/Views/ResetSheet.swift
@@ -320,26 +320,6 @@ struct ResetSheet: View {
.buttonStyle(.bordered)
}
}
- ActionRow {
- Button("Show in Finder", systemImage: "folder") {
- NSWorkspace.shared.activateFileViewerSelecting([backup])
- }
- .buttonStyle(.bordered)
- Button("Put Settings Back") {
- isPuttingBack = true
- Task {
- let restored = await plan.putSettingsBack(from: backup)
- putBack = restored
- switch restored {
- case .complete, .incomplete: changedFiles = true
- case .notSaved, .appIsOpen, .exclusionsNotKnown, .excluded, .copyUnreadable: break
- }
- isPuttingBack = false
- }
- }
- .buttonStyle(.borderedProminent)
- .disabled(isPuttingBack || plan.isAppRunning || plan.putBackRefusal != nil)
- }
if let refusal = plan.putBackRefusal {
putBackResult(refusal)
} else if let putBack {
@@ -349,10 +329,30 @@ struct ResetSheet: View {
.padding(.vertical, 2)
.listRowSeparator(.hidden)
} header: {
- heading(
- "If You Change Your Mind",
- "The old settings were saved before they were cleared. Put them back from here: once the app opens again, it writes new settings where the old ones were, and History won’t put the old files back over them."
- )
+ HeadingWithActions {
+ heading(
+ "If You Change Your Mind",
+ "The old settings were saved before they were cleared. Put them back from here: once the app opens again, it writes new settings where the old ones were, and History won’t put the old files back over them."
+ )
+ } actions: {
+ Button("Show in Finder") {
+ NSWorkspace.shared.activateFileViewerSelecting([backup])
+ }
+ Button("Put Settings Back") {
+ isPuttingBack = true
+ Task {
+ let restored = await plan.putSettingsBack(from: backup)
+ putBack = restored
+ switch restored {
+ case .complete, .incomplete: changedFiles = true
+ case .notSaved, .appIsOpen, .exclusionsNotKnown, .excluded, .copyUnreadable: break
+ }
+ isPuttingBack = false
+ }
+ }
+ .buttonStyle(.borderedProminent)
+ .disabled(isPuttingBack || plan.isAppRunning || plan.putBackRefusal != nil)
+ }
}
}
}
diff --git a/Peel/Views/Settings/AppFoldersSection.swift b/Peel/Views/Settings/AppFoldersSection.swift
index 9c1d2eae..ee201f16 100644
--- a/Peel/Views/Settings/AppFoldersSection.swift
+++ b/Peel/Views/Settings/AppFoldersSection.swift
@@ -34,35 +34,39 @@ struct AppFoldersSection: View {
Text("No other folder is on this list yet.")
.foregroundStyle(.secondary)
} else {
- HStack {
+ HStack(spacing: 8) {
StatusLabel(title: Text("Peel can’t read its list of app folders, so Orphaned Files lists nothing. Starting over keeps the old list beside a new one."))
- Spacer()
+ Spacer(minLength: 8)
StartOverButton(file: library.foldersFile, startedOver: "Started the list of app folders over.") {
library.startFoldersOver()
}
}
}
if !library.foldersLeftOut.isEmpty {
- VStack(alignment: .leading, spacing: 6) {
- StatusLabel(title: Text("Peel no longer looks in these folders, so the apps in them aren’t listed."))
- Self.message(for: library.foldersLeftOut)
- .font(.caption)
- .foregroundStyle(.secondary)
- .textSelection(.enabled)
+ HStack(spacing: 8) {
+ VStack(alignment: .leading, spacing: 6) {
+ StatusLabel(title: Text("Peel no longer looks in these folders, so the apps in them aren’t listed."))
+ Self.message(for: library.foldersLeftOut)
+ .font(.caption)
+ .foregroundStyle(.secondary)
+ .textSelection(.enabled)
+ }
+ Spacer(minLength: 8)
Button("Remove From List") { library.removeFolders(library.foldersLeftOut.map(\.folder)) }
}
}
if library.couldNotSaveFolders {
StatusLabel(title: Text("Peel couldn’t save the app folders."))
}
- ActionRow {
+ ListEditingButtons {
Button("Add Folder…", systemImage: "plus") {
isChoosing = true
}
+ .help(Text("Add Folder…"))
Button("Remove", systemImage: "minus") { removeSelected() }
.disabled(selected.isEmpty)
+ .help(Text("Remove"))
}
- .editingControls()
} header: {
titled("App Folders", "Peel looks for apps in the Applications folders and in the folders on this list, such as one on another disk. While that disk isn’t connected, its apps still count as installed, so their files aren’t listed as orphaned.")
}
diff --git a/Peel/Views/Settings/ExclusionsSettingsView.swift b/Peel/Views/Settings/ExclusionsSettingsView.swift
index 788a89c4..508d13bf 100644
--- a/Peel/Views/Settings/ExclusionsSettingsView.swift
+++ b/Peel/Views/Settings/ExclusionsSettingsView.swift
@@ -81,18 +81,19 @@ struct ExclusionsSettingsView: View {
Task { await exclusions.remove(paths: Array(removed)) }
}
}
- ActionRow {
+ ListEditingButtons {
Button("Add Files or Folders…", systemImage: "plus") {
isChoosingPaths = true
}
+ .help(Text("Add Files or Folders…"))
Button("Remove", systemImage: "minus") {
let removed = selectedPaths
selectedPaths = []
Task { await exclusions.remove(paths: Array(removed)) }
}
.disabled(selectedPaths.isEmpty)
+ .help(Text("Remove"))
}
- .editingControls()
} header: {
heading("Files and Folders", "Peel never moves anything inside these to the Trash, nor a folder that holds one of them, and leaves them out of its lists, but for Applications, which marks an app inside them as excluded, and Homebrew, which won’t uninstall a package inside them. History still shows what moved before. Homebrew’s Clean Up keeps the formulae whose folder you exclude here, but this list doesn’t cover what else it deletes, such as its downloads.")
}
@@ -130,7 +131,7 @@ struct ExclusionsSettingsView: View {
Task { await exclusions.remove(bundleIdentifiers: Array(removed)) }
}
}
- ActionRow {
+ ListEditingButtons {
Menu {
// An app with no identifier is left alone by where it is, as its Control-click menu does.
ForEach(
@@ -154,14 +155,15 @@ struct ExclusionsSettingsView: View {
}
.menuStyle(.button)
.fixedSize()
+ .help(Text("Add App"))
Button("Remove", systemImage: "minus") {
let removed = selectedApps
selectedApps = []
Task { await exclusions.remove(bundleIdentifiers: Array(removed)) }
}
.disabled(selectedApps.isEmpty)
+ .help(Text("Remove"))
}
- .editingControls()
} header: {
heading("Apps", "Excluded apps still appear in Applications, but Peel won’t offer to remove or reset them. A folder named exactly with an excluded app’s identifier, such as its caches or its container, and an update it downloaded are left out of every page and never moved. The app’s other files, such as plug-ins or a folder named after it, go by files and folders only, so to protect them, exclude them above as well.")
}
@@ -194,16 +196,16 @@ struct ExclusionsSettingsView: View {
.scrollContentBackground(.hidden)
.onDeleteCommand { forgetSelectedGroups() }
}
- HStack {
- Spacer()
+ ListEditingButtons {
Button("Remove", systemImage: "minus") { forgetSelectedGroups() }
.disabled(selectedGroups.isEmpty)
+ .help(Text("Remove"))
}
- .editingControls()
} else {
- Text("Peel can’t read this list, so Orphaned Files lists these files again. Starting over keeps the old list beside a new one.")
- .foregroundStyle(.secondary)
- ActionRow {
+ HStack(spacing: 8) {
+ Text("Peel can’t read this list, so Orphaned Files lists these files again. Starting over keeps the old list beside a new one.")
+ .foregroundStyle(.secondary)
+ Spacer(minLength: 8)
StartOverButton(
file: OrphanOwners.defaultURL,
startedOver: "Started the list of orphaned files that belong to an app over."
diff --git a/Peel/Views/Settings/HomebrewSection.swift b/Peel/Views/Settings/HomebrewSection.swift
index 8f83d49b..55a54f1b 100644
--- a/Peel/Views/Settings/HomebrewSection.swift
+++ b/Peel/Views/Settings/HomebrewSection.swift
@@ -18,9 +18,16 @@ struct HomebrewSection: View {
let brew = unrunnable?.brew ?? refused?.brew ?? Homebrew.executableURL
Section {
LabeledContent {
- Text(brew?.abbreviatedPath ?? String(localized: "Not found"))
- .lineLimit(1)
- .truncationMode(.middle)
+ HStack(spacing: 8) {
+ Text(brew?.abbreviatedPath ?? String(localized: "Not found"))
+ .lineLimit(1)
+ .truncationMode(.middle)
+ Button("Choose…") { isChoosing = true }
+ if choice != nil {
+ Button("Use the Usual Places") { use(nil) }
+ }
+ }
+ .editingControls()
} label: {
Text(verbatim: "brew")
}
@@ -42,13 +49,6 @@ struct HomebrewSection: View {
if couldNotSave {
StatusLabel(title: Text("Peel couldn’t save which `brew` to run."))
}
- ActionRow {
- Button("Choose…") { isChoosing = true }
- if choice != nil {
- Button("Use the Usual Places") { use(nil) }
- }
- }
- .editingControls()
} header: {
titled("Homebrew", "Peel runs the `brew` in /opt/homebrew or /usr/local. If your Homebrew is in a folder of its own, such as /opt/brew, choose its `brew`, and Peel and `peel` run that one.")
}
diff --git a/Peel/Views/Settings/SavedSettingsSection.swift b/Peel/Views/Settings/SavedSettingsSection.swift
index 0c5b2637..157c9530 100644
--- a/Peel/Views/Settings/SavedSettingsSection.swift
+++ b/Peel/Views/Settings/SavedSettingsSection.swift
@@ -27,14 +27,10 @@ struct SavedSettingsSection: View {
row(for: copy)
}
} else {
- HStack {
+ HStack(spacing: 8) {
StatusLabel(title: Text("Peel can’t read the folder that keeps the saved copies of settings, so none can be listed or put back."))
- Spacer()
- Button("Show in Finder", systemImage: "folder") {
- NSWorkspace.shared.activateFileViewerSelecting([PreferenceBackup.defaultDirectory])
- }
- .labelStyle(.iconOnly)
- .help(Text("Show in Finder"))
+ Spacer(minLength: 8)
+ ShowInFinderButton(url: PreferenceBackup.defaultDirectory)
}
}
} header: {
@@ -78,30 +74,29 @@ struct SavedSettingsSection: View {
let name = library.name(forReference: copy.bundleIdentifier)
let isOpen = openApps.contains(copy.bundleIdentifier)
let refusal = PreferenceBackup.refusal(ofPuttingBack: copy.bundleIdentifier, exclusions: exclusions.exclusions)
- return LabeledContent {
+ // An `HStack` centers the buttons on the row's two lines, where `LabeledContent` would set them on the first.
+ return HStack(spacing: 8) {
+ VStack(alignment: .leading, spacing: 1) {
+ Text(verbatim: name)
+ Text(copy.date, format: .dateTime.day().month().year().hour().minute())
+ .font(.caption)
+ .foregroundStyle(.secondary)
+ }
+ Spacer(minLength: 8)
HStack(spacing: 8) {
+ ShowInFinderButton(url: copy.folder)
+ RowSymbolButton("Move to Trash", systemImage: "trash") {
+ copyToTrash = copy
+ }
+ .help(history.holdingReason.map { Text(verbatim: $0.explanation) } ?? Text("Move to Trash"))
+ .disabled(!history.mayMove)
Button("Put Back") {
copyToPutBack = copy
}
.disabled(isOpen || refusal != nil)
.help(putBackHelp(refusal: refusal, isOpen: isOpen, name: name))
- Button("Show in Finder", systemImage: "folder") {
- NSWorkspace.shared.activateFileViewerSelecting([copy.folder])
- }
- .labelStyle(.iconOnly)
- .help(Text("Show in Finder"))
- Button("Move to Trash", systemImage: "trash") {
- copyToTrash = copy
- }
- .labelStyle(.iconOnly)
- .help(history.holdingReason.map { Text(verbatim: $0.explanation) } ?? Text("Move to Trash"))
- .disabled(!history.mayMove)
}
- .buttonStyle(.bordered)
.disabled(workingOn != nil)
- } label: {
- Text(verbatim: name)
- Text(copy.date, format: .dateTime.day().month().year().hour().minute())
}
}
diff --git a/Peel/Views/Settings/SettingsListEditing.swift b/Peel/Views/Settings/SettingsListEditing.swift
index 8718bf7f..5e878ad4 100644
--- a/Peel/Views/Settings/SettingsListEditing.swift
+++ b/Peel/Views/Settings/SettingsListEditing.swift
@@ -7,7 +7,7 @@ func settingsListHeight(rows: Int) -> CGFloat {
}
extension View {
- /// Styles the buttons that add to a list and remove from it as small bordered buttons, 20 points high, the
+ /// Styles the buttons beside a Settings row as small bordered buttons, 20 points high, the
/// HIG's minimum on the Mac. A borderless pull-down stays 16 points high at every control size, so they all use
/// this style.
func editingControls() -> some View {
@@ -15,3 +15,18 @@ extension View {
.controlSize(.small)
}
}
+
+/// The `+` and `-` at the foot of a Settings list, as macOS's own lists have them: symbols at the left, each named by
+/// its tooltip and to VoiceOver.
+struct ListEditingButtons<Buttons: View>: View {
+ @ViewBuilder let buttons: Buttons
+
+ var body: some View {
+ HStack(spacing: 4) {
+ buttons
+ Spacer(minLength: 0)
+ }
+ .labelStyle(.iconOnly)
+ .editingControls()
+ }
+}
diff --git a/Peel/Views/Settings/SettingsView.swift b/Peel/Views/Settings/SettingsView.swift
index c390d8af..d34ce661 100644
--- a/Peel/Views/Settings/SettingsView.swift
+++ b/Peel/Views/Settings/SettingsView.swift
@@ -236,15 +236,16 @@ private struct GeneralSettingsView: View {
var body: some View {
Form {
Section {
- LabeledContent {
+ // An `HStack` centers the button on a summary that takes two lines, as Saved Settings' rows do.
+ HStack(spacing: 8) {
+ Text(sidebarToolsSummary)
+ Spacer(minLength: 8)
Button("Choose Tools…") {
isChoosingSidebarTools = true
}
.popover(isPresented: $isChoosingSidebarTools, arrowEdge: .bottom) {
sidebarToolsChoice
}
- } label: {
- Text(sidebarToolsSummary)
}
} header: {
titled("Sidebar", "Turn a tool off to leave it out of the sidebar. The View menu and Shortcuts still open it.")
@@ -442,7 +443,7 @@ private struct GeneralSettingsView: View {
titled("Remove Peel",
"Peel removes its helper and login item, moves itself, the files that are certainly its own, and its folder in Application Support to the Trash, all but the Terminal settings zsh and ssh read, clears its settings, then quits. That folder holds History, your exclusions, App Folders, and Saved Settings, among others. What you set in Tweaks and on the Terminal page stays as it is. The Finder extension goes with the app.")
Spacer(minLength: 8)
- Button("Remove Peel", systemImage: "trash") {
+ Button("Remove Peel") {
isConfirmingSelfRemoval = true
}
.buttonStyle(.borderedProminent)
@@ -705,66 +706,25 @@ private struct HelperSettingsView: View {
@State private var failure: HelperModel.Failure?
@State private var isConfirmingUninstall = false
- /// The helper's buttons have no label beside them, so each is centered in its row.
var body: some View {
Form {
Section {
- LabeledContent {
- statusBadge
- } label: {
- HStack(spacing: 5) {
- Text("Status")
- InfoNote(
- name: String(localized: "Helper"),
- detail: Text("A small tool with administrator rights. It moves items to the Trash and puts them back, starts, stops, enables, or disables background items, and forgets installer receipts. It takes no other orders."),
- symbol: "lock.shield"
- )
- }
- }
- }
-
- Section {
- switch helper.standing {
- case .notInstalled:
- if helper.standing.offersInstall(registeredByAnotherCopy: helper.isRegisteredByAnotherCopy) {
- Button("Install Helper", systemImage: "lock.shield") {
- Task { failure = await helper.install() }
- }
- .disabled(helper.isChanging)
- .centeredInRow()
- } else {
- Text(helper.standing.whyItCannotAct(registeredByAnotherCopy: true))
- .font(.callout)
+ ViewThatFits(in: .horizontal) {
+ HStack(spacing: 8) {
+ status
+ Spacer(minLength: 8)
+ actions
}
- case .waitingForApproval:
- Text("Allow Peel in System Settings under Login Items & Extensions.")
- .font(.callout)
- // Opens System Settings instead of registering again, which returns an error in this state
- // (`SMAppService.h`).
- Button("Open System Settings", systemImage: "gearshape") {
- PrivilegedHelper.openLoginItemsSettings()
+ VStack(alignment: .leading, spacing: 8) {
+ HStack(spacing: 8) { status }
+ ActionRow { actions }
}
- .centeredInRow()
- uninstallButton
- case .notThisAccount:
- Text("Only an administrator can use the helper. Log in as an administrator to remove items that need one.")
- .font(.callout)
- case .notAnswering:
- // Several causes share this message: an older or newer helper, a signature that doesn't
- // match, or a helper that didn't start.
- Text("Peel’s helper isn’t answering. Repairing it installs the one this version of Peel works with.")
+ }
+ if let explanation {
+ explanation
.font(.callout)
- Button("Repair Helper", systemImage: "arrow.clockwise") {
- Task { failure = await helper.repair() }
- }
- .disabled(helper.isChanging)
- .centeredInRow()
- uninstallButton
- case .ready:
- uninstallButton
}
}
- .listRowBackground(Color.clear)
}
.formStyle(.grouped)
.task {
@@ -782,12 +742,76 @@ private struct HelperSettingsView: View {
}
}
+ /// The state with its word and its note, which stay together wherever the buttons go.
+ @ViewBuilder
+ private var status: some View {
+ InfoNote(
+ name: String(localized: "Helper"),
+ detail: Text("A small tool with administrator rights. It moves items to the Trash and puts them back, starts, stops, enables, or disables background items, and forgets installer receipts. It takes no other orders."),
+ symbol: "lock.shield"
+ )
+ Text("Status")
+ statusBadge
+ }
+
+ /// What can be done about the state, the step it asks for last.
+ @ViewBuilder
+ private var actions: some View {
+ switch helper.standing {
+ case .notInstalled:
+ if helper.standing.offersInstall(registeredByAnotherCopy: helper.isRegisteredByAnotherCopy) {
+ Button("Install Helper") {
+ Task { failure = await helper.install() }
+ }
+ .buttonStyle(.borderedProminent)
+ .disabled(helper.isChanging)
+ }
+ case .waitingForApproval:
+ uninstallButton
+ // Opens System Settings instead of registering again, which returns an error in this state
+ // (`SMAppService.h`).
+ Button("Open System Settings") {
+ PrivilegedHelper.openLoginItemsSettings()
+ }
+ .buttonStyle(.borderedProminent)
+ case .notThisAccount:
+ EmptyView()
+ case .notAnswering:
+ uninstallButton
+ Button("Repair Helper") {
+ Task { failure = await helper.repair() }
+ }
+ .buttonStyle(.borderedProminent)
+ .disabled(helper.isChanging)
+ case .ready:
+ uninstallButton
+ }
+ }
+
+ /// What the helper's state asks of the person, said under its row.
+ private var explanation: Text? {
+ switch helper.standing {
+ case .notInstalled:
+ helper.standing.offersInstall(registeredByAnotherCopy: helper.isRegisteredByAnotherCopy)
+ ? nil : Text(helper.standing.whyItCannotAct(registeredByAnotherCopy: true))
+ case .waitingForApproval:
+ Text("Allow Peel in System Settings under Login Items & Extensions.")
+ case .notThisAccount:
+ Text("Only an administrator can use the helper. Log in as an administrator to remove items that need one.")
+ case .notAnswering:
+ // Several causes share this message: an older or newer helper, a signature that doesn't
+ // match, or a helper that didn't start.
+ Text("Peel’s helper isn’t answering. Repairing it installs the one this version of Peel works with.")
+ case .ready:
+ nil
+ }
+ }
+
private var uninstallButton: some View {
- Button("Uninstall Helper", systemImage: "trash", role: .destructive) {
+ Button("Uninstall Helper", role: .destructive) {
isConfirmingUninstall = true
}
.disabled(helper.isChanging)
- .centeredInRow()
}
@ViewBuilder
diff --git a/Peel/Views/ShowInFinderButton.swift b/Peel/Views/ShowInFinderButton.swift
new file mode 100644
index 00000000..7c87595d
--- /dev/null
+++ b/Peel/Views/ShowInFinderButton.swift
@@ -0,0 +1,40 @@
+import AppKit
+import SwiftUI
+
+/// Shows an item in Finder: Finder's own symbol at the end of the row that says where the item is.
+struct ShowInFinderButton: View {
+ let url: URL
+
+ var body: some View {
+ RowSymbolButton("Show in Finder", systemImage: "finder") {
+ NSWorkspace.shared.activateFileViewerSelecting([url])
+ }
+ .help(Text("Show in Finder"))
+ }
+}
+
+/// A symbol alone as a button at the end of a row, which VoiceOver names by its title. The target reaches past the
+/// symbol to the 20 points the HIG asks for and gives them back outside, so the row keeps its height and the symbol
+/// stands at the row's edge.
+struct RowSymbolButton: View {
+ let title: LocalizedStringKey
+ let systemImage: String
+ let action: () -> Void
+
+ init(_ title: LocalizedStringKey, systemImage: String, action: @escaping () -> Void) {
+ self.title = title
+ self.systemImage = systemImage
+ self.action = action
+ }
+
+ var body: some View {
+ Button(action: action) {
+ Label(title, systemImage: systemImage)
+ .labelStyle(.iconOnly)
+ .padding(3)
+ .contentShape(.rect)
+ }
+ .buttonStyle(.borderless)
+ .padding(-3)
+ }
+}
diff --git a/Peel/Views/Space/SpaceDetailView.swift b/Peel/Views/Space/SpaceDetailView.swift
index cf35e2b0..41f88cf9 100644
--- a/Peel/Views/Space/SpaceDetailView.swift
+++ b/Peel/Views/Space/SpaceDetailView.swift
@@ -121,15 +121,7 @@ struct SpaceDetailView: View {
.accessibilityHidden(true)
name()
Spacer(minLength: 8)
- Button {
- NSWorkspace.shared.activateFileViewerSelecting([url])
- } label: {
- Label("Show in Finder", systemImage: "arrow.up.forward.app")
- .minimumTarget()
- }
- .labelStyle(.iconOnly)
- .buttonStyle(.borderless)
- .help(Text("Show in Finder"))
+ ShowInFinderButton(url: url)
}
}
diff --git a/Peel/Views/VendorNotes.swift b/Peel/Views/VendorNotes.swift
index f13ac960..5a9deae4 100644
--- a/Peel/Views/VendorNotes.swift
+++ b/Peel/Views/VendorNotes.swift
@@ -15,7 +15,7 @@ struct SystemExtensionNotice: View {
detail: detail,
kind: .note
) {
- Button("Show in Finder", systemImage: "folder") {
+ Button("Show in Finder") {
NSWorkspace.shared.activateFileViewerSelecting([app.url])
}
}