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.

Tell VoiceOver how the scans of an app's page and the Reset sheet ended

Țugui Dragoș5263293679d0
diff --git a/Peel/Views/AppDetailView.swift b/Peel/Views/AppDetailView.swift
index 86efa56d..eea89156 100644
--- a/Peel/Views/AppDetailView.swift
+++ b/Peel/Views/AppDetailView.swift
@@ -191,6 +191,7 @@ struct AppDetailView: View {
}
.scrollBarBelowSectionHeaders()
.scanState(phase, fadesInResults: false, scan: plan.scanRun)
+ .announcesScan(plan.isScanning, found: plan.total.spoken, wasStopped: plan.scanRun.wasStopped)
.edgeBar(.bottom) {
if plan.scan != nil {
let selected = plan.request.total
diff --git a/Peel/Views/MultipleAppsView.swift b/Peel/Views/MultipleAppsView.swift
index 60134ed6..481413ee 100644
--- a/Peel/Views/MultipleAppsView.swift
+++ b/Peel/Views/MultipleAppsView.swift
@@ -108,6 +108,7 @@ struct MultipleAppsView: View {
.dimmedWhileBusy(plan.isRemoving)
.disabled(plan.isRemoving)
.scanState(phase, isRescanning: isRescanning, fadesInResults: false, scan: plan.scanRun)
+ .announcesScan(plan.isScanning, found: plan.total.spoken, wasStopped: plan.scanRun.wasStopped)
.edgeBar(.bottom) {
if plan.bulk != nil {
let selected = plan.request.total
diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swift
index 57737b3a..e7d05063 100644
--- a/Peel/Views/Presentation.swift
+++ b/Peel/Views/Presentation.swift
@@ -531,6 +531,12 @@ extension Int64? {
}
extension SizeTotal {
+ /// What VoiceOver hears of a page's total once its scan ends, as the page's header says it, or nil when nothing
+ /// is to move.
+ var spoken: AttributedString? {
+ known > 0 || !isComplete ? AttributedString(localized: "\(text) can be moved to the Trash") : nil
+ }
+
var text: String {
switch reading {
case .exactly(let size): size.byteCount
diff --git a/Peel/Views/ResetSheet.swift b/Peel/Views/ResetSheet.swift
index 0fbd101e..ba72be51 100644
--- a/Peel/Views/ResetSheet.swift
+++ b/Peel/Views/ResetSheet.swift
@@ -184,6 +184,12 @@ struct ResetSheet: View {
}
}
.scrollBarBelowSectionHeaders()
+ .announcesScan(
+ plan.scanRun.isRunning,
+ found: plan.items.isEmpty ? nil : AttributedString(localized: "^[\(plan.items.count) item](inflect: true)."),
+ couldNotLook: phase != .message ? nil : plan.isExcluded ? "This app is excluded" : "Nothing to Reset",
+ wasStopped: plan.scanRun.wasStopped
+ )
.scanState(phase, scan: plan.scanRun) {
if plan.isExcluded {
ContentUnavailableView(
diff --git a/PeelTests/SpokenTotalTests.swift b/PeelTests/SpokenTotalTests.swift
new file mode 100644
index 00000000..a19416a0
--- /dev/null
+++ b/PeelTests/SpokenTotalTests.swift
@@ -0,0 +1,14 @@
+import Foundation
+@testable import Peel
+import PeelCore
+import Testing
+
+@MainActor
+struct SpokenTotalTests {
+ @Test func saysWhatAScanFoundToMoveAsThePagesHeaderSaysIt() {
+ #expect(SizeTotal(known: 0, isComplete: true).spoken == nil)
+ #expect(SizeTotal(known: 0, isComplete: false).spoken.map { String($0.characters) } == "Unknown can be moved to the Trash")
+ let total = SizeTotal(known: 2_000_000, isComplete: true)
+ #expect(total.spoken.map { String($0.characters) } == "\(total.text) can be moved to the Trash")
+ }
+}