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.

File Search, iCloud Drive and Duplicates tell VoiceOver when a scan ends

Țugui Dragoș8263ed20eeed
diff --git a/Peel/Views/Cloud/CloudView.swift b/Peel/Views/Cloud/CloudView.swift
index fecbb286..ccf9b100 100644
--- a/Peel/Views/Cloud/CloudView.swift
+++ b/Peel/Views/Cloud/CloudView.swift
@@ -116,6 +116,12 @@ struct CloudView: View {
}
}
.fadesInColumn(whenRowsChange: cloud.files?.map(\.id))
+ .announcesScan(
+ cloud.isScanning,
+ found: cloud.summary,
+ couldNotLook: cloud.couldNotRead ? "iCloud Drive Couldn’t Be Read" : nil,
+ wasStopped: cloud.scanRun.wasStopped
+ )
.navigationTitle(Text(Tool.cloud.title))
.toolbar {
ToolbarItem {
diff --git a/Peel/Views/Duplicates/DuplicateList.swift b/Peel/Views/Duplicates/DuplicateList.swift
index 6d8f1034..b8dd1e69 100644
--- a/Peel/Views/Duplicates/DuplicateList.swift
+++ b/Peel/Views/Duplicates/DuplicateList.swift
@@ -108,6 +108,13 @@ struct DuplicateList: View {
Text("The list of duplicates and your selection are cleared. No files are moved.")
}
.fadesInColumn(whenRowsChange: duplicates.scan.map { $0.groups.map(\.id) + $0.folderGroups.map(\.id) })
+ // A scan ends without a result only when it was stopped.
+ .announcesScan(
+ duplicates.isScanning,
+ found: duplicates.summary,
+ couldNotLook: duplicates.scan?.readNothing == true ? "Not Everything Could Be Read" : nil,
+ wasStopped: duplicates.scan == nil
+ )
.navigationTitle(Text(Tool.duplicates.title))
}
diff --git a/Peel/Views/FileSearch/FileSearchList.swift b/Peel/Views/FileSearch/FileSearchList.swift
index 289906ba..6339633f 100644
--- a/Peel/Views/FileSearch/FileSearchList.swift
+++ b/Peel/Views/FileSearch/FileSearchList.swift
@@ -81,6 +81,13 @@ struct FileSearchList: View {
}
}
.fadesInColumn(whenRowsChange: search.results?.files.map(\.id))
+ // Clearing the words stops the search too.
+ .announcesScan(
+ search.isSearching,
+ found: search.summary,
+ couldNotLook: search.results?.didRun == false ? "Spotlight Didn’t Answer" : nil,
+ wasStopped: search.scanRun.wasStopped || !search.criteria.isSearchable
+ )
// The name is typed in the search field at the top of the column, where other pages filter their lists.
// Here the field is part of the search, so it is always shown.
.columnSearch(text: $search.criteria.name, prompt: "Search Files", when: true)
diff --git a/Peel/Views/ToolSummaries.swift b/Peel/Views/ToolSummaries.swift
index 2d82aac2..6fea48ca 100644
--- a/Peel/Views/ToolSummaries.swift
+++ b/Peel/Views/ToolSummaries.swift
@@ -2,8 +2,8 @@ import Accessibility
import PeelCore
import SwiftUI
-// The summary each tool's detail pane shows before anything is chosen, which VoiceOver also reads when a scan
-// ends: what the tool found, in numbers.
+// What each tool found, in numbers: the summary its detail pane shows before anything is chosen, and what
+// VoiceOver reads when a scan ends.
//
// Each sentence is one localized string with its numbers inside, so a translation can put the parts in any
// order, as Japanese or Turkish need. The sentences avoid verbs that would have to agree with a number, and the
@@ -102,6 +102,14 @@ extension FileSearchLibrary {
}
}
+extension DuplicateLibrary {
+ var summary: AttributedString? { Tool.duplicates.summary(of: looked) }
+}
+
+extension CloudLibrary {
+ var summary: AttributedString? { Tool.cloud.summary(of: looked) }
+}
+
extension PackageLibrary {
var summary: AttributedString? {
guard let receipts, !receipts.isEmpty else { return nil }
@@ -143,11 +151,19 @@ extension RemovalHistoryStore {
extension View {
/// Tells VoiceOver what a scan found when it ends, since a scan can take minutes and the list fills in
- /// silently. A stopped scan is announced as stopped.
- func announcesScan(_ isScanning: Bool, found summary: AttributedString?, wasStopped: Bool = false) -> some View {
+ /// silently. A stopped scan is announced as stopped. `couldNotLook` is the title of the page's message for a
+ /// scan that could not look, which is read in place of "Nothing found." when nothing was found.
+ func announcesScan(
+ _ isScanning: Bool,
+ found summary: AttributedString?,
+ couldNotLook: LocalizedStringResource? = nil,
+ wasStopped: Bool = false
+ ) -> some View {
onChange(of: isScanning) { wasScanning, scanning in
guard wasScanning, !scanning else { return }
- let words = wasStopped ? AttributedString(localized: "Scan stopped.") : summary ?? AttributedString(localized: "Nothing found.")
+ let nothing = couldNotLook.map { AttributedString(localized: $0) }
+ ?? AttributedString(localized: "Nothing found.")
+ let words = wasStopped ? AttributedString(localized: "Scan stopped.") : summary ?? nothing
AccessibilityNotification.Announcement(words).post()
}
}