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 File Search's row on macOS 26 exactly as it was

Țugui Dragoș62b669b3f981
diff --git a/Peel/Views/FileSearch/FileSearchList.swift b/Peel/Views/FileSearch/FileSearchList.swift
index 8b58974b..6e6f65d0 100644
--- a/Peel/Views/FileSearch/FileSearchList.swift
+++ b/Peel/Views/FileSearch/FileSearchList.swift
@@ -44,19 +44,35 @@ struct FileSearchList: View {
if let results = search.results, !results.files.isEmpty {
Section {
ForEach(results.files) { file in
- RemovalRow(
- url: file.url,
- icon: .file(file.url),
- detail: modified(file).note,
- date: modified(file).date,
- warning: warning(for: file),
- size: file.size,
- isLeftAlone: file.requiresPrivileges,
- isFirst: file.id == results.files.first?.id,
- isChoosable: true,
- selection: search, isSelected: search.isSelected(file.url)
- )
- .tag(file.url)
+ // On macOS 27 the day the file was modified stands in the column other lists give the kind.
+ if #available(macOS 27, *) {
+ RemovalRow(
+ url: file.url,
+ icon: .file(file.url),
+ detail: nil,
+ kind: "\(file.modificationDate, format: .dateTime.day().month(.abbreviated).year())",
+ warning: warning(for: file),
+ size: file.size,
+ isLeftAlone: file.requiresPrivileges,
+ isFirst: file.id == results.files.first?.id,
+ isChoosable: true,
+ selection: search, isSelected: search.isSelected(file.url)
+ )
+ .tag(file.url)
+ } else {
+ RemovalRow(
+ url: file.url,
+ icon: .file(file.url),
+ detail: "Modified \(file.modificationDate, format: .relative(presentation: .named))",
+ warning: warning(for: file),
+ size: file.size,
+ isLeftAlone: file.requiresPrivileges,
+ isFirst: file.id == results.files.first?.id,
+ isChoosable: true,
+ selection: search, isSelected: search.isSelected(file.url)
+ )
+ .tag(file.url)
+ }
}
.listRowSeparator(.hidden)
} header: {
@@ -192,13 +208,6 @@ 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 18c3993b..3dba1120 100644
--- a/Peel/Views/RemovalRow.swift
+++ b/Peel/Views/RemovalRow.swift
@@ -11,12 +11,9 @@ struct RemovalRow: View {
var name: String?
let icon: Icon
let detail: LocalizedStringResource?
- /// 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.
+ /// The kind of item, shown in a column of its own, or on macOS 27 the day a File Search file was modified.
+ /// 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?
@@ -44,8 +41,6 @@ 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.
@@ -78,7 +73,7 @@ struct RemovalRow: View {
}
}
.tableRow(isFirst: isFirst)
- .onGeometryChange(for: Bool.self) { [limit = Self.compactBelow(hasKind: kind != nil || date != nil)] proxy in
+ .onGeometryChange(for: Bool.self) { [limit = Self.compactBelow(hasKind: kind != nil)] proxy in
proxy.size.width < limit
} action: { isCompact = $0 }
.contextMenu {
@@ -121,8 +116,7 @@ struct RemovalRow: View {
private var spokenItem: String {
let badge = badgeKind.map { String(localized: $0.title) }
let size = isMeasured ? size.byteCount : String(localized: "Unknown")
- let column = kind.map { String(localized: $0) } ?? date.map { $0.formatted(Self.dateFormat) }
- return [name ?? url.abbreviatedPath, badge, column, size]
+ return [name ?? url.abbreviatedPath, badge, kind.map { String(localized: $0) }, size]
.compactMap(\.self)
.joined(separator: ", ")
}
@@ -141,11 +135,6 @@ 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
@@ -166,12 +155,6 @@ 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)