Initial Commit

This commit is contained in:
2026-03-27 09:21:41 +01:00
commit e9b6412d71
40 changed files with 6801 additions and 0 deletions
@@ -0,0 +1,132 @@
//
// EnhancedPlayerPickerView.swift
// Mobile Music Assistant
//
// Created by Sven Hanold on 26.03.26.
//
import SwiftUI
enum PlayerSelection {
case localPlayer
case remotePlayer(MAPlayer)
}
struct EnhancedPlayerPickerView: View {
@Environment(\.dismiss) private var dismiss
let players: [MAPlayer]
let supportsLocalPlayback: Bool
let onSelect: (PlayerSelection) -> Void
var body: some View {
NavigationStack {
List {
// Local iPhone Player
if supportsLocalPlayback {
Section {
Button {
onSelect(.localPlayer)
dismiss()
} label: {
HStack {
Image(systemName: "iphone")
.foregroundStyle(.blue)
VStack(alignment: .leading, spacing: 4) {
Text("This iPhone")
.font(.headline)
.foregroundStyle(.primary)
Text("Play directly on this device")
.font(.caption)
.foregroundStyle(.secondary)
}
Spacer()
Image(systemName: "chevron.right")
.foregroundStyle(.secondary)
.font(.caption)
}
}
} header: {
Text("Local Playback")
}
}
// Remote Players
if !players.isEmpty {
Section {
ForEach(players) { player in
Button {
onSelect(.remotePlayer(player))
dismiss()
} label: {
HStack {
VStack(alignment: .leading, spacing: 4) {
Text(player.name)
.font(.headline)
.foregroundStyle(.primary)
HStack(spacing: 6) {
Image(systemName: stateIcon(for: player.state))
.foregroundStyle(stateColor(for: player.state))
.font(.caption)
Text(player.state.rawValue.capitalized)
.font(.caption)
.foregroundStyle(.secondary)
}
}
Spacer()
Image(systemName: "chevron.right")
.foregroundStyle(.secondary)
.font(.caption)
}
}
.disabled(!player.available)
}
} header: {
Text("Remote Players")
}
}
}
.navigationTitle("Play on...")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button("Cancel") {
dismiss()
}
}
}
}
}
private func stateIcon(for state: PlayerState) -> String {
switch state {
case .playing: return "play.circle.fill"
case .paused: return "pause.circle.fill"
case .idle: return "stop.circle"
case .off: return "power.circle"
}
}
private func stateColor(for state: PlayerState) -> Color {
switch state {
case .playing: return .green
case .paused: return .orange
case .idle: return .gray
case .off: return .red
}
}
}
#Preview {
EnhancedPlayerPickerView(
players: [],
supportsLocalPlayback: true,
onSelect: { _ in }
)
}