mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-28 23:54:32 +00:00
added lyrics feature
This commit is contained in:
parent
0d61a4024f
commit
13e60c5211
8 changed files with 464 additions and 47 deletions
|
|
@ -9,42 +9,73 @@
|
|||
import SwiftUI
|
||||
import Defaults
|
||||
|
||||
// Note: lyrics display is inlined into the main minimalistic view below and is controlled by Defaults[.enableLyrics]
|
||||
|
||||
struct MinimalisticMusicView: View {
|
||||
@EnvironmentObject var vm: DynamicIslandViewModel
|
||||
@ObservedObject var musicManager = MusicManager.shared
|
||||
@Default(.enableLyrics) var enableLyrics
|
||||
@State private var isHovering: Bool = false
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 0) {
|
||||
// Left: Album Art
|
||||
albumArtView
|
||||
|
||||
// Middle: Song Title (scrolling if needed)
|
||||
Rectangle()
|
||||
.fill(.black)
|
||||
.overlay(
|
||||
GeometryReader { geo in
|
||||
HStack(alignment: .center) {
|
||||
if !musicManager.songTitle.isEmpty {
|
||||
MarqueeText(
|
||||
$musicManager.songTitle,
|
||||
font: .system(size: 12, weight: .semibold),
|
||||
nsFont: .subheadline,
|
||||
textColor: Defaults[.coloredSpectrogram] ? Color(nsColor: musicManager.avgColor) : Color.gray,
|
||||
minDuration: 0.4,
|
||||
frameWidth: max(0, geo.size.width - 8)
|
||||
)
|
||||
VStack(spacing: 2) {
|
||||
// Main content row
|
||||
HStack(spacing: 0) {
|
||||
// Left: Album Art
|
||||
albumArtView
|
||||
|
||||
// Middle: Song Title, Artist and Lyrics (lyrics shown under artist when enabled)
|
||||
Rectangle()
|
||||
.fill(.black)
|
||||
.overlay(
|
||||
GeometryReader { geo in
|
||||
VStack(alignment: .center, spacing: 2) {
|
||||
if !musicManager.songTitle.isEmpty {
|
||||
MarqueeText(
|
||||
$musicManager.songTitle,
|
||||
font: .system(size: 12, weight: .semibold),
|
||||
nsFont: .subheadline,
|
||||
textColor: Defaults[.coloredSpectrogram] ? Color(nsColor: musicManager.avgColor) : Color.gray,
|
||||
minDuration: 0.4,
|
||||
frameWidth: max(0, geo.size.width - 8)
|
||||
)
|
||||
}
|
||||
|
||||
// Artist name
|
||||
if !musicManager.artistName.isEmpty {
|
||||
Text(musicManager.artistName)
|
||||
.font(.system(size: 10, weight: .regular))
|
||||
.foregroundColor(Defaults[.playerColorTinting] ? Color(nsColor: musicManager.avgColor).ensureMinimumBrightness(factor: 0.6) : .gray)
|
||||
.lineLimit(1)
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
.frame(width: geo.size.width, height: geo.size.height, alignment: .center)
|
||||
}
|
||||
.frame(width: geo.size.width, height: geo.size.height, alignment: .center)
|
||||
}
|
||||
)
|
||||
.frame(width: vm.closedNotchSize.width)
|
||||
|
||||
// Right: Music Visualizer
|
||||
visualizerView
|
||||
)
|
||||
.frame(width: vm.closedNotchSize.width)
|
||||
|
||||
// Right: Music Visualizer
|
||||
visualizerView
|
||||
}
|
||||
|
||||
// (lyrics are displayed inline under the artist name)
|
||||
}
|
||||
.frame(height: vm.effectiveClosedNotchHeight + (isHovering ? 8 : 0), alignment: .center)
|
||||
// reserve extra height when lyrics are enabled
|
||||
.frame(height: vm.effectiveClosedNotchHeight + (isHovering ? 8 : 0) + (enableLyrics ? 22 : 0), alignment: .center)
|
||||
.onHover { hovering in
|
||||
isHovering = hovering
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue