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,33 +21,20 @@ struct LockScreenLiveActivity: View {
} }
private var iconColor: Color { private var iconColor: Color {
lockScreenManager.isLocked ? .blue : .green .white
}
private var glowColor: Color {
lockScreenManager.isLocked ? Color.blue.opacity(0.15) : Color.green.opacity(0.2)
} }
var body: some View { var body: some View {
HStack(spacing: 0) { HStack(spacing: 0) {
// Left - Lock icon with subtle glow // Left - Lock icon with subtle glow
Color.clear Color.clear
.background { .overlay(alignment: .leading) {
if isExpanded { if isExpanded {
HStack { Image(systemName: iconName)
ZStack { .font(.system(size: 12, weight: .semibold))
RoundedRectangle(cornerRadius: 6) .foregroundStyle(iconColor)
.fill(glowColor) .matchedGeometryEffect(id: "lock-icon", in: lockIconSpace)
Image(systemName: iconName)
.font(.system(size: 12, weight: .semibold))
.foregroundColor(iconColor)
.modifier(LockPulsingModifier(isUnlocking: !lockScreenManager.isLocked))
.matchedGeometryEffect(id: "lock-icon", in: lockIconSpace)
}
.frame(width: vm.effectiveClosedNotchHeight - 12, height: vm.effectiveClosedNotchHeight - 12) .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)) .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) .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,31 +36,16 @@ struct LockScreenLiveActivityOverlay: View {
state == .locked ? "lock.fill" : "lock.open.fill" state == .locked ? "lock.fill" : "lock.open.fill"
} }
private var iconColor: Color { private var iconColor: Color { .white }
state == .locked ? .blue : .green
}
private var glowColor: Color {
state == .locked ? Color.blue.opacity(0.15) : Color.green.opacity(0.2)
}
var body: some View { var body: some View {
HStack(alignment: .top, spacing: 0) { HStack(alignment: .top, spacing: 0) {
Color.clear Color.clear
.background { .overlay(alignment: .leading) {
HStack { Image(systemName: iconName)
ZStack { .font(.system(size: 12, weight: .semibold))
RoundedRectangle(cornerRadius: 6) .foregroundStyle(iconColor)
.fill(glowColor)
Image(systemName: iconName)
.font(.system(size: 12, weight: .semibold))
.foregroundColor(iconColor)
.modifier(LockPulsingModifier(isUnlocking: state == .unlocking))
}
.frame(width: indicatorSize, height: indicatorSize) .frame(width: indicatorSize, height: indicatorSize)
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading)
} }
.frame(width: indicatorSize, height: notchSize.height, alignment: .top) .frame(width: indicatorSize, height: notchSize.height, alignment: .top)

View file

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