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
Keep the Settings window one size on every tab
Țugui Dragoș66b6ad0b5000
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 3a23fbcc..47b8d80f 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -182,6 +182,7 @@ its changes the way [Keep a Changelog](https://keepachangelog.com/) suggests.state and its buttons on one row.- Exclusions' `+` for apps opens a short list with a search field, rather than a menu that ran to the edge of thescreen.+- The Settings window keeps one size on every tab, rather than growing and shrinking as tabs change.#### Applicationsdiff --git a/Packages/PeelCore/Sources/PeelCore/Support/GrowingWindow.swift b/Packages/PeelCore/Sources/PeelCore/Support/GrowingWindow.swiftdeleted file mode 100644index a708a28f..00000000--- a/Packages/PeelCore/Sources/PeelCore/Support/GrowingWindow.swift+++ /dev/null@@ -1,12 +0,0 @@-public import CoreGraphics--/// Where a window that grew has to stand to stay on its screen.-public enum GrowingWindow {- /// `frame` moved up just as far as its bottom needs to be within `visible`, and never so far that its top passes- /// the top of `visible`. Both are in screen coordinates, which grow upward.- public static func frame(_ frame: CGRect, within visible: CGRect) -> CGRect {- let lowest = frame.height <= visible.height ? visible.minY : visible.maxY - frame.height- guard frame.minY < lowest else { return frame }- return CGRect(x: frame.minX, y: lowest, width: frame.width, height: frame.height)- }-}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/GrowingWindowTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/GrowingWindowTests.swiftdeleted file mode 100644index 09dd709a..00000000--- a/Packages/PeelCore/Tests/PeelCoreTests/GrowingWindowTests.swift+++ /dev/null@@ -1,34 +0,0 @@-import CoreGraphics-@testable import PeelCore-import Testing--struct GrowingWindowTests {- private let macBook = CGRect(x: 0, y: 0, width: 1470, height: 923)-- @Test func aWindowThatGrewPastTheBottomMovesUpByWhatItPassed() {- let grown = CGRect(x: 355, y: -36, width: 760, height: 608)- #expect(GrowingWindow.frame(grown, within: macBook) == CGRect(x: 355, y: 0, width: 760, height: 608))- }-- @Test func aWindowWithinTheScreenStaysWhereItIs() {- let window = CGRect(x: 355, y: 352, width: 760, height: 220)- #expect(GrowingWindow.frame(window, within: macBook) == window)- }-- @Test func aWindowTallerThanTheScreenKeepsItsTopAtTheTopOfTheScreen() {- let small = CGRect(x: 0, y: 0, width: 1024, height: 633)- let grown = CGRect(x: 100, y: -200, width: 760, height: 700)- #expect(GrowingWindow.frame(grown, within: small) == CGRect(x: 100, y: -67, width: 760, height: 700))- }-- @Test func aWindowIsNeverMovedDown() {- let high = CGRect(x: 355, y: 500, width: 760, height: 608)- #expect(GrowingWindow.frame(high, within: macBook) == high)- }-- @Test func aScreenBesideTheMainOneIsMeasuredFromItsOwnBottom() {- let external = CGRect(x: 1470, y: -272, width: 1920, height: 1055)- let grown = CGRect(x: 2000, y: -300, width: 760, height: 608)- #expect(GrowingWindow.frame(grown, within: external) == CGRect(x: 2000, y: -272, width: 760, height: 608))- }-}diff --git a/Peel/Views/Settings/SettingsView.swift b/Peel/Views/Settings/SettingsView.swiftindex d34ce661..92974244 100644--- a/Peel/Views/Settings/SettingsView.swift+++ b/Peel/Views/Settings/SettingsView.swift@@ -23,9 +23,9 @@ enum SettingsPane: String {/// The last open tab is remembered, as the Human Interface Guidelines ask of a settings window.struct SettingsTabs: View {@AppStorage(SettingsKey.pane) private var pane = SettingsPane.general.rawValue- /// Whether each tab is as tall as what it shows, which the Settings window follows. On the Settings page the- /// tabs fill the column.- var fitsEachTab = false+ /// Whether the tabs have the Settings window's size, the same for every tab, so the window holds still as they+ /// change. On the Settings page the tabs fill the column.+ var isInTheWindow = falsevar body: some View {TabView(selection: $pane) {@@ -44,43 +44,27 @@ struct SettingsTabs: View {}}- /// A tab as tall as what it shows, up to 520 points, past which it scrolls. A tab view gives every tab the- /// same height unless each asks for its own, which is what `fixedSize` does here.@ViewBuilderprivate func fitted(_ tab: some View) -> some View {- if fitsEachTab {- tab- .frame(width: 680)- .frame(maxHeight: 520)- .fixedSize(horizontal: false, vertical: true)+ if isInTheWindow {+ tab.frame(width: 680, height: SettingsView.height)} else {tab}}}-/// The Settings window's content. The `Settings` scene sizes the window to fit it, so the window takes the-/// height of the tab shown and can't be resized, as a settings window on the Mac does.+/// The Settings window's content. The `Settings` scene sizes the window to fit it, so it keeps one size whichever tab+/// is open, and a tab with more to show scrolls.struct SettingsView: View {- @State private var hostWindow = HostWindow()+ static let height: CGFloat = 520var body: some View {- Group {- if #available(macOS 27, *) {- SettingsWindowTabs()- } else {- SettingsTabs(fitsEachTab: true)- }- }- // AppKit keeps the window's top where it was as a taller tab makes it grow, which can carry its bottom past- // the bottom of the screen.- .onReceive(NotificationCenter.default.publisher(for: NSWindow.didResizeNotification)) { notice in- guard let window = hostWindow.value, notice.object as? NSWindow === window, let screen = window.screen- else { return }- let frame = GrowingWindow.frame(window.frame, within: screen.visibleFrame)- if frame.origin != window.frame.origin { window.setFrameOrigin(frame.origin) }+ if #available(macOS 27, *) {+ SettingsWindowTabs()+ } else {+ SettingsTabs(isInTheWindow: true)}- .background(HostWindowReader(host: hostWindow))}}@@ -92,9 +76,7 @@ private struct SettingsWindowTabs: View {var body: some View {page- .frame(width: 760)- .frame(maxHeight: 520)- .fixedSize(horizontal: false, vertical: true)+ .frame(width: 760, height: SettingsView.height).navigationTitle(title).toolbar {ToolbarItem(placement: .principal) {