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
Tell of a new version of Peel in the menu bar panel
Țugui Dragoș045edb03be75
diff --git a/GUIDE.md b/GUIDE.mdindex c4f6dbb6..1ed2fdb6 100644--- a/GUIDE.md+++ b/GUIDE.md@@ -516,9 +516,10 @@ account.### How does Peel update itself?-Choose Check for Updates in the Peel menu, or Install Update in About Peel when it says a new version is out. While-Check for app updates is on, Peel also looks once a day. It shows what is new and installs the update only when you-choose, once it has checked that the update is signed as Peel's.+Choose Check for Updates in the Peel menu or in the menu of Peel's panel in the menu bar, or Install Update in About+Peel when it says a new version is out. While Check for app updates is on, Peel also looks once a day, and the panel+says when it found one. It shows what is new and installs the update only when you choose, once it has checked that+the update is signed as Peel's.### Something in Peel isn't clear. Where can I read more?diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex 833eba5f..1817845c 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -127230,6 +127230,112 @@"comment" : "The app's name, never translated.","shouldTranslate" : false},+ "Peel %@ is out" : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Vyšel Peel %@"+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel %@ ist verfügbar"+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel %@ disponible"+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel %@ est disponible"+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel %@ disponibile"+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel %@が公開されました"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel %@ 출시됨"+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel %@ is verschenen"+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Dostępna wersja Peel %@"+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel %@ disponível"+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "A apărut Peel %@"+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Вышла версия Peel %@"+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel %@ har släppts"+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel %@ çıktı"+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Вийшла Peel %@"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel %@已发布"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel %@已推出"+ }+ }+ }+ },"Peel Can’t Run the `brew` You Chose" : {"comment" : "The title of the Homebrew page when the brew program the person chose in Settings > General can no longer be run (moved, not a program, or not theirs). Keep `brew` as it is: it is Homebrew's command.","localizations" : {diff --git a/Peel/HomeSnapshot.swift b/Peel/HomeSnapshot.swiftindex 42963718..e58e818c 100644--- a/Peel/HomeSnapshot.swift+++ b/Peel/HomeSnapshot.swift@@ -86,12 +86,20 @@ enum HomeSnapshot {)try render(MenuBarPanel().environment(AppLibrary()).environment(stats).environment(found)- .environment(homebrew),+ .environment(homebrew).environment(PeelUpdater()),width: 320,scheme: scheme,contrast: contrast,to: "\(directory)/menu-bar-\(name).png")+ try render(+ MenuBarPanel().environment(AppLibrary()).environment(stats).environment(found)+ .environment(homebrew).environment(PeelUpdater(found: "1.0.2")),+ width: 320,+ scheme: scheme,+ contrast: contrast,+ to: "\(directory)/menu-bar-update-\(name).png"+ )}}} catch {diff --git a/Peel/Model/PeelUpdater.swift b/Peel/Model/PeelUpdater.swiftindex b65e0cdb..2fd8a55c 100644--- a/Peel/Model/PeelUpdater.swift+++ b/Peel/Model/PeelUpdater.swift@@ -5,8 +5,9 @@ import Sparkle/// Peel's own updates, through Sparkle: it reads the signed feed, shows the new version to the person, and installs it/// only when they choose, once the update's signature checks out. What Sparkle may do is set in the Info.plist.///-/// A new version found while the person works is told gently, by the face, the sidebar and About, and Sparkle's window-/// opens when they ask for it; Sparkle shows it at once only when it would have their full attention anyway.+/// A new version found while the person works is told gently, by the face, the sidebar, About and the menu bar+/// panel, and Sparkle's window opens when they ask for it; Sparkle shows it at once only when it would have their+/// full attention anyway.@Observablefinal class PeelUpdater: NSObject, SPUUpdaterDelegate, SPUStandardUserDriverDelegate {/// The version Sparkle last found newer than this copy, nil until it finds one and once it finds none.@@ -16,10 +17,11 @@ final class PeelUpdater: NSObject, SPUUpdaterDelegate, SPUStandardUserDriverDele@ObservationIgnored private var canCheck: NSKeyValueObservation?#if DEBUG- /// About as it reads once Sparkle found `version`, for `HomeSnapshot`.+ /// What reads the updater as it reads once Sparkle found `version`, for `HomeSnapshot`.convenience init(found version: String) {self.init()newerVersion = version+ canCheckForUpdates = true}#endif@@ -71,7 +73,7 @@ final class PeelUpdater: NSObject, SPUUpdaterDelegate, SPUStandardUserDriverDele}/// Where Sparkle hands Peel an update it leaves to Peel to tell, which Sparkle requires once Peel takes any.- /// `newerVersion`, set when Sparkle found it, already shows it in the face, the sidebar and About.+ /// `newerVersion`, set when Sparkle found it, already shows it wherever Peel tells of a new version.nonisolated func standardUserDriverWillHandleShowingUpdate(_ handleShowingUpdate: Bool,forUpdate update: SUAppcastItem,diff --git a/Peel/PeelApp.swift b/Peel/PeelApp.swiftindex 5b4d7f7d..eea19adc 100644--- a/Peel/PeelApp.swift+++ b/Peel/PeelApp.swift@@ -496,6 +496,7 @@ struct PeelApp: App {.environment(homebrew).environment(stats).environment(found)+ .environment(updater)} label: {// The update count sits next to the glyph, so updates show without opening Peel.let count = library.menuBarUpdateCountdiff --git a/Peel/Views/MenuBarPanel.swift b/Peel/Views/MenuBarPanel.swiftindex 19920bf5..30e76bc8 100644--- a/Peel/Views/MenuBarPanel.swift+++ b/Peel/Views/MenuBarPanel.swift@@ -7,7 +7,9 @@ struct MenuBarPanel: View {@Environment(\.openWindow) private var openWindow@Environment(AppLibrary.self) private var library@Environment(LifetimeStats.self) private var stats+ @Environment(PeelUpdater.self) private var updater@State private var isPointingAtUpdates = false+ @State private var isPointingAtOwnUpdate = false@State private var room = Self.roomstatic let rowPadding: CGFloat = 18@@ -83,6 +85,8 @@ struct MenuBarPanel: View {Menu {SettingsLink { Text("Settings…") }Button("About Peel") { openWindow(id: AboutView.windowID) }+ Button("Check for Updates…", action: updater.checkForUpdates)+ .disabled(!updater.canCheckForUpdates)Divider()Button("Quit Peel") { QuitGuard.quit() }.keyboardShortcut("q")@@ -137,37 +141,53 @@ struct MenuBarPanel: View {private var updates: some View {let waiting = library.menuBarUpdatesVStack(spacing: 0) {+ if let version = updater.newerVersion {+ Divider().padding(.leading, Self.wordsInset)+ updateRow(+ "arrow.down.circle", Text("Peel \(version) is out"), value: "", amount: 0,+ isPointing: $isPointingAtOwnUpdate, action: updater.checkForUpdates+ )+ .disabled(!updater.canCheckForUpdates)+ }if let first = waiting.first {Divider().padding(.leading, Self.wordsInset)- Button {+ updateRow(+ "arrow.down.app", Text("Updates waiting"), value: waiting.count.formatted(), amount: waiting.count,+ isPointing: $isPointingAtUpdates+ ) {// One update opens that app's page, where it is updated. Several open the list, which leads with// them, rather than one app's page with its files selected for removal.library.selection = waiting.count == 1 ? [first.id] : []open(at: .applications)- } label: {- rowContent(- "arrow.down.app",- Text("Updates waiting"),- waiting.count.formatted(),- amount: waiting.count,- isAccented: true,- leadsSomewhere: true- )}- .buttonStyle(.plain)- .accessibilityLabel(Text("Updates waiting"))- .accessibilityValue(Text(verbatim: waiting.count.formatted()))- .background(isPointingAtUpdates ? Album.slot : .clear)- .motion(.touch, value: isPointingAtUpdates)- .onHover { isPointingAtUpdates = $0 }- .onDisappear { isPointingAtUpdates = false }- .transition(.opacity)}}.clipped()- // The layout itself moves here: the panel grows and shrinks as the row comes and goes, so Reduce+ // The layout itself moves here: the panel grows and shrinks as a row comes and goes, so Reduce// Motion stops it rather than fading it..motion(.settle, .movement, value: waiting.count)+ .motion(.settle, .movement, value: updater.newerVersion)+ }++ private func updateRow(+ _ symbol: String,+ _ label: Text,+ value: String,+ amount: Int,+ isPointing: Binding<Bool>,+ action: @escaping () -> Void+ ) -> some View {+ Button(action: action) {+ rowContent(symbol, label, value, amount: amount, isAccented: true, leadsSomewhere: true)+ }+ .buttonStyle(.plain)+ .accessibilityLabel(label)+ .accessibilityValue(Text(verbatim: value))+ .background(isPointing.wrappedValue ? Album.slot : .clear)+ .motion(.touch, value: isPointing.wrappedValue)+ .onHover { isPointing.wrappedValue = $0 }+ .onDisappear { isPointing.wrappedValue = false }+ .transition(.opacity)}private func row(diff --git a/PeelTests/MenuBarPanelTests.swift b/PeelTests/MenuBarPanelTests.swiftnew file mode 100644index 00000000..1d859e65--- /dev/null+++ b/PeelTests/MenuBarPanelTests.swift@@ -0,0 +1,29 @@+import Foundation+@testable import Peel+import SwiftUI+import Testing++@MainActor+struct MenuBarPanelTests {+ private func height(with updater: PeelUpdater) throws -> CGFloat {+ let made = try MadeUpDefaults()+ defer { made.forget() }+ let folder = FileManager.default.temporaryDirectory.appending(+ path: "MenuBarPanelTests-\(UUID().uuidString)", directoryHint: .isDirectory+ )+ defer { try? FileManager.default.removeItem(at: folder) }+ let panel = MenuBarPanel()+ .environment(AppLibrary(defaults: made.defaults))+ .environment(HomebrewLibrary())+ .environment(LifetimeStats(+ defaults: made.defaults, bundle: folder, history: folder.appending(path: "removals.json")+ ))+ .environment(FoundLastTimeStore(defaults: made.defaults))+ .environment(updater)+ return NSHostingView(rootView: panel).fittingSize.height+ }++ @Test func aNewVersionOfPeelHasARowOfItsOwn() throws {+ #expect(try height(with: PeelUpdater(found: "9.9")) > height(with: PeelUpdater()))+ }+}