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
Select on every area of Space from its toolbar
Țugui Dragoșf15b7b190dbc
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 0a53a2c6..2f5ab870 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -25,6 +25,8 @@ The first public release, for macOS 26 and later, on Apple silicon and Intel Macwhat it didn't move, with the reason.- Keeps what you select on the pages that free space while you look at the others, and moves it all at once, asone entry in History.+- Selects what Peel recommends, everything, or nothing, on one list or on every page of a tool at once, and asks+ first before it selects what Peel doesn't recommend.- Leaves alone the files, folders, and apps you exclude.- Checks your apps for updates, and watches the Trash for apps you remove yourself.- Says in About when a new version of Peel is out, with where to get it, and downloads nothing itself.diff --git a/Peel/Model/SpaceLibrary.swift b/Peel/Model/SpaceLibrary.swiftindex 662da355..3feb6e6b 100644--- a/Peel/Model/SpaceLibrary.swift+++ b/Peel/Model/SpaceLibrary.swift@@ -59,6 +59,26 @@ final class SpaceLibrary: RowSelection {plannedFor[item.id] = (item, revision)}+ /// Makes the plans of the areas in `items` that have none yet, as the page's scan: Rescan turns into Stop+ /// meanwhile, and a scan that was stopped keeps no plan. True once every one of them has its plan.+ func planEvery(_ items: [SpaceItem]) async -> Bool {+ let unplanned = items.filter { !$0.isReadOnly && plans[$0.id] == nil }+ guard !unplanned.isEmpty else { return true }+ let answer = await scanRun.run {+ var made: [(item: SpaceItem, plan: SpaceRemoval.Plan, exclusions: Int)] = []+ for item in unplanned where !Task.isCancelled {+ let new = await self.newPlan(for: item)+ made.append((item, new.plan, new.exclusions))+ }+ return made+ }+ guard let made = answer else { return false }+ for (item, plan, revision) in made {+ keep(plan, for: item, madeWith: revision)+ }+ return true+ }+/// Brings what is selected in each area in line with the helper as it is now, without measuring again.func follow(canUseHelper: Bool) {guard canUseHelper != self.canUseHelper else { return }diff --git a/Peel/Views/SelectMenu.swift b/Peel/Views/SelectMenu.swiftindex 815ba81e..e4b78ec2 100644--- a/Peel/Views/SelectMenu.swift+++ b/Peel/Views/SelectMenu.swift@@ -7,7 +7,17 @@ struct SelectMenu: View {let list: SelectableRows<URL>let selection: any RowSelectionprivate let scope: Scope+ /// Reads what the list does not know yet, such as Space's areas never opened, before a command runs. Nil once+ /// the list is whole. False when the reading was stopped, and the command is then dropped.+ private let reading: (() async -> Bool)?+ private let isDisabled: Bool@State private var notRecommended: Int?+ /// A command chosen before the list was whole, which runs once it is.+ @State private var waiting: Command?++ private enum Command {+ case recommended, all, none+ }private enum Scope {/// The list's name, as the page shows it, which the question names. With nothing a click can select, the@@ -21,12 +31,22 @@ struct SelectMenu: View {self.list = listself.selection = selectionscope = .list(place)+ reading = nil+ isDisabled = false}- init(pages: Int, list: SelectableRows<URL>, selection: any RowSelection) {+ init(+ pages: Int,+ list: SelectableRows<URL>,+ selection: any RowSelection,+ reading: (() async -> Bool)?,+ isDisabled: Bool+ ) {self.list = listself.selection = selectionscope = .pages(pages)+ self.reading = reading+ self.isDisabled = isDisabled}var body: some View {@@ -46,7 +66,7 @@ struct SelectMenu: View {} label: {ToolbarMenuLabel(title: "Select", systemImage: "checklist")}- .disabled(list.selectable.isEmpty)+ .disabled(isDisabled || (list.selectable.isEmpty && reading == nil)).help(Text("Select on every page in the list"))}}@@ -70,27 +90,54 @@ struct SelectMenu: View {Text("This also selects ^[\(notRecommended ?? 0) item](inflect: true) Peel doesn’t recommend removing. Check each one before you move it, or select only what Peel recommends.")}}+ .onChange(of: waiting) { _, command in+ guard let command else { return }+ waiting = nil+ run(command)+ }}+ /// Until the list is whole, what the commands would do is not known, so they stay offered.@ViewBuilderprivate var commands: some View {let selected = selection.selectedURLs- let asks = !list.notRecommendedAdded(by: selected).isEmpty+ let isWhole = reading == nil// Where Peel recommends every row a click can select, it would only repeat Select All.- if list.recommended.count < list.selectable.count {- Button("Select Recommended") { selection.select(list.selectingRecommended(in: selected)) }- .disabled(list.recommended.isEmpty || list.isRecommendedSelected(in: selected))+ if !isWhole || list.recommended.count < list.selectable.count {+ Button("Select Recommended") { choose(.recommended) }+ .disabled(isWhole && (list.recommended.isEmpty || list.isRecommendedSelected(in: selected)))}- Button(asks ? "Select All…" : "Select All") {- if asks {- notRecommended = list.notRecommendedAdded(by: selected).count- } else {+ Button(!isWhole || !list.notRecommendedAdded(by: selected).isEmpty ? "Select All…" : "Select All") {+ choose(.all)+ }+ .disabled(isWhole && list.isAllSelected(in: selected))+ Button("Deselect All") { run(.none) }+ .disabled(list.isNoneSelected(in: selected))+ }++ private func choose(_ command: Command) {+ guard let reading else { return run(command) }+ Task {+ guard await reading() else { return }+ waiting = command+ }+ }++ private func run(_ command: Command) {+ let selected = selection.selectedURLs+ switch command {+ case .recommended:+ selection.select(list.selectingRecommended(in: selected))+ case .all:+ let added = list.notRecommendedAdded(by: selected).count+ if added == 0 {selection.select(list.selectingAll(in: selected))+ } else {+ notRecommended = added}+ case .none:+ selection.select(list.deselectingAll(in: selected))}- .disabled(list.isAllSelected(in: selected))- Button("Deselect All") { selection.select(list.deselectingAll(in: selected)) }- .disabled(list.isNoneSelected(in: selected))}private var question: Text {diff --git a/Peel/Views/SelectOnEveryPage.swift b/Peel/Views/SelectOnEveryPage.swiftindex a4dac95f..13dc7147 100644--- a/Peel/Views/SelectOnEveryPage.swift+++ b/Peel/Views/SelectOnEveryPage.swift@@ -7,12 +7,16 @@ struct SelectOnEveryPage: View {@Environment(SelectionCarrier.self) private var carrierlet pages: SelectablePages<CarriedSelection.Page, URL>let selection: any RowSelection+ var reading: (() async -> Bool)?+ var isDisabled = falsevar body: some View {SelectMenu(pages: pages.selectablePageCount,list: pages.rows,- selection: SeeingPages(selection: selection, pages: pages, carrier: carrier)+ selection: SeeingPages(selection: selection, pages: pages, carrier: carrier),+ reading: reading,+ isDisabled: isDisabled)}}diff --git a/Peel/Views/Space/SpaceList.swift b/Peel/Views/Space/SpaceList.swiftindex 363ab68b..b4aa6c4c 100644--- a/Peel/Views/Space/SpaceList.swift+++ b/Peel/Views/Space/SpaceList.swift@@ -3,6 +3,7 @@ import SwiftUIstruct SpaceList: View {@Environment(SpaceLibrary.self) private var space+ @Environment(HelperModel.self) private var helper@State private var isRescanning = false@State private var searchText = ""@@ -12,6 +13,11 @@ struct SpaceList: View {return items.filter { SearchText.matches(String(localized: $0.words.title), searchText) }}+ private var shownAreas: [SpaceItem] {+ guard let report = space.report else { return [] }+ return SpaceItem.Category.allCases.flatMap { listed(in: $0, of: report) }+ }+private var isFindingNothing: Bool {guard let report = space.report, !searchText.isEmpty else { return false }return SpaceItem.Category.allCases.allSatisfy { listed(in: $0, of: report).isEmpty }@@ -65,6 +71,18 @@ struct SpaceList: View {.navigationTitle(Text(Tool.space.title)).announcesScan(space.isScanning, found: space.summary, wasStopped: space.scanRun.wasStopped).toolbar {+ ToolbarItem {+ let shown = shownAreas+ SelectOnEveryPage(+ pages: SelectablePages(shown.compactMap { item in+ space.plans[item.id].map { (item.page, $0.selectableRows(canUseHelper: helper.canAct)) }+ }),+ selection: space,+ reading: shown.contains { !$0.isReadOnly && space.plans[$0.id] == nil }+ ? { await space.planEvery(shown) } : nil,+ isDisabled: space.isScanning+ )+ }ToolbarItem {RescanButton(isRunning: $isRescanning, isDisabled: space.isRemoving, scan: space.scanRun) {await space.refresh()