diff --git a/DynamicIsland/components/LockScreen/LockScreenTimerWidget.swift b/DynamicIsland/components/LockScreen/LockScreenTimerWidget.swift index 076c992..d21c36a 100644 --- a/DynamicIsland/components/LockScreen/LockScreenTimerWidget.swift +++ b/DynamicIsland/components/LockScreen/LockScreenTimerWidget.swift @@ -201,12 +201,23 @@ struct LockScreenTimerWidget: View { } private func stopTimer() { - guard timerManager.allowsManualInteraction else { - timerManager.endExternalTimer(triggerSmoothClose: false) - return + let stopAction: @MainActor () -> Void = { + if timerManager.allowsManualInteraction { + timerManager.stopTimer() + } else { + timerManager.endExternalTimer(triggerSmoothClose: false) + } + } + + Task { @MainActor in + // Trigger the scale-out animation first so the dismissal mirrors the unlock flow. + LockScreenTimerWidgetPanelManager.shared.hide() + + try? await Task.sleep(nanoseconds: LockScreenTimerWidgetPanelManager.hideAnimationDurationNanoseconds) + + guard !Task.isCancelled else { return } + stopAction() } - timerManager.stopTimer() - LockScreenTimerWidgetPanelManager.shared.hide() } private struct CircleButton: View { diff --git a/DynamicIsland/managers/LockScreenTimerWidgetManager.swift b/DynamicIsland/managers/LockScreenTimerWidgetManager.swift index b8efbe3..50fee0d 100644 --- a/DynamicIsland/managers/LockScreenTimerWidgetManager.swift +++ b/DynamicIsland/managers/LockScreenTimerWidgetManager.swift @@ -95,6 +95,7 @@ final class LockScreenTimerWidgetManager { @MainActor final class LockScreenTimerWidgetPanelManager { static let shared = LockScreenTimerWidgetPanelManager() + static let hideAnimationDurationNanoseconds: UInt64 = 360_000_000 private var window: NSWindow? private var hasDelegated = false @@ -120,7 +121,7 @@ final class LockScreenTimerWidgetPanelManager { hideTask?.cancel() animator.isPresented = false - let delay: UInt64 = animated ? 360_000_000 : 0 + let delay: UInt64 = animated ? Self.hideAnimationDurationNanoseconds : 0 if delay == 0 { window.orderOut(nil) hideTask = nil