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.

Show how far a removal has got on every page that moves things

Țugui Dragoș87c638c8d7ef
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index 7d5de267..fe785fdc 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -170699,6 +170699,112 @@
}
}
},
+ "Waiting for %@ to quit" : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Čekání na ukončení: %@"
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Warten auf Beenden: %@"
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Esperando la salida de %@"
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "En attente de voir %@ quitter"
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Attendo l’uscita da %@"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@の終了を待機中"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@ 종료 대기 중"
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Wacht op het stoppen van %@"
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Czekam na zakończenie: %@"
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Aguardando o encerramento de %@"
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Se așteaptă ca %@ să se închidă"
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ожидание завершения %@"
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Väntar på att %@ avslutas"
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Kapanması bekleniyor: %@"
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Очікування на завершення: %@"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "正在等待%@退出"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "正在等待%@結束"
+ }
+ }
+ }
+ },
"Waiting for approval" : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swift b/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swift
index 79b19078..c6c2156f 100644
--- a/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swift
@@ -421,10 +421,12 @@ public struct TrashService: Sendable {
let more = await trash(rest, usingHelperFor: privilegedURLs, removal: removal, lettingTheirProgramsRun: [])
result.trashed += more.trashed
result.failures += more.failures
- // Nobody asked for these folders, so one that stays is no failure.
+ // Nobody asked for these folders, so one that stays is no failure, and they are not counted with the rest.
for folder in MakersFolders(environment: environment, names: names).above(more.trashed.map(\.originalURL))
where MakersFolders.isEmpty(folder) {
- let moved = await trash([folder], usingHelperFor: [], removal: removal, lettingTheirProgramsRun: []).trashed
+ let moved = await MoveCount.$current.withValue(nil) {
+ await trash([folder], usingHelperFor: [], removal: removal, lettingTheirProgramsRun: []).trashed
+ }
result.trashed += moved
result.emptied.formUnion(moved.map(\.originalURL))
}
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/UninstallationTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/UninstallationTests.swift
index 7b0f6a58..6d683725 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/UninstallationTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/UninstallationTests.swift
@@ -685,11 +685,17 @@ struct UninstallationTests {
leftovers: [file(product, .applicationSupport), file(top, .applicationSupport), file(help, .caches)]
)
- let went = await plan.move([bundle, product, top, help], using: try service(in: directory, refusing: nil))
+ let service = try service(in: directory, refusing: nil)
+ let moves = MoveCount()
+
+ let went = await MoveCount.$current.withValue(moves) {
+ await plan.move([bundle, product, top, help], using: service)
+ }
let maker = directory.url.appending(path: "\(support)/Example")
#expect(Set(went.trashed.map { PathPattern.comparablePath(of: $0.originalURL) })
== Set([bundle, product, top, help, maker].map(PathPattern.comparablePath(of:))))
+ #expect(moves.value == 4)
let records = RemovalPart(source: "Notes", sourceKey: nil, tool: "applications")
.records(of: went, sizes: [bundle: 4_096], batch: UUID())
let size = { (url: URL) in
diff --git a/Peel/Model/MoveProgress.swift b/Peel/Model/MoveProgress.swift
new file mode 100644
index 00000000..daed98c5
--- /dev/null
+++ b/Peel/Model/MoveProgress.swift
@@ -0,0 +1,30 @@
+import Observation
+import PeelCore
+
+/// How far a removal has got, for the bar at the foot of the page while it runs.
+@Observable
+final class MoveProgress {
+ private(set) var isMoving = false
+ /// How many of `toMove` items have moved, brought up to date ten times a second while a move runs.
+ private(set) var moved = 0
+ private(set) var toMove = 0
+
+ /// Runs `work`, counting each item a move in it takes to the Trash.
+ func run<Result>(toMove count: Int, _ work: () async -> Result) async -> Result {
+ isMoving = true
+ moved = 0
+ toMove = count
+ let counted = MoveCount()
+ let watching = Task { [weak self] in
+ while !Task.isCancelled {
+ try? await Task.sleep(for: .milliseconds(100))
+ self?.moved = counted.value
+ }
+ }
+ defer {
+ watching.cancel()
+ isMoving = false
+ }
+ return await MoveCount.$current.withValue(counted) { await work() }
+ }
+}
diff --git a/Peel/Model/SelectionCarrier.swift b/Peel/Model/SelectionCarrier.swift
index c45fd186..84abfdb6 100644
--- a/Peel/Model/SelectionCarrier.swift
+++ b/Peel/Model/SelectionCarrier.swift
@@ -42,11 +42,8 @@ extension Tool {
@Observable
final class SelectionCarrier {
private var carried = CarriedSelection()
- /// True while a Move to Trash moves the parts, one after another.
- private(set) var isMoving = false
- /// How many of `toMove` items have moved, brought up to date ten times a second while a move runs.
- private(set) var movedSoFar = 0
- private(set) var toMove = 0
+ /// A Move to Trash moving the parts, one after another, until every tool that moved is up to date.
+ let progress = MoveProgress()
@ObservationIgnored private let tools: [Tool: any CarriesSelection]
@ObservationIgnored private let apps: AppLibrary
@ObservationIgnored private let history: RemovalHistoryStore
@@ -93,24 +90,10 @@ final class SelectionCarrier {
/// Moves `parts` as one removal. Each part is in History as soon as it moved, so nothing that moved is lost if
/// Peel stops halfway, and a part whose tool kept it stays selected, with the app to quit named after.
func move(_ parts: [CarriedSelection.Part]) async {
- isMoving = true
- movedSoFar = 0
- toMove = parts.reduce(0) { $0 + $1.count }
- let count = MoveCount()
- let watching = Task { [weak self] in
- while !Task.isCancelled {
- try? await Task.sleep(for: .milliseconds(100))
- self?.movedSoFar = count.value
- }
- }
- defer {
- watching.cancel()
- isMoving = false
- }
- var removal = RemovalInProgress()
- var appsToQuit: [String] = []
- let pass = await MoveCount.$current.withValue(count) {
- await QuitGuard.shared.run {
+ await progress.run(toMove: parts.reduce(0) { $0 + $1.count }) {
+ var removal = RemovalInProgress()
+ var appsToQuit: [String] = []
+ let pass = await QuitGuard.shared.run {
await CarriedSelection.pass(parts) { part in
guard let tool = tool(of: part), let result = await tool.move(part, apps: apps) else {
appsToQuit.append(tool(of: part)?.appToQuit(for: part) ?? part.title)
@@ -120,16 +103,16 @@ final class SelectionCarrier {
return result
}
}
- }
- history.finish(removal)
- outcome.report(pass.result, appsToQuit: appsToQuit)
- for part in pass.refused {
- tool(of: part)?.deselect(part)
- }
- let moved = pass.moved.map(\.part)
- for name in moved.tools {
- guard let tool = Tool(rawValue: name) else { continue }
- await tools[tool]?.refresh(after: moved.filter { $0.page.tool == name }, apps: apps)
+ history.finish(removal)
+ outcome.report(pass.result, appsToQuit: appsToQuit)
+ for part in pass.refused {
+ tool(of: part)?.deselect(part)
+ }
+ let moved = pass.moved.map(\.part)
+ for name in moved.tools {
+ guard let tool = Tool(rawValue: name) else { continue }
+ await tools[tool]?.refresh(after: moved.filter { $0.page.tool == name }, apps: apps)
+ }
}
}
diff --git a/Peel/Views/AppDetailView.swift b/Peel/Views/AppDetailView.swift
index a7efa912..cbb757cf 100644
--- a/Peel/Views/AppDetailView.swift
+++ b/Peel/Views/AppDetailView.swift
@@ -12,6 +12,7 @@ struct AppDetailView: View {
@Environment(RemovalOutcome.self) private var outcome
@State private var isRescanning = false
@State private var resetsPrivacy = false
+ @State private var progress = MoveProgress()
@State private var removesDockTile = true
@State private var isConfirmingPrivacyReset = false
/// The result of the last privacy reset started from the More menu, shown under the buttons.
@@ -203,7 +204,9 @@ struct AppDetailView: View {
isScanning: isBusy,
scan: plan.scanRun,
isEnabled: !plan.selectedURLs.isEmpty && !plan.isRemoving && !quitting.isWaiting,
- onRemove: requestRemoval
+ onRemove: requestRemoval,
+ progress: progress,
+ waitingToQuit: quitting.isWaiting ? quitting.names : nil
)
}
}
@@ -475,25 +478,27 @@ struct AppDetailView: View {
let plan = plan
defer { plan.question.finish() }
guard plan.runningProcesses.isEmpty else { return requestRemoval() }
- let result = await QuitGuard.shared.run {
- // The one step that goes before the move: `tccutil` only finds an app that is still in its place.
- let service = TrashService(exclusions: ExclusionsStore.shared.exclusions)
- let privacy = await PrivacyReset.reset(resetting(request.urls), beforeMovingWith: service)
- let result = await plan.move(request)
- let keptItsFiles = plan.uninstallation?.keptItsFiles(after: result, selection: request.urls) == true
- outcome.report(result, privacy: privacy, keptTheirFiles: keptItsFiles ? [plan.app.name] : [])
- if removesDockTile, result.trashed.contains(where: { $0.originalURL == plan.app.url }) {
- _ = await DockTiles().takeOut([plan.app.url])
- }
- if let state = AppManagement.state(
- after: result,
- appBundles: [plan.app.url],
- movedByTheHelper: plan.privilegedURLs
- ) {
- home.record(appManagement: state)
+ let result = await progress.run(toMove: request.urls.count) {
+ await QuitGuard.shared.run {
+ // The one step that goes before the move: `tccutil` only finds an app that is still in its place.
+ let service = TrashService(exclusions: ExclusionsStore.shared.exclusions)
+ let privacy = await PrivacyReset.reset(resetting(request.urls), beforeMovingWith: service)
+ let result = await plan.move(request)
+ let keptItsFiles = plan.uninstallation?.keptItsFiles(after: result, selection: request.urls) == true
+ outcome.report(result, privacy: privacy, keptTheirFiles: keptItsFiles ? [plan.app.name] : [])
+ if removesDockTile, result.trashed.contains(where: { $0.originalURL == plan.app.url }) {
+ _ = await DockTiles().takeOut([plan.app.url])
+ }
+ if let state = AppManagement.state(
+ after: result,
+ appBundles: [plan.app.url],
+ movedByTheHelper: plan.privilegedURLs
+ ) {
+ home.record(appManagement: state)
+ }
+ await history.record(result, tool: .applications, source: plan.app.name, sizes: request.sizes)
+ return result
}
- await history.record(result, tool: .applications, source: plan.app.name, sizes: request.sizes)
- return result
}
if result.trashed.contains(where: { $0.originalURL == plan.app.url }) {
diff --git a/Peel/Views/Cloud/CloudView.swift b/Peel/Views/Cloud/CloudView.swift
index 13576a97..c8f94cd7 100644
--- a/Peel/Views/Cloud/CloudView.swift
+++ b/Peel/Views/Cloud/CloudView.swift
@@ -116,6 +116,7 @@ struct CloudView: View {
RemovalBar(
selectedSize: cloud.selectedSize,
isScanning: cloud.isScanning,
+ isWorking: cloud.isFreeing,
scan: cloud.scanRun,
isEnabled: cloud.selectedSize > 0 && !cloud.isFreeing,
onRemove: { isConfirming = true },
diff --git a/Peel/Views/MultipleAppsView.swift b/Peel/Views/MultipleAppsView.swift
index 6ffebb00..f72b7578 100644
--- a/Peel/Views/MultipleAppsView.swift
+++ b/Peel/Views/MultipleAppsView.swift
@@ -10,6 +10,7 @@ struct MultipleAppsView: View {
@State private var plan: BulkRemovalPlan
@State private var quitting = QuitBeforeRemoving()
@State private var resetsPrivacy = false
+ @State private var progress = MoveProgress()
@State private var removesDockTiles = true
@State private var isRescanning = false
@State private var questionTitle = Text(verbatim: "")
@@ -114,7 +115,9 @@ struct MultipleAppsView: View {
isScanning: plan.isScanning,
scan: plan.scanRun,
isEnabled: !plan.selectedURLs.isEmpty && !plan.isRemoving && !quitting.isWaiting,
- onRemove: requestRemoval
+ onRemove: requestRemoval,
+ progress: progress,
+ waitingToQuit: quitting.isWaiting ? quitting.names : nil
)
}
}
@@ -344,27 +347,31 @@ struct MultipleAppsView: View {
let plan = plan
defer { plan.question.finish() }
guard plan.runningProcesses.isEmpty else { return requestRemoval() }
- let result = await QuitGuard.shared.run {
- // The privacy reset runs before the move, because `tccutil` only finds an app that is still in its place.
- let service = TrashService(exclusions: ExclusionsStore.shared.exclusions)
- let privacy = await PrivacyReset.reset(resetting(request.urls), beforeMovingWith: service)
- let result = await plan.move(request)
- let kept = plan.bulk?.appsThatKeptTheirFiles(after: result, selection: request.urls) ?? []
- outcome.report(result, privacy: privacy, keptTheirFiles: kept.map(\.name))
- if removesDockTiles {
- let moved = Set(result.trashed.map(\.originalURL))
- // Asked of every app that moved, since one opened after the last scan has a tile now.
- _ = await DockTiles().takeOut(plan.apps.map(\.url).filter(moved.contains).sorted { $0.path < $1.path })
- }
- if let state = AppManagement.state(
- after: result,
- appBundles: Set(plan.apps.map(\.url)),
- movedByTheHelper: plan.privilegedURLs
- ) {
- home.record(appManagement: state)
+ let result = await progress.run(toMove: request.urls.count) {
+ await QuitGuard.shared.run {
+ // The privacy reset runs before the move, because `tccutil` only finds an app that is still in its
+ // place.
+ let service = TrashService(exclusions: ExclusionsStore.shared.exclusions)
+ let privacy = await PrivacyReset.reset(resetting(request.urls), beforeMovingWith: service)
+ let result = await plan.move(request)
+ let kept = plan.bulk?.appsThatKeptTheirFiles(after: result, selection: request.urls) ?? []
+ outcome.report(result, privacy: privacy, keptTheirFiles: kept.map(\.name))
+ if removesDockTiles {
+ let moved = Set(result.trashed.map(\.originalURL))
+ // Asked of every app that moved, since one opened after the last scan has a tile now.
+ let apps = plan.apps.map(\.url).filter(moved.contains).sorted { $0.path < $1.path }
+ _ = await DockTiles().takeOut(apps)
+ }
+ if let state = AppManagement.state(
+ after: result,
+ appBundles: Set(plan.apps.map(\.url)),
+ movedByTheHelper: plan.privilegedURLs
+ ) {
+ home.record(appManagement: state)
+ }
+ await plan.record(result, sizes: request.sizes, in: history)
+ return result
}
- await plan.record(result, sizes: request.sizes, in: history)
- return result
}
// When an app bundle moved, reloading the library changes the selection, which rebuilds this page. When
// only files moved, the plan is refreshed here: otherwise they would stay listed, and moving them again
diff --git a/Peel/Views/Plugins/PluginDetailView.swift b/Peel/Views/Plugins/PluginDetailView.swift
index 39697262..bcdf9cea 100644
--- a/Peel/Views/Plugins/PluginDetailView.swift
+++ b/Peel/Views/Plugins/PluginDetailView.swift
@@ -81,6 +81,12 @@ struct PluginDetailView: View {
NSWorkspace.shared.activateFileViewerSelecting([plugin.url])
}
Spacer()
+ BusyShown(isBusy: plugins.isRemoving) { isShown in
+ if isShown {
+ ProgressView()
+ .controlSize(.small)
+ }
+ }
Button("Move to Trash", systemImage: "trash") {
isConfirmingRemoval = true
}
diff --git a/Peel/Views/RemovalBar.swift b/Peel/Views/RemovalBar.swift
index 1bb7765f..7f98b54e 100644
--- a/Peel/Views/RemovalBar.swift
+++ b/Peel/Views/RemovalBar.swift
@@ -15,6 +15,8 @@ struct RemovalBar: View {
@State private var isShowingPages = false
/// The page's own words under the question, worked out when Move to Trash was pressed.
@State private var pageMessage: Text?
+ /// The apps last named in `waitingToQuit`, still named while the spinner stays up after the wait.
+ @State private var waitingNames = ""
private let purpose: Purpose
/// True while the page scans. The bar then moves nothing, whatever is selected.
let isScanning: Bool
@@ -29,6 +31,10 @@ struct RemovalBar: View {
/// A short message about what the page's own action just did, shown in place of the selection, for an
/// action History doesn't record (freeing iCloud files, for example).
var notice: BarNotice?
+ /// The page's own removal, counted beside the spinner while it moves.
+ var progress: MoveProgress?
+ /// The apps the page's removal waits for to quit.
+ var waitingToQuit: String?
private enum Purpose {
/// What the page itself selected, which `onRemove` acts on.
@@ -59,7 +65,9 @@ struct RemovalBar: View {
onRemove: @escaping () -> Void,
title: LocalizedStringResource = "Move to Trash",
systemImage: String = "trash",
- notice: BarNotice? = nil
+ notice: BarNotice? = nil,
+ progress: MoveProgress? = nil,
+ waitingToQuit: String? = nil
) {
purpose = .own(
SizeTotal(known: selectedSize, isComplete: isSelectionMeasured),
@@ -72,6 +80,8 @@ struct RemovalBar: View {
self.title = title
self.systemImage = systemImage
self.notice = notice
+ self.progress = progress
+ self.waitingToQuit = waitingToQuit
}
/// A bar for a page of the storage tools, whose selection travels to the others' pages.
@@ -92,6 +102,11 @@ struct RemovalBar: View {
if case .carried(let page, _) = purpose { page } else { nil }
}
+ /// The removal this bar counts: the carried selection's on a storage tool's page, the page's own otherwise.
+ private var moving: MoveProgress? {
+ page == nil ? progress : carrier.progress
+ }
+
private var reading: Reading {
switch purpose {
case .own(let total, let isEnabled, let onRemove):
@@ -106,7 +121,7 @@ struct RemovalBar: View {
return Reading(
total: parts.total,
pages: parts.contains { $0.page != page } ? parts.count : nil,
- isEnabled: !parts.isEmpty && !carrier.isMoving && !isScanning && !isWorking,
+ isEnabled: !parts.isEmpty && !carrier.progress.isMoving && !isScanning && !isWorking,
remove: { ask(about: parts) }
)
}
@@ -115,73 +130,81 @@ struct RemovalBar: View {
var body: some View {
let reading = reading
let isEnabled = reading.isEnabled && exclusions.exclusions.isKnown && !history.isUnreadable
- BusyShown(isBusy: page != nil && carrier.isMoving) { isShowingMove in
- BusyShown(isBusy: isScanning) { isShowingScan in
- BusyShown(isBusy: isWorking) { isShowingWork in
- FloatingBar {
- if let notice {
- Text(verbatim: notice.figure)
- .font(.barFigure)
- .monospacedDigit()
- Text(notice.words)
- .foregroundStyle(.secondary)
- } else if let moved {
- Text(moved.size.known > 0
- ? moved.size.text
- : String(inflecting: "^[\(moved.records.count) item](inflect: true)"))
- .font(.barFigure)
- .monospacedDigit()
- Text("Moved", comment: "A label after a figure at the foot of a page, for a moment after a removal: a size, such as 303 kB, or a count, such as 3 items. Write it so it reads right after any figure, never as a form that agrees with the number or adds (s).")
- .foregroundStyle(.secondary)
- } else if isShowingScan || isShowingWork {
- ProgressView()
- .controlSize(.small)
- if isShowingScan {
- ReadSoFar(scan: scan)
+ BusyShown(isBusy: moving?.isMoving == true) { isShowingMove in
+ BusyShown(isBusy: waitingToQuit != nil) { isShowingWait in
+ BusyShown(isBusy: isScanning) { isShowingScan in
+ BusyShown(isBusy: isWorking) { isShowingWork in
+ FloatingBar {
+ if let notice {
+ Text(verbatim: notice.figure)
+ .font(.barFigure)
+ .monospacedDigit()
+ Text(notice.words)
.foregroundStyle(.secondary)
- }
- } else if isShowingMove {
- ProgressView()
- .controlSize(.small)
- Text("Moved \(carrier.movedSoFar, format: .number) of \(carrier.toMove, format: .number)")
- .monospacedDigit()
- .foregroundStyle(.secondary)
- } else if let pages = reading.pages, let page {
- // The pages go under the figure rather than beside it, so the capsule stays as wide as with
- // the selection of one page, which fits beside the button in every language at the
- // narrowest column.
- Button {
- isShowingPages = true
- } label: {
- VStack(alignment: .leading, spacing: 0) {
- figure(reading.total)
- HStack(spacing: 4) {
- Text("Selected on ^[\(pages) page](inflect: true)", comment: "Under the figure in the bar at the foot of a page, when the selection is on several pages: the figure is a size, such as 426 kB. Word Selected as the bar's own \"Selected\" is worded, agreeing with no number but the pages'.")
- Image(systemName: "chevron.up")
- .font(.caption2.weight(.semibold))
- .accessibilityHidden(true)
- }
- .font(.subheadline)
+ } else if let moved {
+ Text(moved.size.known > 0
+ ? moved.size.text
+ : String(inflecting: "^[\(moved.records.count) item](inflect: true)"))
+ .font(.barFigure)
+ .monospacedDigit()
+ Text("Moved", comment: "A label after a figure at the foot of a page, for a moment after a removal: a size, such as 303 kB, or a count, such as 3 items. Write it so it reads right after any figure, never as a form that agrees with the number or adds (s).")
.foregroundStyle(.secondary)
+ } else if isShowingScan || isShowingWork {
+ ProgressView()
+ .controlSize(.small)
+ if isShowingScan {
+ ReadSoFar(scan: scan)
+ .foregroundStyle(.secondary)
}
- .contentShape(.rect)
- }
- .buttonStyle(.plain)
- .popover(isPresented: $isShowingPages, arrowEdge: .top) {
- CarriedPartsList(page: page)
+ } else if isShowingMove, let moving {
+ ProgressView()
+ .controlSize(.small)
+ Text("Moved \(moving.moved, format: .number) of \(moving.toMove, format: .number)")
+ .monospacedDigit()
+ .foregroundStyle(.secondary)
+ } else if isShowingWait {
+ ProgressView()
+ .controlSize(.small)
+ Text("Waiting for \(waitingNames) to quit")
+ .foregroundStyle(.secondary)
+ } else if let pages = reading.pages, let page {
+ // The pages go under the figure rather than beside it, so the capsule stays as wide
+ // as with the selection of one page, which fits beside the button in every language
+ // at the narrowest column.
+ Button {
+ isShowingPages = true
+ } label: {
+ VStack(alignment: .leading, spacing: 0) {
+ figure(reading.total)
+ HStack(spacing: 4) {
+ Text("Selected on ^[\(pages) page](inflect: true)", comment: "Under the figure in the bar at the foot of a page, when the selection is on several pages: the figure is a size, such as 426 kB. Word Selected as the bar's own \"Selected\" is worded, agreeing with no number but the pages'.")
+ Image(systemName: "chevron.up")
+ .font(.caption2.weight(.semibold))
+ .accessibilityHidden(true)
+ }
+ .font(.subheadline)
+ .foregroundStyle(.secondary)
+ }
+ .contentShape(.rect)
+ }
+ .buttonStyle(.plain)
+ .popover(isPresented: $isShowingPages, arrowEdge: .top) {
+ CarriedPartsList(page: page)
+ }
+ } else {
+ figure(reading.total)
+ Text("Selected", comment: "A label after a figure at the foot of a page: a size, such as 303 kB, or a count, such as 3 items. Write it so it reads right after any figure, as \"en la selección\" does, never as a form that agrees with the number or adds (s).")
+ .foregroundStyle(.secondary)
}
- } else {
- figure(reading.total)
- Text("Selected", comment: "A label after a figure at the foot of a page: a size, such as 303 kB, or a count, such as 3 items. Write it so it reads right after any figure, as \"en la selección\" does, never as a form that agrees with the number or adds (s).")
- .foregroundStyle(.secondary)
+ } action: {
+ Button(String(localized: title), systemImage: systemImage, action: reading.remove)
+ .disabled(!isEnabled)
}
- } action: {
- Button(String(localized: title), systemImage: systemImage, action: reading.remove)
- .disabled(!isEnabled)
+ .motion(value: isShowingMove)
+ .motion(value: isShowingWait)
+ .motion(value: isShowingScan)
+ .motion(value: isShowingWork)
}
- .motion(value: isShowingMove)
- .motion(value: isShowingScan)
- .motion(value: isShowingWork)
}
}
}
@@ -190,6 +213,9 @@ struct RemovalBar: View {
.motion(value: reading.pages)
.motion(value: moved)
.motion(value: notice)
+ .onChange(of: waitingToQuit, initial: true) { _, names in
+ if let names { waitingNames = names }
+ }
.onChange(of: history.justMoved) { _, batch in
moved = batch
}