47 lines
1.8 KiB
Swift
47 lines
1.8 KiB
Swift
|
|
import SwiftUI
|
||
|
|
|
||
|
|
struct MusicActivityCard: View {
|
||
|
|
let state: MusicActivityAttributes.ContentState
|
||
|
|
let stale: Bool
|
||
|
|
var body: some View {
|
||
|
|
VStack(alignment: .leading, spacing: 10) {
|
||
|
|
HStack(spacing: 12) {
|
||
|
|
Image(systemName: "waveform").font(.title).foregroundStyle(.indigo)
|
||
|
|
TrackLabels(state: state)
|
||
|
|
Spacer(minLength: 0)
|
||
|
|
Image(systemName: state.playing ? "play.fill" : "pause.fill")
|
||
|
|
.accessibilityLabel("Последнее состояние: " + (state.playing ? "воспроизведение" : "пауза"))
|
||
|
|
}
|
||
|
|
ProgressView(value: state.progress).tint(.indigo)
|
||
|
|
ActivityStatus(state: state, stale: stale)
|
||
|
|
Label("Открыть плеер", systemImage: "arrow.up.forward.app").font(.caption.weight(.semibold))
|
||
|
|
}.padding(16)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
struct TrackLabels: View {
|
||
|
|
let state: MusicActivityAttributes.ContentState
|
||
|
|
var body: some View {
|
||
|
|
VStack(alignment: .leading, spacing: 3) {
|
||
|
|
Text(state.title).font(.headline).lineLimit(1)
|
||
|
|
Text(state.artist.isEmpty ? "MusicBridge · музыка на ПК" : state.artist)
|
||
|
|
.font(.caption).foregroundStyle(.secondary).lineLimit(1)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
struct ActivityStatus: View {
|
||
|
|
let state: MusicActivityAttributes.ContentState
|
||
|
|
let stale: Bool
|
||
|
|
var body: some View {
|
||
|
|
if stale || !state.connected {
|
||
|
|
Text("Данные устарели · откройте плеер").font(.caption).foregroundStyle(.secondary)
|
||
|
|
} else {
|
||
|
|
HStack(spacing: 4) {
|
||
|
|
Text("Снимок с ПК в")
|
||
|
|
Text(state.updatedAt, style: .time)
|
||
|
|
}.font(.caption).foregroundStyle(.secondary)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|