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.

Keep macOS's own words for decorative symbols from VoiceOver

Țugui Dragoșdc3fc522b567
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/DecorativeSymbolTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/DecorativeSymbolTests.swift
new file mode 100644
index 00000000..a5588a33
--- /dev/null
+++ b/Packages/PeelCore/Tests/PeelCoreTests/DecorativeSymbolTests.swift
@@ -0,0 +1,56 @@
+import Foundation
+import Testing
+
+struct DecorativeSymbolTests {
+ /// macOS describes these by an action ("move", "copy", "build", "forward", "new folder") or by their own name, so
+ /// VoiceOver says that word for an image of one that Peel doesn't label.
+ static let misleading: Set = [
+ "folder", "folder.fill", "questionmark.app", "doc.on.doc", "hammer", "chevron.right", "folder.badge.plus",
+ ]
+ static let ancestorCovers = [".hidden()", ".accessibilityElement(children: .ignore)", ".accessibilityLabel("]
+
+ @Test func aSymbolMacOSNamesByAnActionIsNeverLeftForVoiceOver() throws {
+ let root = LineLengthTests.repository.path(percentEncoded: false)
+ var found: [String] = []
+ for file in try LineLengthTests.swiftFiles()
+ where file.path(percentEncoded: false).dropFirst(root.count).hasPrefix("Peel/") {
+ let lines = try String(contentsOf: file, encoding: .utf8).components(separatedBy: "\n")
+ for (index, line) in lines.enumerated() {
+ guard let name = Self.symbol(in: line), Self.misleading.contains(name) else { continue }
+ let indent = Self.indent(of: line)
+ let before = lines[max(0, index - 3)...index].joined(separator: "\n")
+ if before.contains("icon:") || before.contains("label:") || before.contains("Label {") { continue }
+ let following = lines[(index + 1)..<min(lines.count, index + 30)]
+ let own = following.prefix { line in
+ let code = line.trimmingCharacters(in: .whitespaces)
+ return Self.indent(of: line) > indent && (code.hasPrefix(".") || code.hasPrefix("//"))
+ }
+ if own.contains(where: { $0.contains(".accessibilityHidden(true)") || $0.contains(".accessibilityLabel(") }) {
+ continue
+ }
+ let ancestors = following.filter { Self.indent(of: $0) < indent }
+ if ancestors.contains(where: { line in Self.ancestorCovers.contains { line.contains($0) } }) {
+ continue
+ }
+ found.append("\(file.path(percentEncoded: false).dropFirst(root.count)):\(index + 1) \(name)")
+ }
+ }
+ #expect(found.isEmpty, "VoiceOver would say macOS's word for these symbols: \(found)")
+ }
+
+ @Test func aNoticesOwnSymbolIsDecoration() throws {
+ let text = try String(
+ contentsOf: LineLengthTests.repository.appending(path: "Peel/Views/Notice.swift"), encoding: .utf8
+ )
+ #expect(text.contains(".accessibilityHidden(systemImage != nil)"))
+ }
+
+ private static func symbol(in line: String) -> String? {
+ guard let start = line.range(of: #"Image(systemName: ""#) else { return nil }
+ return line[start.upperBound...].split(separator: "\"", maxSplits: 1).first.map(String.init)
+ }
+
+ private static func indent(of line: String) -> Int {
+ line.prefix { $0 == " " }.count
+ }
+}
diff --git a/Peel/Views/Duplicates/DuplicateList.swift b/Peel/Views/Duplicates/DuplicateList.swift
index 7ae1d4d0..e9e6b5a1 100644
--- a/Peel/Views/Duplicates/DuplicateList.swift
+++ b/Peel/Views/Duplicates/DuplicateList.swift
@@ -243,6 +243,7 @@ private struct DuplicateFolderGroupRow: View {
.font(.system(size: 20))
.rowTint(Color.accentColor)
.frame(width: 28, height: 28)
+ .accessibilityHidden(true)
VStack(alignment: .leading, spacing: 2) {
Text(verbatim: group.folders[0].url.lastPathComponent)
.lineLimit(1)
diff --git a/Peel/Views/Notice.swift b/Peel/Views/Notice.swift
index 57678658..d8b9dc83 100644
--- a/Peel/Views/Notice.swift
+++ b/Peel/Views/Notice.swift
@@ -111,6 +111,8 @@ struct Notice<Actions: View>: View {
.font(.system(size: 16))
.foregroundStyle(tint)
.frame(width: 26)
+ // The kind's own symbol tells VoiceOver Info or Warning; one a page chooses only decorates.
+ .accessibilityHidden(systemImage != nil)
}
}
}
diff --git a/Peel/Views/Settings/ExclusionsSettingsView.swift b/Peel/Views/Settings/ExclusionsSettingsView.swift
index 0effc21b..689272a0 100644
--- a/Peel/Views/Settings/ExclusionsSettingsView.swift
+++ b/Peel/Views/Settings/ExclusionsSettingsView.swift
@@ -112,6 +112,7 @@ struct ExclusionsSettingsView: View {
} else {
Image(systemName: "questionmark.app")
.foregroundStyle(.secondary)
+ .accessibilityHidden(true)
}
Text(verbatim: identifier)
.font(.caption)
diff --git a/Peel/Views/Settings/SettingsView.swift b/Peel/Views/Settings/SettingsView.swift
index 9f09a1da..47980a61 100644
--- a/Peel/Views/Settings/SettingsView.swift
+++ b/Peel/Views/Settings/SettingsView.swift
@@ -582,6 +582,7 @@ extension GeneralSettingsView {
} else {
Image(systemName: "questionmark.app")
.foregroundStyle(.secondary)
+ .accessibilityHidden(true)
}
VStack(alignment: .leading, spacing: 1) {
Text(verbatim: item.name)
diff --git a/Peel/Views/Space/SpaceDetailView.swift b/Peel/Views/Space/SpaceDetailView.swift
index 2703c765..b65b2c7e 100644
--- a/Peel/Views/Space/SpaceDetailView.swift
+++ b/Peel/Views/Space/SpaceDetailView.swift
@@ -72,6 +72,7 @@ struct SpaceDetailView: View {
HStack(spacing: 8) {
Image(systemName: "folder")
.foregroundStyle(.secondary)
+ .accessibilityHidden(true)
Text(url.abbreviatedPath)
.lineLimit(1)
.truncationMode(.middle)