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.

Show when File Search's files were modified, on macOS 27

Țugui Dragoș7c08daf951e1
diff --git a/Peel/Views/FileSearch/FileSearchList.swift b/Peel/Views/FileSearch/FileSearchList.swift
index f3d8143c..8b58974b 100644
--- a/Peel/Views/FileSearch/FileSearchList.swift
+++ b/Peel/Views/FileSearch/FileSearchList.swift
@@ -47,7 +47,8 @@ struct FileSearchList: View {
RemovalRow(
url: file.url,
icon: .file(file.url),
- detail: "Modified \(file.modificationDate, format: .relative(presentation: .named))",
+ detail: modified(file).note,
+ date: modified(file).date,
warning: warning(for: file),
size: file.size,
isLeftAlone: file.requiresPrivileges,
@@ -191,6 +192,13 @@ struct FileSearchList: View {
}
}
+ /// When the file was modified, which a search can filter by: on macOS 27 in the row's own column, and on
+ /// macOS 26 in its note.
+ private func modified(_ file: FoundFile) -> (note: LocalizedStringResource?, date: Date?) {
+ if #available(macOS 27, *) { return (nil, file.modificationDate) }
+ return ("Modified \(file.modificationDate, format: .relative(presentation: .named))", nil)
+ }
+
private func warning(for file: FoundFile) -> String? {
let lines = [
file.requiresPrivileges
diff --git a/Peel/Views/RemovalRow.swift b/Peel/Views/RemovalRow.swift
index 57577193..18c3993b 100644
--- a/Peel/Views/RemovalRow.swift
+++ b/Peel/Views/RemovalRow.swift
@@ -14,6 +14,9 @@ struct RemovalRow: View {
/// The kind of item, shown in a column of its own. Tools with nothing to show there pass nil, and the
/// column is left out.
var kind: LocalizedStringResource?
+ /// A date shown in the kind's column, for a list whose rows have no kind, such as when File Search's files
+ /// were modified.
+ var date: Date?
var warning: String?
/// The newest write inside the item, which its note tells when the page knows it.
var lastWritten: Date?
@@ -41,6 +44,8 @@ struct RemovalRow: View {
let isSelected: Bool
static let controlWidth: CGFloat = 20
+ /// How `date` reads in its column: the day, the month's short name, and the year.
+ private static let dateFormat = Date.FormatStyle.dateTime.day().month(.abbreviated).year()
/// The least width a path keeps. With less, the kind and size move under the path, and so does the badge.
private static let pathFloor: CGFloat = 160
/// The width of a row's fixed parts: the checkbox, the icon, the note, and the gaps between them.
@@ -73,7 +78,7 @@ struct RemovalRow: View {
}
}
.tableRow(isFirst: isFirst)
- .onGeometryChange(for: Bool.self) { [limit = Self.compactBelow(hasKind: kind != nil)] proxy in
+ .onGeometryChange(for: Bool.self) { [limit = Self.compactBelow(hasKind: kind != nil || date != nil)] proxy in
proxy.size.width < limit
} action: { isCompact = $0 }
.contextMenu {
@@ -116,7 +121,8 @@ struct RemovalRow: View {
private var spokenItem: String {
let badge = badgeKind.map { String(localized: $0.title) }
let size = isMeasured ? size.byteCount : String(localized: "Unknown")
- return [name ?? url.abbreviatedPath, badge, kind.map { String(localized: $0) }, size]
+ let column = kind.map { String(localized: $0) } ?? date.map { $0.formatted(Self.dateFormat) }
+ return [name ?? url.abbreviatedPath, badge, column, size]
.compactMap(\.self)
.joined(separator: ", ")
}
@@ -135,6 +141,11 @@ struct RemovalRow: View {
.font(.caption)
.foregroundStyle(.secondary)
.lineLimit(1)
+ } else if let date {
+ Text(date, format: Self.dateFormat)
+ .font(.caption)
+ .foregroundStyle(.secondary)
+ .lineLimit(1)
}
Spacer(minLength: 8)
sizeText
@@ -155,6 +166,12 @@ struct RemovalRow: View {
.lineLimit(1)
.frame(width: RowColumns.kind, alignment: .leading)
.help(Text(kind))
+ } else if let date {
+ Text(date, format: Self.dateFormat)
+ .font(.caption)
+ .foregroundStyle(.secondary)
+ .lineLimit(1)
+ .frame(width: RowColumns.kind, alignment: .leading)
}
sizeText
.foregroundStyle(.secondary)