Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
Draw the note of an iCloud Drive download beside its row
Țugui Dragoș2ffb267a7137
diff --git a/Peel/Views/Cloud/CloudFolderRow.swift b/Peel/Views/Cloud/CloudFolderRow.swiftindex 8ebb9e60..b3d755ff 100644--- a/Peel/Views/Cloud/CloudFolderRow.swift+++ b/Peel/Views/Cloud/CloudFolderRow.swift@@ -6,6 +6,8 @@ struct CloudFolderRow: View {let folder: CloudFolderlet rows: SelectableRows<URL>let isOpen: Bool+ /// True while the files' rows have a note column, whose place the folder's row keeps, so the sizes line up.+ var hasNoteColumn = falselet isFirst: Boollet selection: any RowSelectionlet toggleOpen: () -> Void@@ -58,6 +60,7 @@ struct CloudFolderRow: View {.foregroundStyle(.secondary).frame(width: RowColumns.size, alignment: .trailing)}+ .padding(.trailing, hasNoteColumn ? RemovalRow.controlWidth + 6 : 0).contentShape(.rect)}.buttonStyle(RowButtonStyle())diff --git a/Peel/Views/Cloud/CloudView.swift b/Peel/Views/Cloud/CloudView.swiftindex 1c0e56cd..de30d9f6 100644--- a/Peel/Views/Cloud/CloudView.swift+++ b/Peel/Views/Cloud/CloudView.swift@@ -59,6 +59,7 @@ struct CloudView: View {}if !listed.isEmpty {+ let hasNoteColumn = Self.hasNoteColumn(listed)Section {ForEach(Array(folders.enumerated()), id: \.element.id) { index, folder inlet open = isOpen(folder)@@ -66,6 +67,7 @@ struct CloudView: View {folder: folder,rows: selectableRows(folder.files),isOpen: open,+ hasNoteColumn: hasNoteColumn,isFirst: index == 0,selection: cloud,toggleOpen: { toggle(folder) }@@ -76,11 +78,9 @@ struct CloudView: View {url: file.url,name: file.name,icon: .file(file.url),- detail: file.isDesktopPicture- ? "Not selected: it is the wallpaper, which macOS keeps open while it is shown, so its download can’t be removed now."- : nil,+ detail: file.note,size: file.size,- hasNoteColumn: false,+ hasNoteColumn: hasNoteColumn,selection: cloud, isSelected: cloud.isSelected(file.url)).padding(.leading, CloudFolderRow.indent)@@ -248,6 +248,11 @@ struct CloudView: View {}}+ /// Whether the note column is on: while a listed download has a note, so the note is drawn beside it.+ static func hasNoteColumn(_ files: [CloudFile]) -> Bool {+ files.contains { $0.note != nil }+ }+private func selectableRows(_ files: [CloudFile]) -> SelectableRows<URL> {SelectableRows(rows: files.map(\.url),@@ -314,3 +319,12 @@ private struct LeftAlone {return lines.joined(separator: "\n\n")}}++extension CloudFile {+ /// Why Peel doesn't recommend removing this download, said beside its row, or nil.+ var note: LocalizedStringResource? {+ isDesktopPicture+ ? "Not selected: it is the wallpaper, which macOS keeps open while it is shown, so its download can’t be removed now."+ : nil+ }+}diff --git a/PeelTests/CloudNotesTests.swift b/PeelTests/CloudNotesTests.swiftnew file mode 100644index 00000000..e7955da5--- /dev/null+++ b/PeelTests/CloudNotesTests.swift@@ -0,0 +1,23 @@+import Foundation+@testable import Peel+@testable import PeelCore+import Testing++struct CloudNotesTests {+ private static func download(_ name: String) -> CloudFile {+ CloudFile(+ url: URL(filePath: "/org.example/\(name)"), name: name, container: "iCloud Drive", size: 2_000_000,+ modified: nil+ )+ }++ /// The note column is on while a listed download has a note, so the note is drawn beside its row.+ @Test func showsTheNoteColumnWhileARowHasANote() {+ var picture = Self.download("Beach.heic")+ picture.isDesktopPicture = true++ #expect(!CloudView.hasNoteColumn([Self.download("Notes.pdf")]))+ #expect(CloudView.hasNoteColumn([Self.download("Notes.pdf"), picture]))+ #expect(picture.note != nil)+ }+}