Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
Keep an empty state's buttons inside its column
Țugui Dragoș40592572374b
diff --git a/Peel/Views/Cloud/CloudView.swift b/Peel/Views/Cloud/CloudView.swiftindex 11ff87c0..fdb375ba 100644--- a/Peel/Views/Cloud/CloudView.swift+++ b/Peel/Views/Cloud/CloudView.swift@@ -152,7 +152,9 @@ struct CloudView: View {sharedDownloadsNote}} actions: {- UnreadableFoldersActions(folders: cloud.notRead, needsFullDiskAccess: false)+ EmptyStateActions {+ UnreadableFoldersActions(folders: cloud.notRead, needsFullDiskAccess: false)+ }}} else if cloud.files?.isEmpty == true, cloud.isNotSetUp {ContentUnavailableView {diff --git a/Peel/Views/Duplicates/DuplicateList.swift b/Peel/Views/Duplicates/DuplicateList.swiftindex 3bfc04c5..c4a58ae8 100644--- a/Peel/Views/Duplicates/DuplicateList.swift+++ b/Peel/Views/Duplicates/DuplicateList.swift@@ -84,10 +84,12 @@ struct DuplicateList: View {Text(verbatim: Self.reasons(scan.skippedLocations))}} actions: {- UnreadableFoldersActions(- folders: scan.unreadableLocations,- needsFullDiskAccess: scan.needsFullDiskAccess- )+ EmptyStateActions {+ UnreadableFoldersActions(+ folders: scan.unreadableLocations,+ needsFullDiskAccess: scan.needsFullDiskAccess+ )+ }}} else if scan.groups.isEmpty, scan.folderGroups.isEmpty {ContentUnavailableView(diff --git a/Peel/Views/EmptyStateActions.swift b/Peel/Views/EmptyStateActions.swiftnew file mode 100644index 00000000..0284079c--- /dev/null+++ b/Peel/Views/EmptyStateActions.swift@@ -0,0 +1,15 @@+import SwiftUI++/// The buttons of an empty state: side by side when they fit the width they are given, otherwise one under another,+/// each as wide as its own title. An empty state lays its actions in one row that never wraps, so in a list column a+/// few buttons would run past both edges.+struct EmptyStateActions<Content: View>: View {+ @ViewBuilder let content: Content++ var body: some View {+ ViewThatFits(in: .horizontal) {+ HStack { content }+ VStack { Group { content }.fixedSize() }+ }+ }+}diff --git a/Peel/Views/Homebrew/HomebrewList.swift b/Peel/Views/Homebrew/HomebrewList.swiftindex 28d39204..7888de46 100644--- a/Peel/Views/Homebrew/HomebrewList.swift+++ b/Peel/Views/Homebrew/HomebrewList.swift@@ -761,13 +761,15 @@ struct HomebrewList: View {} description: {Text("Install Homebrew to manage command-line tools and apps from Peel.")} actions: {- if let url = URL(string: "https://brew.sh") {- Link(destination: url) {- Text("Open brew.sh")- .minimumTarget()+ EmptyStateActions {+ if let url = URL(string: "https://brew.sh") {+ Link(destination: url) {+ Text("Open brew.sh")+ .minimumTarget()+ }}+ Button("Homebrew Is in Another Folder") { SettingsPane.general.open(with: openSettings) }}- Button("Homebrew Is in Another Folder") { SettingsPane.general.open(with: openSettings) }}} else if homebrew.needsDefinitions, homebrew.packages?.isEmpty != false, homebrew.runningCommand == nil,let reason = homebrew.whyItCantChange {diff --git a/Peel/Views/Installers/InstallerList.swift b/Peel/Views/Installers/InstallerList.swiftindex 5fe44cde..ccf28827 100644--- a/Peel/Views/Installers/InstallerList.swift+++ b/Peel/Views/Installers/InstallerList.swift@@ -41,7 +41,9 @@ struct InstallerList: View {} description: {UnreadableFoldersDetail(folders: installers.unreadable, needsFullDiskAccess: true)} actions: {- UnreadableFoldersActions(folders: installers.unreadable, needsFullDiskAccess: true)+ EmptyStateActions {+ UnreadableFoldersActions(folders: installers.unreadable, needsFullDiskAccess: true)+ }}} else if installers.sections.isEmpty {ContentUnavailableView(diff --git a/Peel/Views/Intel/IntelList.swift b/Peel/Views/Intel/IntelList.swiftindex fec24db3..5e62d36a 100644--- a/Peel/Views/Intel/IntelList.swift+++ b/Peel/Views/Intel/IntelList.swift@@ -64,7 +64,7 @@ struct IntelList: View {} description: {unread} actions: {- unreadActions+ EmptyStateActions { unreadActions }}} else if intel.findings.isEmpty {if #available(macOS 27, *) {diff --git a/Peel/Views/Orphans/OrphanList.swift b/Peel/Views/Orphans/OrphanList.swiftindex 170b48c6..456b3af0 100644--- a/Peel/Views/Orphans/OrphanList.swift+++ b/Peel/Views/Orphans/OrphanList.swift@@ -49,15 +49,17 @@ struct OrphanList: View {saying: parts.dropFirst().reduce(parts.first ?? Text(verbatim: "")) { Text("\($0)\n\n\($1)") })} actions: {- if library.listOfFoldersUnreadable {- StartOverButton(file: library.foldersFile, startedOver: "Started the list of app folders over.") {- library.startFoldersOver()+ EmptyStateActions {+ if library.listOfFoldersUnreadable {+ StartOverButton(file: library.foldersFile, startedOver: "Started the list of app folders over.") {+ library.startFoldersOver()+ }}+ UnreadableFoldersActions(+ folders: library.unreadable,+ needsFullDiskAccess: library.unreadableNeedsFullDiskAccess+ )}- UnreadableFoldersActions(- folders: library.unreadable,- needsFullDiskAccess: library.unreadableNeedsFullDiskAccess- )}} else if listsNothing, let unreadable = orphans.scan?.unreadableLocations, !unreadable.isEmpty {ContentUnavailableView {@@ -69,10 +71,12 @@ struct OrphanList: View {saying: Text("No orphaned files were found, but Peel couldn’t look inside \(RemovalFailureAlert.listedFolders(unreadable.map(\.url.abbreviatedPath))), so there may be some there."))} actions: {- UnreadableFoldersActions(- folders: unreadable.map(\.url),- needsFullDiskAccess: orphans.scan?.needsFullDiskAccess == true- )+ EmptyStateActions {+ UnreadableFoldersActions(+ folders: unreadable.map(\.url),+ needsFullDiskAccess: orphans.scan?.needsFullDiskAccess == true+ )+ }}} else if listsNothing {ContentUnavailableView(diff --git a/Peel/Views/Plugins/PluginList.swift b/Peel/Views/Plugins/PluginList.swiftindex 86c654d6..f195e788 100644--- a/Peel/Views/Plugins/PluginList.swift+++ b/Peel/Views/Plugins/PluginList.swift@@ -70,10 +70,12 @@ struct PluginList: View {saying: Text("No plug-ins were found, but Peel couldn’t look inside \(RemovalFailureAlert.listedFolders(plugins.unreadable.map(\.abbreviatedPath))), so there may be some there."))} actions: {- UnreadableFoldersActions(- folders: plugins.unreadable,- needsFullDiskAccess: plugins.needsFullDiskAccess- )+ EmptyStateActions {+ UnreadableFoldersActions(+ folders: plugins.unreadable,+ needsFullDiskAccess: plugins.needsFullDiskAccess+ )+ }}} else if plugins.plugins?.isEmpty == true {ContentUnavailableView(diff --git a/Peel/Views/Projects/ProjectList.swift b/Peel/Views/Projects/ProjectList.swiftindex 22f0ed45..bcc5b091 100644--- a/Peel/Views/Projects/ProjectList.swift+++ b/Peel/Views/Projects/ProjectList.swift@@ -47,20 +47,10 @@ struct ProjectList: View {.columnSearch(text: $searchText, prompt: "Search Build Artifacts", when: projects.groups?.isEmpty == false).scanState(phase(filtered), isRescanning: isRescanning, scan: projects.scanRun) {if projects.folders.isEmpty {- ContentUnavailableView {- Label("No Folders Yet", systemImage: "folder.badge.gearshape")- } description: {- Text("Choose where your projects live. Peel looks for what their builds left behind.")- } actions: {- Button("Choose a Folder…") {- Task { await projects.addFolder() }- }- .buttonStyle(.borderedProminent)- ForEach(projects.suggestedFolders, id: \.self) { folder in- Button("Add “\(folder.lastPathComponent)”") {- Task { await projects.add([folder]) }- }- }+ NoProjectFolders(suggested: projects.suggestedFolders) {+ Task { await projects.addFolder() }+ } add: { folder in+ Task { await projects.add([folder]) }}} else if !searchText.isEmpty, projects.groups?.isEmpty == false, filtered.isEmpty {ContentUnavailableView.search(text: searchText)@@ -73,10 +63,12 @@ struct ProjectList: View {)unsearchableReasons} actions: {- UnreadableFoldersActions(- folders: projects.unreadable,- needsFullDiskAccess: projects.needsFullDiskAccess- )+ EmptyStateActions {+ UnreadableFoldersActions(+ folders: projects.unreadable,+ needsFullDiskAccess: projects.needsFullDiskAccess+ )+ }}} else if projects.groups?.isEmpty == true, !projects.unsearchable.isEmpty {ContentUnavailableView {@@ -223,3 +215,27 @@ private struct ProjectRow: View {}}}++/// What Build Artifacts shows before a folder is chosen: a button to choose one, and one for each usual place for+/// projects on this Mac.+struct NoProjectFolders: View {+ let suggested: [URL]+ let choose: () -> Void+ let add: (URL) -> Void++ var body: some View {+ ContentUnavailableView {+ Label("No Folders Yet", systemImage: "folder.badge.gearshape")+ } description: {+ Text("Choose where your projects live. Peel looks for what their builds left behind.")+ } actions: {+ EmptyStateActions {+ Button("Choose a Folder…", action: choose)+ .buttonStyle(.borderedProminent)+ ForEach(suggested, id: \.self) { folder in+ Button("Add “\(folder.lastPathComponent)”") { add(folder) }+ }+ }+ }+ }+}diff --git a/PeelTests/NoProjectFoldersTests.swift b/PeelTests/NoProjectFoldersTests.swiftnew file mode 100644index 00000000..13571488--- /dev/null+++ b/PeelTests/NoProjectFoldersTests.swift@@ -0,0 +1,17 @@+import AppKit+@testable import Peel+import SwiftUI+import Testing++@MainActor+struct NoProjectFoldersTests {+ @Test func itsButtonsFitTheListColumn() {+ let suggested = ["Developer", "Projects", "Code", "src"].map { URL(filePath: "/Users/Shared/\($0)") }+ let host = NSHostingController(rootView: NoProjectFolders(suggested: suggested, choose: {}, add: { _ in }))+ let column = ListColumn.width++ let size = host.sizeThatFits(in: CGSize(width: column, height: 2_000))++ #expect(size.width <= column)+ }+}