From c1703abcfca038dda0701276db2f24b22ab65a89 Mon Sep 17 00:00:00 2001 From: Hariharan Mudaliar Date: Thu, 26 Feb 2026 14:02:07 +0530 Subject: [PATCH] Fully working Liquid Glass Optimization --- DynamicIsland/Localizable.xcstrings | 73 +------------------ .../LockScreen/LockScreenMusicPanel.swift | 7 +- .../helpers/LiquidGlassBackground.swift | 18 ++++- 3 files changed, 21 insertions(+), 77 deletions(-) diff --git a/DynamicIsland/Localizable.xcstrings b/DynamicIsland/Localizable.xcstrings index 9d3475b..b3c3e64 100644 --- a/DynamicIsland/Localizable.xcstrings +++ b/DynamicIsland/Localizable.xcstrings @@ -1591,10 +1591,6 @@ } } }, - "±10 Seconds" : { - "comment" : "Displayed as the name of the music skip behavior option.", - "isCommentAutoGenerated" : true - }, "0" : { "comment" : "A label displayed in a circular gauge to indicate the minimum battery level.", "isCommentAutoGenerated" : true, @@ -1911,10 +1907,6 @@ } } }, - "Accent" : { - "comment" : "Display name for the \"Accent\" caps lock indicator tint mode.", - "isCommentAutoGenerated" : true - }, "Accent color" : { "localizations" : { "ar" : { @@ -2260,10 +2252,6 @@ } } }, - "Adaptive gradient" : { - "comment" : "Name of the timer icon color mode option that uses an adaptive gradient.", - "isCommentAutoGenerated" : true - }, "Add" : { "localizations" : { "ar" : { @@ -3853,10 +3841,6 @@ } } }, - "Apple Music" : { - "comment" : "Localized name for \"Now Playing\" media controller type.", - "isCommentAutoGenerated" : true - }, "Applies the notch-style parallax effect to the lock screen media widget album art." : { "localizations" : { "pt-BR" : { @@ -4268,10 +4252,6 @@ } } }, - "Bar" : { - "comment" : "Localized name for the \"Bar\" timer progress style.", - "isCommentAutoGenerated" : true - }, "Battery" : { "localizations" : { "ar" : { @@ -8511,10 +8491,6 @@ } } }, - "Digital" : { - "comment" : "The display name for the \"Digital\" reminder presentation style.", - "isCommentAutoGenerated" : true - }, "Dimensions" : { "localizations" : { "pt-BR" : { @@ -11885,10 +11861,6 @@ } } }, - "Green" : { - "comment" : "Name of the \"Green\" Caps Lock Indicator Tint Mode.", - "isCommentAutoGenerated" : true - }, "Height:" : { "extractionState" : "stale", "localizations" : { @@ -15555,6 +15527,7 @@ } }, "Minutes" : { + "extractionState" : "stale", "localizations" : { "fr" : { "stringUnit" : { @@ -17764,10 +17737,6 @@ } } }, - "Now Playing" : { - "comment" : "Localized name for each media controller type.", - "isCommentAutoGenerated" : true - }, "Off" : { "comment" : "Text displayed in a status label at the top of the screen indicating whether low power mode is on or off.", "isCommentAutoGenerated" : true @@ -18134,10 +18103,6 @@ } } }, - "Panel" : { - "comment" : "Name for the \"Panel\" clipboard display mode.", - "isCommentAutoGenerated" : true - }, "Panel mode shows clipboard in a floating window near the notch." : { "comment" : "A description of the \"Panel\" clipboard display mode.", "isCommentAutoGenerated" : true, @@ -19732,10 +19697,6 @@ } } }, - "Ring" : { - "comment" : "Name of the timer progress style that shows a ring animation.", - "isCommentAutoGenerated" : true - }, "Rotation:" : { "extractionState" : "stale", "localizations" : { @@ -20556,10 +20517,6 @@ } } }, - "Separate Tab" : { - "comment" : "Name of the clipboard display mode option that opens the clipboard in a separate tab.", - "isCommentAutoGenerated" : true - }, "Separate Tab mode integrates Copied Items and Notes into a single view. If both are enabled, Notes appear on the right and Clipboard on the left." : { "comment" : "A description of the \"Separate Tab\" clipboard display mode.", "isCommentAutoGenerated" : true, @@ -21614,14 +21571,6 @@ } } }, - "Shows screen assistant as a dropdown attached to the AI button" : { - "comment" : "Description of the \"Popover\" display mode for the screen assistant.", - "isCommentAutoGenerated" : true - }, - "Shows screen assistant in a floating panel near the notch" : { - "comment" : "Description of the \"panel\" display mode for the screen assistant.", - "isCommentAutoGenerated" : true - }, "Shows the model's reasoning process before the final answer" : { "localizations" : { "fr" : { @@ -21684,10 +21633,6 @@ } } }, - "Skip forward or backward by ten seconds" : { - "comment" : "Description of a music skip behavior where the user can skip forward or backward by ten seconds.", - "isCommentAutoGenerated" : true - }, "Slider color" : { "localizations" : { "ar" : { @@ -22255,10 +22200,6 @@ } } }, - "Spotify" : { - "comment" : "Add more media player types here.", - "isCommentAutoGenerated" : true - }, "Square" : { "localizations" : { "ar" : { @@ -22367,10 +22308,6 @@ }, "Standard notch media controls are hidden. Re-enable the toggle above to restore them." : { - }, - "Standard previous/next track controls" : { - "comment" : "Description of a music skip behavior option that skips to the previous or next track.", - "isCommentAutoGenerated" : true }, "Start" : { "localizations" : { @@ -23720,10 +23657,6 @@ }, "shouldTranslate" : false }, - "Track Skip" : { - "comment" : "Display name for the \"Track Skip\" music skip behavior.", - "isCommentAutoGenerated" : true - }, "Transform" : { "extractionState" : "stale", "localizations" : { @@ -25634,10 +25567,6 @@ "comment" : "A footer note explaining the app's funding.", "isCommentAutoGenerated" : true }, - "Youtube Music" : { - "comment" : "Name for the media controller type that links to YouTube Music.", - "isCommentAutoGenerated" : true - }, "YouTube Music requires this third-party app to be installed: " : { "localizations" : { "ar" : { diff --git a/DynamicIsland/components/LockScreen/LockScreenMusicPanel.swift b/DynamicIsland/components/LockScreen/LockScreenMusicPanel.swift index 4d88285..e7ffd82 100644 --- a/DynamicIsland/components/LockScreen/LockScreenMusicPanel.swift +++ b/DynamicIsland/components/LockScreen/LockScreenMusicPanel.swift @@ -355,13 +355,18 @@ struct LockScreenMusicPanel: View { collapseWorkItem?.cancel() collapseWorkItem = nil } + + private var isProgressTimelinePaused: Bool { + !musicManager.isPlaying || musicManager.isLiveStream || musicManager.playbackRate <= 0 + } // MARK: - Progress Bar private var progressBar: some View { TimelineView( .animation( - minimumInterval: (!musicManager.isLiveStream && musicManager.playbackRate > 0) ? 0.1 : nil + minimumInterval: 0.1, + paused: isProgressTimelinePaused ) ) { timeline in MusicSliderView( diff --git a/DynamicIsland/helpers/LiquidGlassBackground.swift b/DynamicIsland/helpers/LiquidGlassBackground.swift index b7fb299..924a2f2 100644 --- a/DynamicIsland/helpers/LiquidGlassBackground.swift +++ b/DynamicIsland/helpers/LiquidGlassBackground.swift @@ -26,6 +26,8 @@ private final class LiquidGlassContainerView: NSView { private var observedBackdropLayers: [CALayer] = [] private var hasScheduledBackdropSetup = false + private let windowServerAwareKeyPath = "windowServerAware" + private let scaleKeyPath = "scale" deinit { removeBackdropObservers() @@ -69,13 +71,15 @@ private final class LiquidGlassContainerView: NSView { removeBackdropObservers() observedBackdropLayers = newBackdropLayers for backdrop in observedBackdropLayers { - backdrop.addObserver(self, forKeyPath: "windowServerAware", options: [.old, .new], context: nil) + backdrop.addObserver(self, forKeyPath: windowServerAwareKeyPath, options: [.old, .new], context: nil) + backdrop.addObserver(self, forKeyPath: scaleKeyPath, options: [.old, .new], context: nil) } } private func setBackdropProperties(in layer: CALayer) { if NSStringFromClass(type(of: layer)).contains("CABackdropLayer") { - layer.setValue(true, forKey: "windowServerAware") + layer.setValue(true, forKey: windowServerAwareKeyPath) + layer.setValue(1.0, forKey: scaleKeyPath) } layer.sublayers?.forEach { setBackdropProperties(in: $0) } } @@ -95,10 +99,15 @@ private final class LiquidGlassContainerView: NSView { change: [NSKeyValueChangeKey: Any]?, context: UnsafeMutableRawPointer? ) { - if keyPath == "windowServerAware" { + if keyPath == windowServerAwareKeyPath { if change?[.newKey] as? Bool == false { configureBackdropLayers() } + } else if keyPath == scaleKeyPath { + guard let layer = object as? CALayer else { return } + if let newScale = (change?[.newKey] as? NSNumber)?.doubleValue, newScale != 1.0 { + layer.setValue(1.0, forKey: scaleKeyPath) + } } else { super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context) } @@ -106,7 +115,8 @@ private final class LiquidGlassContainerView: NSView { private func removeBackdropObservers() { for layer in observedBackdropLayers { - layer.removeObserver(self, forKeyPath: "windowServerAware") + layer.removeObserver(self, forKeyPath: windowServerAwareKeyPath) + layer.removeObserver(self, forKeyPath: scaleKeyPath) } observedBackdropLayers.removeAll() }