70 lines
2.1 KiB
Swift
70 lines
2.1 KiB
Swift
//
|
|
// NowPlayingMiniView.swift
|
|
// QueueCube
|
|
//
|
|
// Created by James Magahern on 6/11/25.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct NowPlayingMiniView: View {
|
|
@Binding var model: NowPlayingViewModel
|
|
let onTap: () -> Void
|
|
|
|
@GestureState private var tapGestureState = false
|
|
|
|
private var nothingQueued: Bool {
|
|
guard let title = model.title, let subtitle = model.subtitle else { return true }
|
|
return title.isEmpty && subtitle.isEmpty
|
|
}
|
|
|
|
var body: some View {
|
|
let playPauseImageName = model.isPlaying ? "pause.fill" : "play.fill"
|
|
let tapGesture = DragGesture(minimumDistance: 0)
|
|
.updating($tapGestureState) { _, state, _ in
|
|
state = true
|
|
}
|
|
.onEnded { _ in
|
|
onTap()
|
|
}
|
|
|
|
HStack {
|
|
VStack(alignment: .leading) {
|
|
if let title = model.title, !title.isEmpty {
|
|
Text(title)
|
|
.font(.caption)
|
|
.lineLimit(1)
|
|
.bold()
|
|
}
|
|
|
|
if let subtitle = model.subtitle, !subtitle.isEmpty {
|
|
Text(subtitle)
|
|
.lineLimit(1)
|
|
.font(.caption)
|
|
.foregroundStyle(.secondary)
|
|
}
|
|
|
|
if nothingQueued {
|
|
Text(.notPlaying)
|
|
.font(.caption)
|
|
.foregroundStyle(.secondary)
|
|
}
|
|
}
|
|
|
|
Spacer()
|
|
|
|
Button(action: { model.onPlayPause(model) }) { Image(systemName: playPauseImageName) }
|
|
.imageScale(.large)
|
|
.padding(12.0)
|
|
}
|
|
.padding(EdgeInsets(top: 4.0, leading: 14.0, bottom: 4.0, trailing: 10.0))
|
|
.background(
|
|
RoundedRectangle(cornerRadius: 12)
|
|
.fill(tapGestureState ? .ultraThinMaterial : .bar)
|
|
.stroke(.ultraThinMaterial, lineWidth: 1.0)
|
|
)
|
|
.shadow(color: .black.opacity(0.15), radius: 14.0, y: 2.0)
|
|
.gesture(tapGesture)
|
|
}
|
|
}
|