Removed Pulsating

This commit is contained in:
Hariharan Mudaliar 2025-10-17 18:32:34 +05:30
commit 1ac788c5de
3 changed files with 33 additions and 69 deletions

View file

@ -21,34 +21,21 @@ struct LockScreenLiveActivity: View {
}
private var iconColor: Color {
lockScreenManager.isLocked ? .blue : .green
}
private var glowColor: Color {
lockScreenManager.isLocked ? Color.blue.opacity(0.15) : Color.green.opacity(0.2)
.white
}
var body: some View {
HStack(spacing: 0) {
// Left - Lock icon with subtle glow
Color.clear
.background {
.overlay(alignment: .leading) {
if isExpanded {
HStack {
ZStack {
RoundedRectangle(cornerRadius: 6)
.fill(glowColor)
Image(systemName: iconName)
.font(.system(size: 12, weight: .semibold))
.foregroundColor(iconColor)
.modifier(LockPulsingModifier(isUnlocking: !lockScreenManager.isLocked))
.foregroundStyle(iconColor)
.matchedGeometryEffect(id: "lock-icon", in: lockIconSpace)
}
.frame(width: vm.effectiveClosedNotchHeight - 12, height: vm.effectiveClosedNotchHeight - 12)
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading)
}
}
.frame(width: isExpanded ? max(0, vm.effectiveClosedNotchHeight - (isHovering ? 0 : 12) + gestureProgress / 2) : 0, height: vm.effectiveClosedNotchHeight - (isHovering ? 0 : 12))
@ -87,23 +74,3 @@ struct LockScreenLiveActivity: View {
.animation(.easeOut(duration: 0.25), value: isExpanded)
}
}
// Pulsing animation modifier for lock indicator
struct LockPulsingModifier: ViewModifier {
var isUnlocking: Bool
@State private var isPulsing = false
func body(content: Content) -> some View {
content
.scaleEffect(isPulsing ? 1.1 : 1.0)
.opacity(isPulsing ? (isUnlocking ? 1.0 : 0.8) : 1.0)
.onAppear {
withAnimation(.easeInOut(duration: 1.0).repeatForever(autoreverses: true)) {
isPulsing = true
}
}
.onDisappear {
isPulsing = false
}
}
}

View file

@ -36,32 +36,17 @@ struct LockScreenLiveActivityOverlay: View {
state == .locked ? "lock.fill" : "lock.open.fill"
}
private var iconColor: Color {
state == .locked ? .blue : .green
}
private var glowColor: Color {
state == .locked ? Color.blue.opacity(0.15) : Color.green.opacity(0.2)
}
private var iconColor: Color { .white }
var body: some View {
HStack(alignment: .top, spacing: 0) {
Color.clear
.background {
HStack {
ZStack {
RoundedRectangle(cornerRadius: 6)
.fill(glowColor)
.overlay(alignment: .leading) {
Image(systemName: iconName)
.font(.system(size: 12, weight: .semibold))
.foregroundColor(iconColor)
.modifier(LockPulsingModifier(isUnlocking: state == .unlocking))
}
.foregroundStyle(iconColor)
.frame(width: indicatorSize, height: indicatorSize)
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading)
}
.frame(width: indicatorSize, height: notchSize.height, alignment: .top)
Color.clear

View file

@ -17,6 +17,7 @@ class LockScreenLiveActivityWindowManager {
private var window: NSWindow?
private var hasDelegated = false
private var hideTask: Task<Void, Never>?
private var hostingView: NSHostingView<LockScreenLiveActivityOverlay>?
private init() {}
@ -82,7 +83,21 @@ class LockScreenLiveActivityWindowManager {
window.setFrame(targetFrame, display: true)
let overlay = LockScreenLiveActivityOverlay(state: state, notchSize: notchSize)
window.contentView = NSHostingView(rootView: overlay)
if let hostingView {
hostingView.rootView = overlay
hostingView.frame = CGRect(origin: .zero, size: targetFrame.size)
} else {
let view = NSHostingView(rootView: overlay)
view.frame = CGRect(origin: .zero, size: targetFrame.size)
hostingView = view
window.contentView = view
}
if window.contentView !== hostingView {
window.contentView = hostingView
}
window.displayIfNeeded()
if !hasDelegated {
@ -90,17 +105,13 @@ class LockScreenLiveActivityWindowManager {
hasDelegated = true
}
if !window.isVisible {
window.alphaValue = 0
window.orderFrontRegardless()
if window.alphaValue < 1 {
NSAnimationContext.runAnimationGroup { context in
context.duration = 0.12
window.animator().alphaValue = 1
}
} else {
window.orderFrontRegardless()
window.alphaValue = 1
}
}
@ -130,9 +141,10 @@ class LockScreenLiveActivityWindowManager {
guard let window else { return }
window.orderOut(nil)
window.alphaValue = 0
window.contentView = nil
NSAnimationContext.runAnimationGroup { context in
context.duration = 0.1
window.animator().alphaValue = 0
}
print("[\(timestamp())] LockScreenLiveActivityWindowManager: HUD hidden")
}