From d4f23b5a8f5ca0fac393eb7ba78c2fe3e32e52da Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Sat, 30 Mar 2024 14:28:59 +0900 Subject: [PATCH] Hide dock tile when not showing progress Fixes #20 --- Sources/DockProgress/DockProgress.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Sources/DockProgress/DockProgress.swift b/Sources/DockProgress/DockProgress.swift index 7273d94..42ed344 100644 --- a/Sources/DockProgress/DockProgress.swift +++ b/Sources/DockProgress/DockProgress.swift @@ -107,6 +107,7 @@ public enum DockProgress { public static var progress: Double = 0 { didSet { if progress > 0 { + NSApp.dockTile.contentView = dockContentView displayLinkObserver.start() } else { updateDockIcon() @@ -117,7 +118,13 @@ public enum DockProgress { /** The currently displayed progress. Animates towards ``progress``. */ - public private(set) static var displayedProgress = 0.0 + public private(set) static var displayedProgress = 0.0 { + didSet { + if displayedProgress == 0 || displayedProgress >= 1 { + NSApp.dockTile.contentView = nil + } + } + } /** Reset the progress without animating.