mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 15:14:33 +00:00
Working lock liveactivity
This commit is contained in:
parent
1ac788c5de
commit
05d41f6bb7
3 changed files with 63 additions and 8 deletions
|
|
@ -18,6 +18,7 @@ class LockScreenLiveActivityWindowManager {
|
|||
private var hasDelegated = false
|
||||
private var hideTask: Task<Void, Never>?
|
||||
private var hostingView: NSHostingView<LockScreenLiveActivityOverlay>?
|
||||
private let overlayModel = LockScreenLiveActivityOverlayViewModel()
|
||||
|
||||
private init() {}
|
||||
|
||||
|
|
@ -82,7 +83,7 @@ class LockScreenLiveActivityWindowManager {
|
|||
let targetFrame = frame(for: notchSize, on: screen)
|
||||
window.setFrame(targetFrame, display: true)
|
||||
|
||||
let overlay = LockScreenLiveActivityOverlay(state: state, notchSize: notchSize)
|
||||
let overlay = LockScreenLiveActivityOverlay(state: state, notchSize: notchSize, viewModel: overlayModel)
|
||||
|
||||
if let hostingView {
|
||||
hostingView.rootView = overlay
|
||||
|
|
@ -107,6 +108,15 @@ class LockScreenLiveActivityWindowManager {
|
|||
|
||||
window.orderFrontRegardless()
|
||||
|
||||
if state == .locked {
|
||||
overlayModel.expansion = 0.2
|
||||
withAnimation(.spring(response: 0.55, dampingFraction: 0.82)) {
|
||||
overlayModel.expansion = 1
|
||||
}
|
||||
} else {
|
||||
overlayModel.expansion = 1
|
||||
}
|
||||
|
||||
if window.alphaValue < 1 {
|
||||
NSAnimationContext.runAnimationGroup { context in
|
||||
context.duration = 0.12
|
||||
|
|
@ -141,6 +151,10 @@ class LockScreenLiveActivityWindowManager {
|
|||
|
||||
guard let window else { return }
|
||||
|
||||
withAnimation(.easeOut(duration: 0.1)) {
|
||||
overlayModel.expansion = 0.2
|
||||
}
|
||||
|
||||
NSAnimationContext.runAnimationGroup { context in
|
||||
context.duration = 0.1
|
||||
window.animator().alphaValue = 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue