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.

History's records use AppKit's checkbox beside the record

Țugui Dragoș0e6e8333436b
diff --git a/Peel/Views/History/HistoryDetailView.swift b/Peel/Views/History/HistoryDetailView.swift
index bcb8150e..d994366d 100644
--- a/Peel/Views/History/HistoryDetailView.swift
+++ b/Peel/Views/History/HistoryDetailView.swift
@@ -255,29 +255,21 @@ private struct HistoryRecordRow: View {
var isFirst = false
var body: some View {
- HStack(spacing: 0) {
- Toggle(isOn: Binding(get: { isSelected }, set: { history.setSelected($0, record) })) {
- HStack(alignment: .firstTextBaseline, spacing: 10) {
- Image(systemName: place.symbolName)
- .foregroundStyle(.secondary)
- .frame(width: 20)
- VStack(alignment: .leading, spacing: 2) {
- Text(record.originalURL.abbreviatedPath)
- .lineLimit(1)
- .truncationMode(.middle)
- Text(place.title)
- .font(.caption)
- .foregroundStyle(.secondary)
- }
- Spacer(minLength: 12)
- Text(record.size.byteCount)
- .monospacedDigit()
- .foregroundStyle(.secondary)
- }
- }
- .toggleStyle(.checkbox)
- .disabled(place != .inTrash)
+ HStack(alignment: .checkboxTitleLine, spacing: 5) {
+ NativeCheckbox(
+ isOn: Binding(get: { isSelected }, set: { history.setSelected($0, record) }),
+ label: [record.originalURL.abbreviatedPath, String(localized: place.title), record.size.byteCount]
+ .joined(separator: ", ")
+ )
+ // A click on the record selects it, as a click on a checkbox's title does. VoiceOver hears the record
+ // as the checkbox's name.
+ item
+ .contentShape(.rect)
+ .onTapGesture { history.setSelected(!isSelected, record) }
+ .checkboxTitle()
+ .accessibilityHidden(true)
}
+ .disabled(place != .inTrash)
.tableRow(isFirst: isFirst)
.contextMenu {
if place == .inTrash {
@@ -287,4 +279,25 @@ private struct HistoryRecordRow: View {
}
}
}
+
+ private var item: some View {
+ HStack(alignment: .firstTextBaseline, spacing: 10) {
+ Image(systemName: place.symbolName)
+ .foregroundStyle(.secondary)
+ .frame(width: 20)
+ VStack(alignment: .leading, spacing: 2) {
+ Text(record.originalURL.abbreviatedPath)
+ .lineLimit(1)
+ .truncationMode(.middle)
+ .checkboxTitleLine()
+ Text(place.title)
+ .font(.caption)
+ .foregroundStyle(.secondary)
+ }
+ Spacer(minLength: 12)
+ Text(record.size.byteCount)
+ .monospacedDigit()
+ .foregroundStyle(.secondary)
+ }
+ }
}