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 the notes under Space's and iCloud Drive's rows whole

Țugui Dragoș888da2c2be99
diff --git a/Peel/Views/Cloud/CloudView.swift b/Peel/Views/Cloud/CloudView.swift
index d4b463b6..5cb7c604 100644
--- a/Peel/Views/Cloud/CloudView.swift
+++ b/Peel/Views/Cloud/CloudView.swift
@@ -93,21 +93,8 @@ struct CloudView: View {
}
}
.listRowSeparator(.hidden)
- } header: {
- SectionHeaderLine {
- heading(
- "On This Mac and in iCloud",
- "Once their downloads are removed, Finder still lists these files, with a cloud beside each name. Deleting a file is different: that removes it from iCloud and from your other devices, and Peel never does it here."
- )
- } actions: {
- SelectMenu(
- list: selectableRows(listed), place: Text(Tool.cloud.title), selection: cloud,
- removesDownloads: true
- )
- }
- } footer: {
if cloud.cutShort != nil || cloud.sharedDownloads > 0 || !cloud.unreadableFolders.isEmpty {
- VStack(alignment: .leading, spacing: 6) {
+ ListNotes {
switch cloud.cutShort {
case .listIsFull:
Text("Peel lists the biggest downloads, up to \(CloudStorage.maximumFiles.formatted()). The next ones show once you remove some of these.")
@@ -119,8 +106,18 @@ struct CloudView: View {
unreadableFoldersNote
sharedDownloadsNote
}
- .font(.callout)
- .foregroundStyle(.secondary)
+ }
+ } header: {
+ SectionHeaderLine {
+ heading(
+ "On This Mac and in iCloud",
+ "Once their downloads are removed, Finder still lists these files, with a cloud beside each name. Deleting a file is different: that removes it from iCloud and from your other devices, and Peel never does it here."
+ )
+ } actions: {
+ SelectMenu(
+ list: selectableRows(listed), place: Text(Tool.cloud.title), selection: cloud,
+ removesDownloads: true
+ )
}
}
}
diff --git a/Peel/Views/ListNotes.swift b/Peel/Views/ListNotes.swift
new file mode 100644
index 00000000..53c1ad9c
--- /dev/null
+++ b/Peel/Views/ListNotes.swift
@@ -0,0 +1,16 @@
+import SwiftUI
+
+/// Notes under the rows of a list's section, in a row of their own: macOS shows a `List` section's footer on one line
+/// and cuts off the rest of a longer note.
+struct ListNotes<Notes: View>: View {
+ @ViewBuilder let notes: Notes
+
+ var body: some View {
+ VStack(alignment: .leading, spacing: 6) {
+ notes
+ }
+ .font(.callout)
+ .foregroundStyle(.secondary)
+ .listRowSeparator(.hidden)
+ }
+}
diff --git a/Peel/Views/Space/SpaceDetailView.swift b/Peel/Views/Space/SpaceDetailView.swift
index e832e62e..942eccf1 100644
--- a/Peel/Views/Space/SpaceDetailView.swift
+++ b/Peel/Views/Space/SpaceDetailView.swift
@@ -170,19 +170,8 @@ struct SpaceDetailView: View {
)
}
.listRowSeparator(.hidden)
- } header: {
- SectionHeaderLine {
- heading("Inside", "What is selected goes to the Trash, and History can put it back. The folders it sits in stay, since macOS expects to find them.")
- } actions: {
- SelectMenu(
- list: plan.selectableRows(canUseHelper: helper.canAct),
- place: Text(item.words.title),
- selection: space
- )
- }
- } footer: {
if !plan.appsToQuit.isEmpty || !plan.refused.isEmpty {
- VStack(alignment: .leading, spacing: 6) {
+ ListNotes {
if !plan.appsToQuit.isEmpty {
Text("Peel doesn’t include folders an open app is still writing to: \(plan.appsToQuit.formatted(.list(type: .and))). Quit an app to include its folders. Peel can only tell a folder is an open app’s when it carries the app’s own name or identifier, not its maker’s.")
}
@@ -194,8 +183,16 @@ struct SpaceDetailView: View {
Text("Peel leaves ^[\(plan.refused.count - keepingWork) folder](inflect: true) here alone because it protects what is there, such as what iCloud keeps to stay in sync, a wallet, an app’s documents, or a library.")
}
}
- .font(.callout)
- .foregroundStyle(.secondary)
+ }
+ } header: {
+ SectionHeaderLine {
+ heading("Inside", "What is selected goes to the Trash, and History can put it back. The folders it sits in stay, since macOS expects to find them.")
+ } actions: {
+ SelectMenu(
+ list: plan.selectableRows(canUseHelper: helper.canAct),
+ place: Text(item.words.title),
+ selection: space
+ )
}
}
}
diff --git a/PeelTests/ListNotesTests.swift b/PeelTests/ListNotesTests.swift
new file mode 100644
index 00000000..97073242
--- /dev/null
+++ b/PeelTests/ListNotesTests.swift
@@ -0,0 +1,46 @@
+import AppKit
+@testable import Peel
+import SwiftUI
+import Testing
+
+@MainActor
+struct ListNotesTests {
+ private final class Heights {
+ var row: CGFloat = 0
+ var note: CGFloat = 0
+ }
+
+ private struct Page: View {
+ let heights: Heights
+
+ var body: some View {
+ List {
+ Section {
+ Text(verbatim: "Row")
+ .onGeometryChange(for: CGFloat.self) { $0.size.height } action: { heights.row = $0 }
+ ListNotes {
+ Text(verbatim: String(repeating: "Peel leaves this folder where it is for now. ", count: 8))
+ .onGeometryChange(for: CGFloat.self) { $0.size.height } action: { heights.note = $0 }
+ }
+ }
+ }
+ }
+ }
+
+ @Test func aNoteUnderAListsRowsShowsEveryLine() async {
+ let heights = Heights()
+ let window = NSWindow(
+ contentRect: NSRect(x: 0, y: 0, width: 320, height: 600), styleMask: [.titled],
+ backing: .buffered, defer: true
+ )
+ window.contentView = NSHostingView(rootView: Page(heights: heights))
+
+ for _ in 0..<200 where heights.note == 0 || heights.row == 0 {
+ window.layoutIfNeeded()
+ try? await Task.sleep(for: .milliseconds(5))
+ }
+
+ #expect(heights.row > 0)
+ #expect(heights.note > 3 * heights.row)
+ }
+}