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.

A click on a File Search row chooses the file instead of selecting it

Țugui Dragoșd048606c6ba1
diff --git a/Peel/Views/FileSearch/FileSearchList.swift b/Peel/Views/FileSearch/FileSearchList.swift
index 4901d74b..ce54651c 100644
--- a/Peel/Views/FileSearch/FileSearchList.swift
+++ b/Peel/Views/FileSearch/FileSearchList.swift
@@ -36,6 +36,7 @@ struct FileSearchList: View {
size: file.size,
isLocked: file.requiresPrivileges,
isFirst: file.id == results.files.first?.id,
+ isChoosable: true,
selection: search, isSelected: search.isSelected(file.url)
)
.tag(file.url)
diff --git a/Peel/Views/RemovalRow.swift b/Peel/Views/RemovalRow.swift
index afe442f7..f8b95303 100644
--- a/Peel/Views/RemovalRow.swift
+++ b/Peel/Views/RemovalRow.swift
@@ -28,6 +28,9 @@ struct RemovalRow: View {
/// False when no row of the table has a note. The note column is then left out, so the sizes end at the
/// same edge as the page's totals and Select All.
var hasNoteColumn = true
+ /// True in a list whose rows are chosen to show them in the detail column. A click on such a row chooses it,
+ /// and only its checkbox selects the item.
+ var isChoosable = false
/// The object the checkbox writes to. A `Binding` here would rebuild every row in the list: see `RowSelection`.
let selection: any RowSelection
let isSelected: Bool
@@ -72,16 +75,25 @@ struct RemovalRow: View {
// The label reads every column, so the hint adds only the warning from the note.
hint: warning.map { String(Self.commandsMarked($0).characters) }
)
- item
- .contentShape(.rect)
- // A click on the item selects it, as a click on a checkbox's title does.
- .onTapGesture { selection.setSelected(!isSelected, for: url) }
+ clickableItem
.checkboxTitle()
.accessibilityHidden(true)
}
.disabled(isLocked || isExcluded || isLeftAlone)
}
+ @ViewBuilder
+ private var clickableItem: some View {
+ if isChoosable {
+ item
+ } else {
+ // A click on the item selects it, as a click on a checkbox's title does.
+ item
+ .contentShape(.rect)
+ .onTapGesture { selection.setSelected(!isSelected, for: url) }
+ }
+ }
+
/// The item as the checkbox's title reads it: its path, its badge, its kind and its size.
private var spokenItem: String {
let badge = badgeKind.map { String(localized: $0.title) }