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 a list's place and its search field's focus on macOS 27

Țugui Dragoș7af769d9e1bc
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 68f0fb5b..3fdc63ed 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -455,6 +455,7 @@ its changes the way [Keep a Changelog](https://keepachangelog.com/) suggests.
#### Applications
+- On macOS 27, the list keeps its place when the first update arrives or the last one leaves.
- A system extension macOS is updating is named once on its app's page and in `peel uninstall`.
- Folders of apps are read each on a thread of its own within a time limit, so one that doesn't answer is named and
no longer holds the whole list.
@@ -741,6 +742,8 @@ its changes the way [Keep a Changelog](https://keepachangelog.com/) suggests.
#### Every page
+- On macOS 27, a search field keeps the keyboard when the rows it filters come and go, so the next letter no longer
+ chooses a tool in the sidebar.
- A program another account has open, a build tool's daemon, and a script a running Node.js or Python process was
started with are named, with the step that frees them.
- A Dropbox folder outside File Provider counts as syncing, so nothing in it moves.
diff --git a/Peel/Views/AppList.swift b/Peel/Views/AppList.swift
index 7cc968f4..693e59b0 100644
--- a/Peel/Views/AppList.swift
+++ b/Peel/Views/AppList.swift
@@ -55,7 +55,7 @@ struct AppList: View {
}
}
.accessibilityLabel(Text(Tool.applications.title))
- .scrollBarBelowSectionHeaders(!visible.waiting.isEmpty)
+ .scrollBarBelowSectionHeaders(!library.apps.isEmpty)
.overlay {
if library.isLoading, library.apps.isEmpty {
ProgressView()
diff --git a/Peel/Views/BackgroundItems/BackgroundItemList.swift b/Peel/Views/BackgroundItems/BackgroundItemList.swift
index e317ec7d..786d3489 100644
--- a/Peel/Views/BackgroundItems/BackgroundItemList.swift
+++ b/Peel/Views/BackgroundItems/BackgroundItemList.swift
@@ -22,7 +22,7 @@ struct BackgroundItemList: View {
section(Text("Daemons"), items: filtered.filter { $0.kind == .daemon })
}
.accessibilityLabel(Text(Tool.backgroundItems.title))
- .scrollBarBelowSectionHeaders(!filtered.isEmpty)
+ .scrollBarBelowSectionHeaders(backgroundItems.items?.isEmpty == false)
.scanState(phase(filtered), isRescanning: isRescanning, scan: backgroundItems.scanRun) {
if backgroundItems.items?.isEmpty == true,
let note = backgroundItems.missingNote, let title = couldNotLook {
diff --git a/Peel/Views/Duplicates/DuplicateList.swift b/Peel/Views/Duplicates/DuplicateList.swift
index aacb1daa..3bfc04c5 100644
--- a/Peel/Views/Duplicates/DuplicateList.swift
+++ b/Peel/Views/Duplicates/DuplicateList.swift
@@ -50,7 +50,9 @@ struct DuplicateList: View {
}
}
.accessibilityLabel(Text(Tool.duplicates.title))
- .scrollBarBelowSectionHeaders(!folderGroups.isEmpty || !synced.isEmpty)
+ .scrollBarBelowSectionHeaders(
+ !scan.folderGroups.isEmpty || scan.groups.contains(where: \.everyCopySyncs)
+ )
.columnSearch(text: $searchText, prompt: "Search Duplicates", when: !scan.groups.isEmpty || !scan.folderGroups.isEmpty)
.overlay {
if !(scan.groups.isEmpty && scan.folderGroups.isEmpty), groups.isEmpty, folderGroups.isEmpty {
diff --git a/Peel/Views/FileSearch/FileSearchList.swift b/Peel/Views/FileSearch/FileSearchList.swift
index 50e88b2b..1686d747 100644
--- a/Peel/Views/FileSearch/FileSearchList.swift
+++ b/Peel/Views/FileSearch/FileSearchList.swift
@@ -7,6 +7,7 @@ struct FileSearchList: View {
@Environment(ExclusionsStore.self) private var exclusions
@State private var isShowingFilters = false
@State private var isRescanning = false
+ @ScaledMetric(relativeTo: .body) private var rowHeight: CGFloat = 48
var body: some View {
@Bindable var search = search
@@ -104,7 +105,8 @@ struct FileSearchList: View {
}
.accessibilityLabel(Text(Tool.fileSearch.title))
.onKeyPress(.space) { search.toggleChosen() ? .handled : .ignored }
- .scrollBarBelowSectionHeaders(search.results?.files.isEmpty == false)
+ .scrollBarBelowSectionHeaders()
+ .startsRows(at: rowHeight)
.scanState(phase, isRescanning: search.isSearching, fadesInResults: false, scan: search.scanRun) {
if search.results == nil {
ContentUnavailableView(
@@ -286,3 +288,17 @@ private struct LeftOutLines: View {
}
}
}
+
+extension View {
+ /// Starts a list's rows at `height`. On macOS 27 a list filled all at once from empty, led by a section header,
+ /// leaves its rows at the height it starts them at. Building the list again would measure them, but it takes the
+ /// focus from the search field above it, so a list that fills as someone types starts them at their own height.
+ @ViewBuilder
+ fileprivate func startsRows(at height: CGFloat) -> some View {
+ if #available(macOS 27, *) {
+ environment(\.defaultMinListRowHeight, height)
+ } else {
+ self
+ }
+ }
+}
diff --git a/Peel/Views/History/HistoryList.swift b/Peel/Views/History/HistoryList.swift
index 83b204f5..3e421ecd 100644
--- a/Peel/Views/History/HistoryList.swift
+++ b/Peel/Views/History/HistoryList.swift
@@ -58,7 +58,7 @@ struct HistoryList: View {
}
}
.accessibilityLabel(Text(Tool.history.title))
- .scrollBarBelowSectionHeaders(!listed.isEmpty && !refused.isEmpty)
+ .scrollBarBelowSectionHeaders(!history.batches.isEmpty && !history.refusalBatches.isEmpty)
.columnSearch(text: $searchText, prompt: "Search History", when: !history.batches.isEmpty || !history.refusalBatches.isEmpty)
.edgeBar(.top) {
VStack(spacing: 8) {
diff --git a/Peel/Views/Intel/IntelList.swift b/Peel/Views/Intel/IntelList.swift
index b40c2dc9..3c8b098f 100644
--- a/Peel/Views/Intel/IntelList.swift
+++ b/Peel/Views/Intel/IntelList.swift
@@ -49,7 +49,7 @@ struct IntelList: View {
}
}
.accessibilityLabel(Text(Tool.intel.title))
- .scrollBarBelowSectionHeaders(!byKind.isEmpty)
+ .scrollBarBelowSectionHeaders(!intel.findings.isEmpty)
.columnSearch(text: $searchText, prompt: "Search Intel Software", when: !intel.findings.isEmpty)
.scanState(phase(matching), isRescanning: isRescanning, scan: intel.scanRun) {
if !searchText.isEmpty, matching.isEmpty {
diff --git a/Peel/Views/Plugins/PluginList.swift b/Peel/Views/Plugins/PluginList.swift
index 50096ec0..8e1b9b51 100644
--- a/Peel/Views/Plugins/PluginList.swift
+++ b/Peel/Views/Plugins/PluginList.swift
@@ -58,7 +58,7 @@ struct PluginList: View {
}
}
.accessibilityLabel(Text(Tool.plugins.title))
- .scrollBarBelowSectionHeaders(!byCategory.isEmpty)
+ .scrollBarBelowSectionHeaders(plugins.plugins?.isEmpty == false)
.scanState(phase(filtered), isRescanning: isRescanning, scan: plugins.scanRun) {
if plugins.plugins?.isEmpty == true, !plugins.unreadable.isEmpty {
ContentUnavailableView {
diff --git a/Peel/Views/SectionHeaderScrollBar.swift b/Peel/Views/SectionHeaderScrollBar.swift
index 1f3dd4e3..ad29ef0c 100644
--- a/Peel/Views/SectionHeaderScrollBar.swift
+++ b/Peel/Views/SectionHeaderScrollBar.swift
@@ -2,14 +2,15 @@ import SwiftUI
extension View {
/// Starts a list's scroll bar below the band of a section header held at the top of the list, as Finder's starts
- /// below its column headings. On macOS 27 it otherwise starts level with that band. `hasHeaders` is whether the
- /// list shows any section header at the moment. macOS 27 takes the margin only when the list is built, so the
- /// list is built again when its headers come or go.
+ /// below its column headings. On macOS 27 it otherwise starts level with that band. `isOn` says whether the list
+ /// has that band. macOS 27 takes the margin only when the list is built, so the list is built again when `isOn`
+ /// changes, which sends it back to its top and takes the focus from the search field above it. So `isOn` follows
+ /// what the page found, never what a search leaves of it.
@ViewBuilder
- func scrollBarBelowSectionHeaders(_ hasHeaders: Bool = true) -> some View {
+ func scrollBarBelowSectionHeaders(_ isOn: Bool = true) -> some View {
if #available(macOS 27, *) {
- contentMargins(.top, hasHeaders ? sectionHeaderBand : 0, for: .scrollIndicators)
- .id(hasHeaders)
+ contentMargins(.top, isOn ? sectionHeaderBand : 0, for: .scrollIndicators)
+ .id(isOn)
} else {
self
}