From 1ac788c5de18322b260959aa64f55ed242035fc0 Mon Sep 17 00:00:00 2001 From: Hariharan Mudaliar Date: Fri, 17 Oct 2025 18:32:34 +0530 Subject: [PATCH] Removed Pulsating --- .../LockScreen/LockScreenLiveActivity.swift | 45 +++---------------- .../LockScreenLiveActivityOverlay.swift | 25 +++-------- .../LockScreenLiveActivityWindowManager.swift | 32 ++++++++----- 3 files changed, 33 insertions(+), 69 deletions(-) diff --git a/DynamicIsland/components/LockScreen/LockScreenLiveActivity.swift b/DynamicIsland/components/LockScreen/LockScreenLiveActivity.swift index 41a3735..32ba769 100644 --- a/DynamicIsland/components/LockScreen/LockScreenLiveActivity.swift +++ b/DynamicIsland/components/LockScreen/LockScreenLiveActivity.swift @@ -21,33 +21,20 @@ 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)) - .matchedGeometryEffect(id: "lock-icon", in: lockIconSpace) - } + Image(systemName: iconName) + .font(.system(size: 12, weight: .semibold)) + .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 - } - } -} diff --git a/DynamicIsland/components/LockScreen/LockScreenLiveActivityOverlay.swift b/DynamicIsland/components/LockScreen/LockScreenLiveActivityOverlay.swift index ace5e30..d28fe33 100644 --- a/DynamicIsland/components/LockScreen/LockScreenLiveActivityOverlay.swift +++ b/DynamicIsland/components/LockScreen/LockScreenLiveActivityOverlay.swift @@ -36,31 +36,16 @@ 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) - - Image(systemName: iconName) - .font(.system(size: 12, weight: .semibold)) - .foregroundColor(iconColor) - .modifier(LockPulsingModifier(isUnlocking: state == .unlocking)) - } + .overlay(alignment: .leading) { + Image(systemName: iconName) + .font(.system(size: 12, weight: .semibold)) + .foregroundStyle(iconColor) .frame(width: indicatorSize, height: indicatorSize) - } - .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading) } .frame(width: indicatorSize, height: notchSize.height, alignment: .top) diff --git a/DynamicIsland/managers/LockScreenLiveActivityWindowManager.swift b/DynamicIsland/managers/LockScreenLiveActivityWindowManager.swift index b1fcbbb..6c14f76 100644 --- a/DynamicIsland/managers/LockScreenLiveActivityWindowManager.swift +++ b/DynamicIsland/managers/LockScreenLiveActivityWindowManager.swift @@ -17,6 +17,7 @@ class LockScreenLiveActivityWindowManager { private var window: NSWindow? private var hasDelegated = false private var hideTask: Task? + private var hostingView: NSHostingView? 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() + 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") }