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.

Draw nothing behind the bars on macOS 27

Țugui Dragoș47e550f872c4
diff --git a/Peel/Navigation/TitleBarBackground.swift b/Peel/Navigation/TitleBarBackground.swift
index ec0d1b7d..5737e6e6 100644
--- a/Peel/Navigation/TitleBarBackground.swift
+++ b/Peel/Navigation/TitleBarBackground.swift
@@ -1,13 +1,13 @@
import SwiftUI
extension View {
- /// Keeps the title bar clear on macOS 27, as it is on macOS 26. There the window draws a background behind each
- /// column's section of the title bar even when nothing is under it; without it, what scrolls beneath the title
- /// bar is still blurred by the scroll edge effect.
+ /// Keeps the title bar clear on macOS 27: no background behind each column's section of it, and nothing drawn
+ /// over what scrolls beneath it.
@ViewBuilder
func clearTitleBar() -> some View {
if #available(macOS 27, *) {
toolbarBackgroundVisibility(.hidden, for: .windowToolbar)
+ .scrollEdgeEffectHidden(true, for: .top)
} else {
self
}
diff --git a/Peel/Navigation/ToolSidebar.swift b/Peel/Navigation/ToolSidebar.swift
index ba722855..f33bfdd7 100644
--- a/Peel/Navigation/ToolSidebar.swift
+++ b/Peel/Navigation/ToolSidebar.swift
@@ -75,7 +75,7 @@ struct ToolSidebar: View {
group(.storage, isExpanded: $isStorageExpanded)
group(.system, isExpanded: $isSystemExpanded)
}
- .safeAreaBar(edge: .top, spacing: 0) { mascot }
+ .edgeBar(.top, spacing: 0) { mascot }
.takesFocusWhenNothingHasIt()
.onReceive(
NotificationCenter.default.publisher(for: NSScroller.preferredScrollerStyleDidChangeNotification)
diff --git a/Peel/Views/AppDetailView.swift b/Peel/Views/AppDetailView.swift
index c388dcd9..22a88a29 100644
--- a/Peel/Views/AppDetailView.swift
+++ b/Peel/Views/AppDetailView.swift
@@ -191,7 +191,7 @@ struct AppDetailView: View {
}
}
.scanState(phase, fadesInResults: false, scan: plan.scanRun)
- .safeAreaBar(edge: .bottom) {
+ .edgeBar(.bottom) {
if plan.scan != nil {
let selected = plan.request.total
RemovalBar(
diff --git a/Peel/Views/Cloud/CloudView.swift b/Peel/Views/Cloud/CloudView.swift
index b8ef42e1..a5d03170 100644
--- a/Peel/Views/Cloud/CloudView.swift
+++ b/Peel/Views/Cloud/CloudView.swift
@@ -110,7 +110,7 @@ struct CloudView: View {
)
}
}
- .safeAreaBar(edge: .bottom) {
+ .edgeBar(.bottom) {
if cloud.files?.isEmpty == false {
RemovalBar(
selectedSize: cloud.selectedSize,
diff --git a/Peel/Views/ColumnSearchField.swift b/Peel/Views/ColumnSearchField.swift
index 94aec6a3..565bc284 100644
--- a/Peel/Views/ColumnSearchField.swift
+++ b/Peel/Views/ColumnSearchField.swift
@@ -80,7 +80,7 @@ extension View {
/// filtered ones, a query that matched nothing would hide the field and leave no way to clear it. While
/// `when` is false, the field is hidden but keeps its place.
func columnSearch(text: Binding<String>, prompt: LocalizedStringResource, when hasRows: Bool) -> some View {
- safeAreaBar(edge: .top) {
+ edgeBar(.top) {
ColumnSearchField(text: text, prompt: prompt, isAvailable: hasRows)
.padding(.horizontal, 12)
.padding(.bottom, 8)
diff --git a/Peel/Views/Developer/DeveloperDetailView.swift b/Peel/Views/Developer/DeveloperDetailView.swift
index 4ce4f581..b66805b9 100644
--- a/Peel/Views/Developer/DeveloperDetailView.swift
+++ b/Peel/Views/Developer/DeveloperDetailView.swift
@@ -39,7 +39,7 @@ struct DeveloperDetailView: View {
}
}
.dimmedWhileBusy(developer.isScanning)
- .safeAreaBar(edge: .bottom) {
+ .edgeBar(.bottom) {
RemovalBar(
page: environment.page,
isScanning: developer.isScanning,
diff --git a/Peel/Views/Duplicates/DuplicateFolderGroupView.swift b/Peel/Views/Duplicates/DuplicateFolderGroupView.swift
index 53ffb5ba..f3f56b33 100644
--- a/Peel/Views/Duplicates/DuplicateFolderGroupView.swift
+++ b/Peel/Views/Duplicates/DuplicateFolderGroupView.swift
@@ -28,7 +28,7 @@ struct DuplicateFolderGroupView: View {
}
.disabled(duplicates.isRemoving)
}
- .safeAreaBar(edge: .bottom) {
+ .edgeBar(.bottom) {
DuplicateRemovalBar()
}
.fadesInColumn(whenRowsChange: group.folders.map(\.id))
diff --git a/Peel/Views/Duplicates/DuplicateGroupView.swift b/Peel/Views/Duplicates/DuplicateGroupView.swift
index 9446154f..1e0a4081 100644
--- a/Peel/Views/Duplicates/DuplicateGroupView.swift
+++ b/Peel/Views/Duplicates/DuplicateGroupView.swift
@@ -31,7 +31,7 @@ struct DuplicateGroupView: View {
}
.disabled(duplicates.isRemoving)
}
- .safeAreaBar(edge: .bottom) {
+ .edgeBar(.bottom) {
DuplicateRemovalBar()
}
.fadesInColumn(whenRowsChange: group.files.map(\.id))
diff --git a/Peel/Views/Duplicates/DuplicateStatusViews.swift b/Peel/Views/Duplicates/DuplicateStatusViews.swift
index 73cd56d1..5ace273d 100644
--- a/Peel/Views/Duplicates/DuplicateStatusViews.swift
+++ b/Peel/Views/Duplicates/DuplicateStatusViews.swift
@@ -95,7 +95,7 @@ struct DuplicateSummaryView: View {
// Takes the page's height, so the bar floats at its foot as on every page, not under these words.
.frame(maxHeight: .infinity)
}
- .safeAreaBar(edge: .bottom) {
+ .edgeBar(.bottom) {
DuplicateRemovalBar()
}
}
diff --git a/Peel/Views/EdgeBar.swift b/Peel/Views/EdgeBar.swift
new file mode 100644
index 00000000..f19abe2b
--- /dev/null
+++ b/Peel/Views/EdgeBar.swift
@@ -0,0 +1,15 @@
+import SwiftUI
+
+extension View {
+ /// A bar across the top or the foot of a scrolling page, such as a search field or a button with its note.
+ /// macOS 27 draws a background across the page behind a bar even when nothing is under it, so there the bar
+ /// takes room as an inset instead, with nothing drawn behind it.
+ @ViewBuilder
+ func edgeBar(_ edge: VerticalEdge, spacing: CGFloat? = nil, @ViewBuilder content: () -> some View) -> some View {
+ if #available(macOS 27, *) {
+ safeAreaInset(edge: edge, spacing: spacing ?? 0, content: content)
+ } else {
+ safeAreaBar(edge: edge, spacing: spacing, content: content)
+ }
+ }
+}
diff --git a/Peel/Views/FileSearch/FileSearchList.swift b/Peel/Views/FileSearch/FileSearchList.swift
index 4461bb22..44483a2b 100644
--- a/Peel/Views/FileSearch/FileSearchList.swift
+++ b/Peel/Views/FileSearch/FileSearchList.swift
@@ -74,7 +74,7 @@ struct FileSearchList: View {
ContentUnavailableView.search
}
}
- .safeAreaBar(edge: .bottom) {
+ .edgeBar(.bottom) {
if search.results?.files.isEmpty == false {
RemovalBar(page: Tool.fileSearch.page(), isScanning: search.isSearching)
}
diff --git a/Peel/Views/History/HistoryDetailView.swift b/Peel/Views/History/HistoryDetailView.swift
index eb5fba28..0172727b 100644
--- a/Peel/Views/History/HistoryDetailView.swift
+++ b/Peel/Views/History/HistoryDetailView.swift
@@ -41,7 +41,7 @@ struct HistoryDetailView: View {
records(in: standing)
}
}
- .safeAreaBar(edge: .bottom) {
+ .edgeBar(.bottom) {
let selectedCount = standing?.selectedCount(in: history.selectedIDs) ?? 0
RestoreBar(
count: selectedCount,
diff --git a/Peel/Views/History/HistoryList.swift b/Peel/Views/History/HistoryList.swift
index f04126dc..f5e5df0c 100644
--- a/Peel/Views/History/HistoryList.swift
+++ b/Peel/Views/History/HistoryList.swift
@@ -52,7 +52,7 @@ struct HistoryList: View {
}
}
.columnSearch(text: $searchText, prompt: "Search History", when: !history.batches.isEmpty || !history.refusalBatches.isEmpty)
- .safeAreaBar(edge: .top) {
+ .edgeBar(.top) {
VStack(spacing: 8) {
if let problem = history.shownProblem {
HistoryProblemNotice(problem: problem)
diff --git a/Peel/Views/Installers/InstallerDetailView.swift b/Peel/Views/Installers/InstallerDetailView.swift
index 3ebda1f1..b3672919 100644
--- a/Peel/Views/Installers/InstallerDetailView.swift
+++ b/Peel/Views/Installers/InstallerDetailView.swift
@@ -74,7 +74,7 @@ struct InstallerDetailView: View {
}
}
.dimmedWhileBusy(installers.isScanning)
- .safeAreaBar(edge: .bottom) {
+ .edgeBar(.bottom) {
if kind != .deviceBackup {
RemovalBar(
page: kind.page,
diff --git a/Peel/Views/MultipleAppsView.swift b/Peel/Views/MultipleAppsView.swift
index 04c0521d..7c9be612 100644
--- a/Peel/Views/MultipleAppsView.swift
+++ b/Peel/Views/MultipleAppsView.swift
@@ -108,7 +108,7 @@ struct MultipleAppsView: View {
.dimmedWhileBusy(plan.isRemoving)
.disabled(plan.isRemoving)
.scanState(phase, isRescanning: isRescanning, fadesInResults: false, scan: plan.scanRun)
- .safeAreaBar(edge: .bottom) {
+ .edgeBar(.bottom) {
if plan.bulk != nil {
let selected = plan.request.total
RemovalBar(
diff --git a/Peel/Views/Orphans/OrphanDetailView.swift b/Peel/Views/Orphans/OrphanDetailView.swift
index d96c8574..45636141 100644
--- a/Peel/Views/Orphans/OrphanDetailView.swift
+++ b/Peel/Views/Orphans/OrphanDetailView.swift
@@ -53,7 +53,7 @@ struct OrphanDetailView: View {
}
}
.dimmedWhileBusy(orphans.isScanning)
- .safeAreaBar(edge: .bottom) {
+ .edgeBar(.bottom) {
RemovalBar(page: group.page, isScanning: orphans.isScanning, scan: orphans.scanRun)
}
.fadesInColumn(whenRowsChange: group.items.map(\.id))
diff --git a/Peel/Views/Orphans/OrphanList.swift b/Peel/Views/Orphans/OrphanList.swift
index 04344718..69569a5d 100644
--- a/Peel/Views/Orphans/OrphanList.swift
+++ b/Peel/Views/Orphans/OrphanList.swift
@@ -68,7 +68,7 @@ struct OrphanList: View {
ContentUnavailableView.search(text: searchText)
}
}
- .safeAreaBar(edge: .bottom) {
+ .edgeBar(.bottom) {
Group {
if let cutShort = orphans.scan?.cutShortLocations, !cutShort.isEmpty {
Text("There are more folders in \(cutShort.map(\.url.abbreviatedPath).formatted(.list(type: .and))) than Peel looks inside, so an orphaned file may be in a folder Peel didn’t reach.")
diff --git a/Peel/Views/Packages/PackageDetailView.swift b/Peel/Views/Packages/PackageDetailView.swift
index a6eb8644..e803df29 100644
--- a/Peel/Views/Packages/PackageDetailView.swift
+++ b/Peel/Views/Packages/PackageDetailView.swift
@@ -71,7 +71,7 @@ struct PackageDetailView: View {
}
.disabled(packages.isWorking)
.dimmedWhileBusy(packages.isScanning)
- .safeAreaBar(edge: .bottom) {
+ .edgeBar(.bottom) {
if !receipt.items.isEmpty {
RemovalBar(
selectedSize: SizeTotal(selectedItems.map(\.size)).known,
diff --git a/Peel/Views/Projects/ProjectDetailView.swift b/Peel/Views/Projects/ProjectDetailView.swift
index 9a34cfde..bc42bc1c 100644
--- a/Peel/Views/Projects/ProjectDetailView.swift
+++ b/Peel/Views/Projects/ProjectDetailView.swift
@@ -60,7 +60,7 @@ struct ProjectDetailView: View {
}
}
.dimmedWhileBusy(projects.isScanning)
- .safeAreaBar(edge: .bottom) {
+ .edgeBar(.bottom) {
RemovalBar(
page: group.page,
isScanning: projects.isScanning,
diff --git a/Peel/Views/Projects/ProjectList.swift b/Peel/Views/Projects/ProjectList.swift
index 7486ada1..f71bc25f 100644
--- a/Peel/Views/Projects/ProjectList.swift
+++ b/Peel/Views/Projects/ProjectList.swift
@@ -79,7 +79,7 @@ struct ProjectList: View {
)
}
}
- .safeAreaBar(edge: .bottom) {
+ .edgeBar(.bottom) {
Group {
if projects.wasCutShort {
Text("There were more folders than Peel looks at in one go, so this list isn’t all of them.")
diff --git a/Peel/Views/ResetSheet.swift b/Peel/Views/ResetSheet.swift
index 00796ed1..6119a20a 100644
--- a/Peel/Views/ResetSheet.swift
+++ b/Peel/Views/ResetSheet.swift
@@ -177,7 +177,7 @@ struct ResetSheet: View {
description: Text("Peel found no settings on this Mac that are certainly \(plan.app.name)’s own.")
)
}
- .safeAreaBar(edge: .bottom) { bar }
+ .edgeBar(.bottom) { bar }
}
private var header: some View {
@@ -311,7 +311,7 @@ struct ResetSheet: View {
}
}
}
- .safeAreaBar(edge: .bottom) {
+ .edgeBar(.bottom) {
HStack {
Spacer()
Button("Done") { dismiss() }
diff --git a/Peel/Views/Space/SpaceDetailView.swift b/Peel/Views/Space/SpaceDetailView.swift
index 3ff25d3d..61268aab 100644
--- a/Peel/Views/Space/SpaceDetailView.swift
+++ b/Peel/Views/Space/SpaceDetailView.swift
@@ -86,7 +86,7 @@ struct SpaceDetailView: View {
}
}
.dimmedWhileBusy(space.isScanning)
- .safeAreaBar(edge: .bottom) {
+ .edgeBar(.bottom) {
if !item.isReadOnly {
RemovalBar(
page: item.page,
diff --git a/Peel/Views/Terminal/GitTab.swift b/Peel/Views/Terminal/GitTab.swift
index 140f88e1..c139a281 100644
--- a/Peel/Views/Terminal/GitTab.swift
+++ b/Peel/Views/Terminal/GitTab.swift
@@ -43,14 +43,14 @@ struct GitTab: View {
}
}
.formStyle(.grouped)
- .turnAllOffBar(
+ .edgeBar(.bottom) {
TurnAllOffBar(
explanation: "Peel changes these with `git config --global`. Turning one off puts back what was there before Peel, or leaves it to Git.",
isEnabled: git.hasSomethingOn
) {
isConfirmingTurnAllOff = true
}
- )
+ }
.alert("Turn off all Git settings?", isPresented: $isConfirmingTurnAllOff) {
Button("Turn All Off") { git.turnAllOff() }
Button("Cancel", role: .cancel) {}
diff --git a/Peel/Views/Terminal/SSHTab.swift b/Peel/Views/Terminal/SSHTab.swift
index bad84258..3fef5a0d 100644
--- a/Peel/Views/Terminal/SSHTab.swift
+++ b/Peel/Views/Terminal/SSHTab.swift
@@ -40,14 +40,14 @@ struct SSHTab: View {
}
}
.formStyle(.grouped)
- .turnAllOffBar(
+ .edgeBar(.bottom) {
TurnAllOffBar(
explanation: "Peel writes these to a file of its own, which ssh reads. Turning one off takes it out of that file, and your ~/.ssh/config stays as it is.",
isEnabled: ssh.hasSomethingOn
) {
isConfirmingTurnAllOff = true
}
- )
+ }
.alert("Turn off all SSH settings?", isPresented: $isConfirmingTurnAllOff) {
Button("Turn All Off") { ssh.turnAllOff() }
Button("Cancel", role: .cancel) {}
diff --git a/Peel/Views/Terminal/ShellTab.swift b/Peel/Views/Terminal/ShellTab.swift
index 365798ac..b64d2988 100644
--- a/Peel/Views/Terminal/ShellTab.swift
+++ b/Peel/Views/Terminal/ShellTab.swift
@@ -43,14 +43,14 @@ struct ShellTab: View {
}
}
.formStyle(.grouped)
- .turnAllOffBar(
+ .edgeBar(.bottom) {
TurnAllOffBar(
explanation: "Peel writes these to a file of its own, which zsh reads. Turning one off takes it out of that file, and your ~/.zshrc stays as it is.",
isEnabled: shell.hasSomethingOn
) {
isConfirmingTurnAllOff = true
}
- )
+ }
.alert("Turn off all shell settings?", isPresented: $isConfirmingTurnAllOff) {
Button("Turn All Off") { shell.turnAllOff() }
Button("Cancel", role: .cancel) {}
diff --git a/Peel/Views/TurnAllOffBar.swift b/Peel/Views/TurnAllOffBar.swift
index cae3bcc5..4db36eed 100644
--- a/Peel/Views/TurnAllOffBar.swift
+++ b/Peel/Views/TurnAllOffBar.swift
@@ -21,49 +21,3 @@ struct TurnAllOffBar: View {
.padding(.bottom, 10)
}
}
-
-extension View {
- /// Puts the bar at the foot of the page, over a soft edge only while something has scrolled under it.
- @ViewBuilder
- func turnAllOffBar(_ bar: TurnAllOffBar) -> some View {
- if #available(macOS 27, *) {
- modifier(SoftEdgeWhileScrolledUnder(bar: bar))
- } else {
- safeAreaBar(edge: .bottom) { bar }
- }
- }
-}
-
-/// macOS 27 gives a bar at the foot of a page a background across the page even when nothing is under it, so the
-/// bar takes room as an inset instead. While the content runs on beneath it, a material that blurs it fades in from
-/// above the bar, as the soft scroll edge effect does under a bar on macOS 26.
-private struct SoftEdgeWhileScrolledUnder: ViewModifier {
- let bar: TurnAllOffBar
- @State private var isOverContent = false
-
- func body(content: Content) -> some View {
- content
- .onScrollGeometryChange(for: Bool.self) { geometry in
- // The visible rect reaches under the bar, so the bar's height is taken off its end.
- geometry.contentSize.height - (geometry.visibleRect.maxY - geometry.contentInsets.bottom) > 1
- } action: { _, isUnder in
- isOverContent = isUnder
- }
- .safeAreaInset(edge: .bottom, spacing: 0) {
- bar
- .padding(.top, 10)
- .frame(maxWidth: .infinity)
- .background(alignment: .bottom) {
- if isOverContent {
- Rectangle()
- .fill(.regularMaterial)
- .mask(
- LinearGradient(colors: [.clear, .black], startPoint: .top, endPoint: .center)
- )
- .padding(.top, -24)
- .ignoresSafeArea(edges: .bottom)
- }
- }
- }
- }
-}
diff --git a/Peel/Views/Tweaks/TweakPage.swift b/Peel/Views/Tweaks/TweakPage.swift
index 518c7471..3c2ccaf0 100644
--- a/Peel/Views/Tweaks/TweakPage.swift
+++ b/Peel/Views/Tweaks/TweakPage.swift
@@ -19,7 +19,7 @@ struct TweakPage: View {
}
}
}
- .safeAreaBar(edge: .top) {
+ .edgeBar(.top) {
Group {
if tweaks.isSleepDisabled {
SleepNotice()
@@ -31,14 +31,14 @@ struct TweakPage: View {
.motion(.settle, .movement, value: tweaks.isSleepDisabled)
}
// Shown once for every tab, at the foot of the page, rather than under each group's section.
- .turnAllOffBar(
+ .edgeBar(.bottom) {
TurnAllOffBar(
explanation: "Each of these is a setting macOS already has. Turning one off puts back what was there before Peel, or leaves it to macOS.",
isEnabled: tweaks.hasSomethingOn && !tweaks.isTurningAllOff
) {
isConfirmingTurnAllOff = true
}
- )
+ }
.alert("Turn off all tweaks?", isPresented: $isConfirmingTurnAllOff) {
Button("Turn All Off") {
Task { await tweaks.turnAllOff() }