mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-28 23:54:32 +00:00
Smoothened dismiss timer
This commit is contained in:
parent
2db2fb20a5
commit
f9a8887879
2 changed files with 18 additions and 6 deletions
|
|
@ -201,12 +201,23 @@ struct LockScreenTimerWidget: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func stopTimer() {
|
private func stopTimer() {
|
||||||
guard timerManager.allowsManualInteraction else {
|
let stopAction: @MainActor () -> Void = {
|
||||||
timerManager.endExternalTimer(triggerSmoothClose: false)
|
if timerManager.allowsManualInteraction {
|
||||||
return
|
|
||||||
}
|
|
||||||
timerManager.stopTimer()
|
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()
|
LockScreenTimerWidgetPanelManager.shared.hide()
|
||||||
|
|
||||||
|
try? await Task.sleep(nanoseconds: LockScreenTimerWidgetPanelManager.hideAnimationDurationNanoseconds)
|
||||||
|
|
||||||
|
guard !Task.isCancelled else { return }
|
||||||
|
stopAction()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private struct CircleButton: View {
|
private struct CircleButton: View {
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,7 @@ final class LockScreenTimerWidgetManager {
|
||||||
@MainActor
|
@MainActor
|
||||||
final class LockScreenTimerWidgetPanelManager {
|
final class LockScreenTimerWidgetPanelManager {
|
||||||
static let shared = LockScreenTimerWidgetPanelManager()
|
static let shared = LockScreenTimerWidgetPanelManager()
|
||||||
|
static let hideAnimationDurationNanoseconds: UInt64 = 360_000_000
|
||||||
|
|
||||||
private var window: NSWindow?
|
private var window: NSWindow?
|
||||||
private var hasDelegated = false
|
private var hasDelegated = false
|
||||||
|
|
@ -120,7 +121,7 @@ final class LockScreenTimerWidgetPanelManager {
|
||||||
hideTask?.cancel()
|
hideTask?.cancel()
|
||||||
animator.isPresented = false
|
animator.isPresented = false
|
||||||
|
|
||||||
let delay: UInt64 = animated ? 360_000_000 : 0
|
let delay: UInt64 = animated ? Self.hideAnimationDurationNanoseconds : 0
|
||||||
if delay == 0 {
|
if delay == 0 {
|
||||||
window.orderOut(nil)
|
window.orderOut(nil)
|
||||||
hideTask = nil
|
hideTask = nil
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue