added lyrics feature

This commit is contained in:
delli 2025-11-15 14:21:31 +01:00
commit 13e60c5211
8 changed files with 464 additions and 47 deletions

View file

@ -83,7 +83,34 @@ class DynamicIslandViewModel: NSObject, ObservableObject {
let updatedTarget = self.calculateDynamicNotchSize()
guard self.notchState == .open else { return }
guard self.notchSize != updatedTarget else { return }
self.notchSize = updatedTarget
withAnimation(.smooth) {
self.notchSize = updatedTarget
}
if let delegate = AppDelegate.shared {
delegate.ensureWindowSize(updatedTarget, animated: true, force: false)
}
}
.store(in: &cancellables)
// Observe settings + lyrics changes to dynamically resize the notch
let enableLyricsPublisher = Defaults.publisher(.enableLyrics).map { $0.newValue }
enableLyricsPublisher
.combineLatest(MusicManager.shared.$currentLyrics)
.removeDuplicates { $0.0 == $1.0 && $0.1 == $1.1 }
.receive(on: RunLoop.main)
.sink { [weak self] _ in
guard let self else { return }
guard Defaults[.enableMinimalisticUI] else { return }
let updatedTarget = self.calculateDynamicNotchSize()
guard self.notchState == .open else { return }
guard self.notchSize != updatedTarget else { return }
withAnimation(.smooth) {
self.notchSize = updatedTarget
}
if let delegate = AppDelegate.shared {
delegate.ensureWindowSize(updatedTarget, animated: true, force: false)
}
}
.store(in: &cancellables)
}
@ -171,27 +198,32 @@ class DynamicIslandViewModel: NSObject, ObservableObject {
if Defaults[.enableMinimalisticUI] {
let extraHeight = ReminderLiveActivityManager.additionalHeight(forRowCount: minimalisticReminderRowCount)
baseSize.height += extraHeight
// Add extra height for lyrics if enabled in settings
if Defaults[.enableLyrics] {
baseSize.height += 24 // Additional height for lyrics display
}
}
// Only apply dynamic sizing when on stats tab and stats are enabled
guard DynamicIslandViewCoordinator.shared.currentView == .stats && Defaults[.enableStatsFeature] else {
return baseSize
}
let enabledGraphsCount = [
Defaults[.showCpuGraph],
Defaults[.showMemoryGraph],
Defaults[.showMemoryGraph],
Defaults[.showGpuGraph],
Defaults[.showNetworkGraph],
Defaults[.showDiskGraph]
].filter { $0 }.count
// If 4+ graphs are enabled, increase width
if enabledGraphsCount >= 4 {
let extraWidth: CGFloat = CGFloat(enabledGraphsCount - 3) * 120
return CGSize(width: baseSize.width + extraWidth, height: baseSize.height)
}
return baseSize
}