Working Lyrics and adjusted height

This commit is contained in:
Hariharan Mudaliar 2025-11-18 00:03:59 +05:30
commit 4f82ce417e
6 changed files with 116 additions and 34 deletions

View file

@ -52,15 +52,7 @@ struct MinimalisticMusicView: View {
// Lyrics under the author name (same font size as author)
if enableLyrics {
Text(musicManager.currentLyrics)
.font(.system(size: 10, weight: .regular))
.foregroundColor(.white.opacity(0.8))
.lineLimit(2)
.multilineTextAlignment(.center)
.frame(maxWidth: .infinity, alignment: .center)
.padding(.horizontal, 4)
.transition(.opacity)
.animation(.easeInOut(duration: 0.3), value: musicManager.currentLyrics)
lyricsLineView
}
}
.frame(width: geo.size.width, height: geo.size.height, alignment: .center)
@ -75,7 +67,7 @@ struct MinimalisticMusicView: View {
// (lyrics are displayed inline under the artist name)
}
// reserve extra height when lyrics are enabled
.frame(height: vm.effectiveClosedNotchHeight + (isHovering ? 8 : 0) + (enableLyrics ? 22 : 0), alignment: .center)
.frame(height: vm.effectiveClosedNotchHeight + (isHovering ? 8 : 0), alignment: .center)
.onHover { hovering in
isHovering = hovering
}
@ -118,3 +110,33 @@ struct MinimalisticMusicView: View {
height: max(0, vm.effectiveClosedNotchHeight - (isHovering ? 0 : 12)), alignment: .center)
}
}
private extension MinimalisticMusicView {
var lyricsLineView: some View {
let line = musicManager.currentLyrics.trimmingCharacters(in: .whitespacesAndNewlines)
return HStack(spacing: 6) {
if !line.isEmpty {
Image(systemName: "music.note")
.font(.system(size: 11, weight: .semibold))
.foregroundColor(.white.opacity(0.7))
.symbolRenderingMode(.monochrome)
Text(line)
.font(.system(size: 11, weight: .semibold))
.foregroundColor(.white.opacity(0.88))
.lineLimit(2)
.multilineTextAlignment(.center)
.frame(maxWidth: .infinity, alignment: .center)
.padding(.horizontal, 6)
.id(line)
.transition(.asymmetric(
insertion: .move(edge: .bottom).combined(with: .opacity),
removal: .move(edge: .top).combined(with: .opacity)
))
}
}
.frame(maxWidth: .infinity, alignment: .center)
.animation(.smooth(duration: 0.32), value: line)
}
}

View file

@ -50,18 +50,6 @@ struct MinimalisticMusicPlayerView: View {
.foregroundColor(Defaults[.playerColorTinting] ? Color(nsColor: musicManager.avgColor).ensureMinimumBrightness(factor: 0.6) : .gray)
.lineLimit(1)
// Lyrics shown under the author name, same font size as author
if enableLyrics {
Text(musicManager.currentLyrics)
.font(.system(size: 10, weight: .regular))
.foregroundColor(.white.opacity(0.8))
.lineLimit(2)
.multilineTextAlignment(.leading)
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.top, 4)
.transition(.opacity)
.animation(.easeInOut(duration: 0.3), value: musicManager.currentLyrics)
}
}
.frame(width: textWidth, alignment: .leading)
@ -81,7 +69,10 @@ struct MinimalisticMusicPlayerView: View {
playbackControls
.padding(.top, 4)
// Lyrics are displayed inline under the artist name (see header area)
if enableLyrics {
lyricsView
.padding(.top, 10)
}
reminderList
}
@ -90,7 +81,6 @@ struct MinimalisticMusicPlayerView: View {
.padding(.bottom, shouldShowReminderList ? ReminderLiveActivityManager.listBottomPadding : ReminderLiveActivityManager.baselineMinimalisticBottomPadding)
.frame(maxWidth: .infinity)
.frame(height: calculateDynamicHeight(), alignment: .center)
.animation(.easeInOut(duration: 0.3), value: musicManager.currentLyrics)
}
// MARK: - TypingLyricView
@ -174,8 +164,10 @@ struct MinimalisticMusicPlayerView: View {
height += 40 + 2 // controls + top padding
// Add lyrics height if enabled in settings (reserve space even while loading)
if Defaults[.enableLyrics] {
height += 20 + 4 // lyrics + top padding
if enableLyrics {
let lyricsTopPadding: CGFloat = 10
let lyricsEstimatedHeight: CGFloat = 30
height += lyricsTopPadding + lyricsEstimatedHeight
}
// Add reminder list height if showing
@ -198,6 +190,36 @@ struct MinimalisticMusicPlayerView: View {
.animation(.easeInOut(duration: 0.18), value: shouldShowReminderList)
.environmentObject(vm)
}
private var lyricsView: some View {
let line = musicManager.currentLyrics.trimmingCharacters(in: .whitespacesAndNewlines)
let transition: AnyTransition = .asymmetric(
insertion: .move(edge: .bottom).combined(with: .opacity),
removal: .move(edge: .top).combined(with: .opacity)
)
return HStack(spacing: 6) {
if !line.isEmpty {
Image(systemName: "music.note")
.font(.system(size: 12, weight: .semibold))
.foregroundColor(.white.opacity(0.7))
.symbolRenderingMode(.monochrome)
Text(line)
.font(.system(size: 12, weight: .semibold))
.foregroundColor(.white.opacity(0.88))
.lineLimit(2)
.multilineTextAlignment(.leading)
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.trailing, 6)
.id(line)
.transition(transition)
}
}
.padding(.horizontal, 6)
.frame(maxWidth: .infinity, alignment: .leading)
.animation(.smooth(duration: 0.32), value: line)
}
private struct MinimalisticReminderEventListView: View {

View file

@ -157,6 +157,11 @@ struct MusicControlsView: View {
.fontWeight(.medium)
// Lyrics shown under the author name (same font size as author) when enabled in settings
if Defaults[.enableLyrics] {
let transition = AnyTransition.asymmetric(
insertion: .move(edge: .bottom).combined(with: .opacity),
removal: .move(edge: .top).combined(with: .opacity)
)
Text(musicManager.currentLyrics)
.font(.headline)
.foregroundColor(.white.opacity(0.8))
@ -164,8 +169,9 @@ struct MusicControlsView: View {
.multilineTextAlignment(.leading)
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.top, 2)
.transition(.opacity)
.animation(.easeInOut(duration: 0.3), value: musicManager.currentLyrics)
.id(musicManager.currentLyrics)
.transition(transition)
.animation(.easeInOut(duration: 0.32), value: musicManager.currentLyrics)
}
}
}