Skip to content

Commit 475d14a

Browse files
HarshJa1nEdwinASalcedo
authored andcommitted
fix(lyrics): constrain closed-notch lyrics width to center section
Approach 1: Horizontal marquee lyrics below closed notch. Fixes width consistency issue from PR TheBoredTeam#1048 where lyrics spanned the full notch width (album art + center + spectrum). Now lyrics are constrained to the center section width only, matching the dark notch body. Changes from original PR: - Lyrics width matches center notch section (not full width) - Use .caption2 font for compact closed state - Hide lyrics when paused or during sneakPeek/expandingView - Hide entirely when no lyrics available (no placeholder) - Smooth height animation on appear/disappear - Fix coordinator.sneakPeek API for current dev branch Co-Authored-By: EdwinASalcedo <92866752+EdwinASalcedo@users.noreply.github.com>
1 parent 6b679dd commit 475d14a

1 file changed

Lines changed: 25 additions & 18 deletions

File tree

boringNotch/ContentView.swift

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ struct ContentView: View {
430430
}
431431
return base
432432
}()
433+
433434
VStack(spacing: 0) {
434435
HStack(spacing: 0) {
435436
Image(nsImage: musicManager.albumArt)
@@ -519,7 +520,12 @@ struct ContentView: View {
519520
alignment: .center
520521
)
521522

522-
if Defaults[.enableLyricsOnClosedNotch] && !coordinator.sneakPeek.show {
523+
if Defaults[.enableLyricsOnClosedNotch]
524+
&& !coordinator.shouldShowSneakPeek(on: vm.screenUUID)
525+
&& !(coordinator.expandingView.show && coordinator.expandingView.type == .music)
526+
&& musicManager.isPlaying
527+
{
528+
let lyricsWidth: CGFloat = vm.closedNotchSize.width + -cornerRadiusInsets.closed.top
523529
TimelineView(.animation(minimumInterval: 0.25)) { timeline in
524530
let currentElapsed: Double = {
525531
guard musicManager.isPlaying else { return musicManager.elapsedTime }
@@ -533,36 +539,37 @@ struct ContentView: View {
533539
return LyricsService.shared.lyricLine(at: currentElapsed)
534540
}
535541
let trimmed = musicManager.currentLyrics.trimmingCharacters(in: .whitespacesAndNewlines)
536-
return trimmed.isEmpty ? "No lyrics found" : trimmed.replacingOccurrences(of: "\n", with: " ")
542+
return trimmed.isEmpty ? "" : trimmed.replacingOccurrences(of: "\n", with: " ")
537543
}()
538544
let isPersian = line.unicodeScalars.contains { scalar in
539545
let v = scalar.value
540546
return v >= 0x0600 && v <= 0x06FF
541547
}
542-
GeometryReader { geo in
548+
if !line.isEmpty {
543549
MarqueeText(
544550
line,
545-
font: .subheadline,
546-
color: musicManager.isFetchingLyrics ? .gray.opacity(0.7) : .gray,
547-
frameWidth: geo.size.width
548-
)
551+
font: isPersian
552+
? .custom("Vazirmatn-Regular",
553+
size: NSFont.preferredFont(forTextStyle: .caption2).pointSize)
554+
: .caption2,
555+
nsFont: .caption2,
556+
color: .gray,
557+
frameWidth: lyricsWidth - 8
558+
)
559+
.lineLimit(1)
560+
.frame(width: lyricsWidth, height: 14)
549561
}
550-
.font(isPersian ? .custom("Vazirmatn-Regular", size: NSFont.preferredFont(forTextStyle: .subheadline).pointSize) : .subheadline)
551-
.lineLimit(1)
552-
.opacity(musicManager.isPlaying ? 1 : 0)
553-
.transition(.opacity.combined(with: .move(edge: .top)))
554562
}
563+
.transition(.opacity.combined(with: .move(edge: .top)))
555564
}
556565
}
557566
.frame(
558-
// Based on width sizes from the inner HStack -> Album art + Rectangle Overlay + AudioSpectrumView
559-
// Probably a better way to calulcate that width
560-
width: scaledArtSize +
561-
(vm.closedNotchSize.width + -cornerRadiusInsets.closed.top) +
562-
(displayClosedNotchHeight - 12 + gestureProgress / 2),
563-
// Extra height to display lyrics
564-
height: Defaults[.enableLyricsOnClosedNotch] ? displayClosedNotchHeight + 16 : displayClosedNotchHeight
567+
height: (Defaults[.enableLyricsOnClosedNotch] && musicManager.isPlaying)
568+
? displayClosedNotchHeight + 14
569+
: displayClosedNotchHeight,
570+
alignment: .center
565571
)
572+
.animation(.smooth(duration: 0.3), value: musicManager.isPlaying)
566573
}
567574

568575
@ViewBuilder

0 commit comments

Comments
 (0)