Duo deck: Now Playing tab, full-pane Stems / Lyrics / Playing Next / EQ pages
Unfolded with something playing, the tab bar leads with a Now Playing item that shows the deck beside docked Now Playing. Each deck page gets the whole pane; the queue moved to its own page and a vertical graphic EQ page was added. Dev build 27. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
190b793043
commit
4ddcfd7ff5
5 files changed
+166
-49
No files matched your search
@@ -36,6 +36,19 @@ enum Tab: String, CaseIterable, Hashable {
|
||||
}
|
||||
}
|
||||
|
||||
/// The pages of the deck beside docked Now Playing on an unfolded iPhone Duo.
|
||||
enum DeckPage: String, CaseIterable, Hashable {
|
||||
case Stems, Lyrics, Queue, Eq
|
||||
var title: String {
|
||||
switch self {
|
||||
case .Stems: "Stems"
|
||||
case .Lyrics: "Lyrics"
|
||||
case .Queue: "Playing Next"
|
||||
case .Eq: "EQ"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum Route: Hashable {
|
||||
case Artists, Albums, Songs, RecentlyAdded, Playlists, Genres, Downloads, DownloadQueue, TabBar, WebRadio
|
||||
case Eq, EqFilters(profileId: String), EqFilterPage(profileId: String, filterId: String)
|
||||
@@ -54,10 +67,10 @@ final class Ui {
|
||||
}
|
||||
/// True while an unfolded iPhone Duo shows Now Playing docked beside the library.
|
||||
private(set) var split = false
|
||||
/// Split only: the side opposite Now Playing shows the stems and queue (true) or the selected tab.
|
||||
/// Split only: the Now Playing tab (the deck) is selected instead of `tab`.
|
||||
var deck = true
|
||||
/// Split only: the deck shows the lyrics (karaoke) instead of the stems and queue.
|
||||
var deckLyrics = false
|
||||
/// Split only: which of the deck's pages is showing.
|
||||
var deckPage: DeckPage = .Stems
|
||||
let overlays: Overlays
|
||||
|
||||
init(overlays: Overlays) { self.overlays = overlays }
|
||||
@@ -72,12 +85,21 @@ final class Ui {
|
||||
|
||||
/// Tapping the selected tab again pops it to its root.
|
||||
func selectTab(_ t: Tab) {
|
||||
if split && deck { deck = false; tab = t; return }
|
||||
if showsDeck { deck = false; tab = t; return }
|
||||
if t == tab { paths[t] = [] } else { tab = t }
|
||||
}
|
||||
|
||||
/// The tabs currently in the bar, in order.
|
||||
var tabs: [Tab] { Tab.layout(AppGraph.shared.settings.tabLayout) }
|
||||
/// Split with something playing, the bar leads with a Now Playing item that opens the deck.
|
||||
var hasDeckTab: Bool { split && AppGraph.shared.playback.current != nil }
|
||||
var showsDeck: Bool { hasDeckTab && deck }
|
||||
|
||||
/// The tabs currently in the bar, in order. The Now Playing item takes one of the five places
|
||||
/// (iOS folds a sixth into "More"), so the last one before Settings steps aside for it.
|
||||
var tabs: [Tab] {
|
||||
var t = Tab.layout(AppGraph.shared.settings.tabLayout)
|
||||
if hasDeckTab && t.count >= Tab.maxVisible, let i = t.lastIndex(where: { $0 != .Settings }) { t.remove(at: i) }
|
||||
return t
|
||||
}
|
||||
|
||||
/// Where library pages open: Library if it's in the bar, else the first tab that is.
|
||||
private var home: Tab { tabs.contains(.Library) ? .Library : (tabs.first ?? .Settings) }
|
||||
@@ -96,7 +118,7 @@ final class Ui {
|
||||
func openNowPlaying() { if !split { nowPlayingOpen = true } }
|
||||
|
||||
/// Split only: brings the stems and queue (or the lyrics) back beside Now Playing.
|
||||
func showDeck(lyrics: Bool = false) { deck = true; deckLyrics = lyrics }
|
||||
func showDeck(_ page: DeckPage? = nil) { deck = true; if let page { deckPage = page } }
|
||||
|
||||
func setSplit(_ on: Bool) {
|
||||
guard on != split else { return }
|
||||
@@ -107,7 +129,7 @@ final class Ui {
|
||||
UserDefaults.standard.set(true, forKey: "duoSeen")
|
||||
}
|
||||
// Karaoke left on shows its lyrics in the deck.
|
||||
deckLyrics = on && AppGraph.shared.playback.karaoke
|
||||
if on && AppGraph.shared.playback.karaoke { deckPage = .Lyrics } else if deckPage == .Lyrics { deckPage = .Stems }
|
||||
}
|
||||
|
||||
/// Switches to the Library tab and pushes [r] there.
|
||||
|
||||
@@ -11,8 +11,16 @@ struct RootView: View {
|
||||
var body: some View {
|
||||
let s = g.settings
|
||||
let p = Palette.of(s.theme, s.accent)
|
||||
TabView(selection: Binding(get: { ui.tab }, set: { ui.selectTab($0) })) {
|
||||
ForEach(Tab.layout(s.tabLayout), id: \.self) { t in
|
||||
TabView(selection: Binding(get: { ui.showsDeck ? BarItem.deck : .tab(ui.tab) },
|
||||
set: { if case .tab(let t) = $0 { ui.selectTab(t) } else { ui.showDeck() } })) {
|
||||
// Unfolded with something playing, Now Playing leads the bar: the deck (stems, lyrics,
|
||||
// queue, EQ) on this side of the hinge, the player docked on the other.
|
||||
if ui.hasDeckTab {
|
||||
DuoPane { NowPlayingDeck() }
|
||||
.tabItem { Label("Now Playing", systemImage: "waveform") }
|
||||
.tag(BarItem.deck)
|
||||
}
|
||||
ForEach(ui.tabs, id: \.self) { t in
|
||||
DuoPane {
|
||||
NavigationStack(path: ui.path(t)) {
|
||||
root(t).miniPlayerRoom()
|
||||
@@ -21,12 +29,12 @@ struct RootView: View {
|
||||
.modifier(FloatingMiniPlayer())
|
||||
}
|
||||
.tabItem { Label(t.rawValue, systemImage: t.icon) }
|
||||
.tag(t)
|
||||
.tag(BarItem.tab(t))
|
||||
}
|
||||
}
|
||||
.modifier(GlassMiniPlayerHost())
|
||||
.background(p.bg.ignoresSafeArea())
|
||||
.onChange(of: s.tabLayout) { _, _ in ui.ensureValidTab() }
|
||||
.onChange(of: ui.tabs) { _, _ in ui.ensureValidTab() }
|
||||
.fullScreenCover(isPresented: Binding(get: { ui.nowPlayingOpen }, set: { ui.nowPlayingOpen = $0 })) {
|
||||
NowPlayingScreen()
|
||||
.overlayHost(ui.overlays, level: 1)
|
||||
@@ -45,6 +53,8 @@ struct RootView: View {
|
||||
.tint(p.accent)
|
||||
}
|
||||
|
||||
private enum BarItem: Hashable { case deck, tab(Tab) }
|
||||
|
||||
@ViewBuilder private func root(_ t: Tab) -> some View {
|
||||
switch t {
|
||||
case .Library: LibraryHome()
|
||||
@@ -156,7 +166,7 @@ private extension View {
|
||||
}
|
||||
|
||||
/// One tab's content, split at the iPhone Duo's hinge (the system's division region): the tab
|
||||
/// (with the deck over it while it's showing) on one side, docked Now Playing on the other, left
|
||||
/// (or, for the Now Playing item, the deck) on one side, docked Now Playing on the other, left
|
||||
/// and right trading places with the deck's swap button. It measures inside the tab's safe area,
|
||||
/// so the system's tab bar is never covered. Anywhere without a hinge it's just the tab, and the
|
||||
/// tab stays put in the view tree so its scroll state survives folding, unfolding and swapping.
|
||||
@@ -170,13 +180,9 @@ private struct DuoPane<Content: View>: View {
|
||||
GeometryReader { geo in
|
||||
let cut = Self.cut(geo)
|
||||
let flip = swap && cut?.vertical == true
|
||||
let deck = cut != nil && ui.deck && g.playback.current != nil
|
||||
let layout = cut?.vertical == false ? AnyLayout(VStackLayout(spacing: cut?.gap ?? 0)) : AnyLayout(HStackLayout(spacing: cut?.gap ?? 0))
|
||||
layout {
|
||||
ZStack {
|
||||
content
|
||||
if deck { NowPlayingDeck().transition(.opacity) }
|
||||
}
|
||||
content
|
||||
.environment(\.layoutDirection, .leftToRight)
|
||||
.frame(width: cut.map { $0.vertical ? (flip ? $0.second : $0.first) : geo.size.width } ?? geo.size.width,
|
||||
height: cut.map { $0.vertical ? geo.size.height : $0.first } ?? geo.size.height)
|
||||
@@ -191,7 +197,6 @@ private struct DuoPane<Content: View>: View {
|
||||
.environment(\.layoutDirection, flip ? .rightToLeft : .leftToRight)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
|
||||
.animation(.spring(duration: 0.4, bounce: 0.1), value: flip)
|
||||
.animation(.easeInOut(duration: 0.2), value: deck)
|
||||
.onChange(of: cut != nil, initial: true) { _, on in ui.setSplit(on) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,6 +202,86 @@ struct VerticalBandSlider: View {
|
||||
}
|
||||
}
|
||||
|
||||
// ---- deck EQ (unfolded iPhone Duo) ---------------------------------------------------------
|
||||
|
||||
/// The graphic EQ as a deck page: tall vertical bands that use the pane's height, with the
|
||||
/// on/off switch, profile and presets above them. Filters and devices stay in Settings.
|
||||
struct DeckEqPanel: View {
|
||||
@Environment(Ui.self) private var ui
|
||||
@Environment(\.palette) private var p
|
||||
private var g: AppGraph { .shared }
|
||||
|
||||
var body: some View {
|
||||
let eq = g.eq
|
||||
let state = eq.state
|
||||
VStack(spacing: 14) {
|
||||
HStack(spacing: 10) {
|
||||
Toggle("Equalizer", isOn: Binding(get: { state.enabled }, set: { eq.setEnabled($0) }))
|
||||
.labelsHidden().tint(Color(hex: 0x34C759))
|
||||
if let pr = eq.active {
|
||||
Menu {
|
||||
Section("Profile") {
|
||||
ForEach(state.profiles, id: \.id) { x in
|
||||
Button { eq.select(x.id) } label: {
|
||||
if x.id == pr.id { Label(x.name, systemImage: "checkmark") } else { Text(x.name) }
|
||||
}
|
||||
}
|
||||
}
|
||||
Section("Load Preset") {
|
||||
ForEach(EQ_PRESETS, id: \.0) { name, gains in Button(name) { eq.setGains(pr.id, gains) } }
|
||||
}
|
||||
} label: {
|
||||
HStack(spacing: 4) {
|
||||
Text(pr.name).lineLimit(1)
|
||||
Image(systemName: "chevron.up.chevron.down").font(.caption.weight(.semibold))
|
||||
}
|
||||
.font(.subheadline.weight(.semibold)).foregroundStyle(p.label)
|
||||
.padding(.horizontal, 12).frame(height: 32)
|
||||
.background(p.fill, in: Capsule())
|
||||
}
|
||||
}
|
||||
Spacer(minLength: 0)
|
||||
Button { ui.showInSettings(.Eq) } label: {
|
||||
Text("More").font(.subheadline.weight(.semibold)).foregroundStyle(p.label2)
|
||||
.padding(.horizontal, 12).frame(height: 32).background(p.fill, in: Capsule())
|
||||
}
|
||||
.buttonStyle(PressFade())
|
||||
}
|
||||
if let pr = eq.active {
|
||||
let preamp = effectivePreamp(pr)
|
||||
EqCurve(chain: pr.chain, preampDb: preamp, enabled: state.enabled, range: EQ_MAX_DB + 3, bandMarkers: true)
|
||||
.frame(height: 72)
|
||||
HStack(spacing: 0) {
|
||||
ForEach(EQ_BANDS.indices, id: \.self) { i in
|
||||
let v = pr.gains[i]
|
||||
VStack(spacing: 6) {
|
||||
Text(db(v)).font(.caption2.monospacedDigit()).foregroundStyle(abs(v) > 0.05 ? p.accent : p.label2)
|
||||
.lineLimit(1).fixedSize()
|
||||
VerticalBandSlider(value: v / EQ_MAX_DB) { eq.setGain(pr.id, band: i, db: round1($0 * EQ_MAX_DB)) }
|
||||
.frame(maxHeight: .infinity)
|
||||
Text(EQ_LABELS[i]).font(.caption2).foregroundStyle(p.label2)
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
}
|
||||
.frame(maxHeight: .infinity)
|
||||
.opacity(state.enabled ? 1 : 0.5)
|
||||
HStack {
|
||||
Text("Preamp").foregroundStyle(p.label2)
|
||||
Spacer()
|
||||
Text(abs(preamp) < 0.05 ? "off" : "\(db(preamp)) dB").monospacedDigit().foregroundStyle(p.label2)
|
||||
}
|
||||
.font(.subheadline)
|
||||
} else {
|
||||
Text("No EQ profile yet. Make one in Settings.").font(.subheadline).foregroundStyle(p.label2)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 24).padding(.top, 8).padding(.bottom, 12)
|
||||
.onAppear { eq.refreshRoute() }
|
||||
}
|
||||
}
|
||||
|
||||
// ---- main EQ screen -------------------------------------------------------------------------
|
||||
|
||||
struct EqScreen: View {
|
||||
|
||||
@@ -248,9 +248,9 @@ struct NowPlayingScreen: View {
|
||||
.padding(.top, tight ? 4 : 14)
|
||||
HStack {
|
||||
let hidden = NowPlayingButton.hidden(g.settings.hiddenNowPlaying)
|
||||
if !hidden.contains(.Mixer) { PanelToggle(symbol: "slider.vertical.3", on: docked ? ui.deck && !ui.deckLyrics : panel == .Mixer) { show(.Mixer) } }
|
||||
if !hidden.contains(.Mixer) { PanelToggle(symbol: "slider.vertical.3", on: docked ? ui.showsDeck && ui.deckPage == .Stems : panel == .Mixer) { show(.Mixer) } }
|
||||
if !hidden.contains(.Speed) { SpeedMenu() }
|
||||
if !hidden.contains(.Route) { Button { ui.showInSettings(.Eq) } label: { routeLabel(c) }.buttonStyle(PressFade()).frame(maxWidth: .infinity) } else { Spacer() }
|
||||
if !hidden.contains(.Route) { Button { if docked { withAnimation(.snappy) { ui.showDeck(.Eq) } } else { ui.showInSettings(.Eq) } } label: { routeLabel(c) }.buttonStyle(PressFade()).frame(maxWidth: .infinity) } else { Spacer() }
|
||||
if !hidden.contains(.AirPlay) { AirPlayButton(tint: UIColor(c.label2), active: UIColor(c.accent)).frame(width: 40, height: 40) }
|
||||
if !hidden.contains(.Karaoke) { PanelToggle(symbol: "music.mic", on: pm.karaoke) { karaoke() } }
|
||||
}
|
||||
@@ -276,9 +276,9 @@ struct NowPlayingScreen: View {
|
||||
// Docked, the lyrics get the deck's whole side of the hinge.
|
||||
if docked {
|
||||
withAnimation(.snappy(duration: 0.25)) {
|
||||
if pm.karaoke && !(ui.deck && ui.deckLyrics) { ui.showDeck(lyrics: true); return }
|
||||
if pm.karaoke && !(ui.showsDeck && ui.deckPage == .Lyrics) { ui.showDeck(.Lyrics); return }
|
||||
pm.setKaraoke(!pm.karaoke)
|
||||
ui.showDeck(lyrics: pm.karaoke)
|
||||
ui.showDeck(pm.karaoke ? .Lyrics : .Stems)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -292,7 +292,7 @@ struct NowPlayingScreen: View {
|
||||
private func show(_ to: NpPanel) {
|
||||
// Docked, the stems and the queue have the other side of the hinge to themselves.
|
||||
// The queue lives only in the deck there, never a second copy beside it.
|
||||
if docked { if to == .Mixer { withAnimation(.snappy) { ui.showDeck() } }; return }
|
||||
if docked { if to == .Mixer { withAnimation(.snappy) { ui.showDeck(.Stems) } }; return }
|
||||
withAnimation(.spring(duration: 0.38, bounce: 0.12)) { panel = panel == to ? .Art : to }
|
||||
}
|
||||
|
||||
@@ -1005,8 +1005,8 @@ struct FaderSlider: View {
|
||||
|
||||
// ---- deck -----------------------------------------------------------------------------------
|
||||
|
||||
/// Unfolded iPhone Duo: the stems over the queue, or the lyrics, on the other side of the hinge
|
||||
/// from Now Playing. The stems stay put and the queue scrolls in what's left under them.
|
||||
/// Unfolded iPhone Duo: the Now Playing tab's side of the hinge, across from docked Now Playing.
|
||||
/// One page at a time (stems, lyrics, the queue or the EQ), each with the whole pane to itself.
|
||||
struct NowPlayingDeck: View {
|
||||
@Environment(Ui.self) private var ui
|
||||
@Environment(\.palette) private var base
|
||||
@@ -1017,21 +1017,20 @@ struct NowPlayingDeck: View {
|
||||
var body: some View {
|
||||
let c = tint.map { base.tinted($0) } ?? base
|
||||
let track = g.playback.current?.track
|
||||
GeometryReader { geo in
|
||||
GeometryReader { _ in
|
||||
if let track {
|
||||
VStack(spacing: 0) {
|
||||
header(c)
|
||||
if ui.deckLyrics {
|
||||
LyricsPanel(track: track).frame(maxHeight: .infinity)
|
||||
} else {
|
||||
let n = max(g.playback.stemNames.count, 1)
|
||||
// Every stem without scrolling comes first; the queue scrolls in whatever is left.
|
||||
let fit = MixerPanel.roomyChrome + CGFloat(n) * MixerPanel.roomyMin + 8
|
||||
let mixH = min(max(fit, min(MixerPanel.roomyHeight(n), geo.size.height - 260)), geo.size.height - 36)
|
||||
MixerPanel(roomy: true).frame(height: max(mixH, 0))
|
||||
Rectangle().fill(c.label3.opacity(0.35)).frame(height: 0.5).padding(.horizontal, 24).padding(.bottom, 4)
|
||||
QueuePanel().frame(maxHeight: .infinity)
|
||||
Group {
|
||||
switch ui.deckPage {
|
||||
case .Stems: MixerPanel(roomy: true)
|
||||
case .Lyrics: LyricsPanel(track: track)
|
||||
case .Queue: QueuePanel(title: false)
|
||||
case .Eq: DeckEqPanel()
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
|
||||
.transition(.opacity)
|
||||
}
|
||||
} else {
|
||||
Text("Nothing Playing").font(.title3.weight(.semibold)).foregroundStyle(c.label2)
|
||||
@@ -1045,18 +1044,21 @@ struct NowPlayingDeck: View {
|
||||
.modifier(NpScheme(dark: c.dark, docked: true))
|
||||
.tint(c.label)
|
||||
.animation(.easeInOut(duration: 0.3), value: tint)
|
||||
.animation(.snappy(duration: 0.25), value: ui.deckLyrics)
|
||||
.animation(.snappy(duration: 0.25), value: ui.deckPage)
|
||||
.task(id: "\(track?.thumb ?? "")|\(g.settings.albumColorNowPlaying)|\(base.dark)") {
|
||||
guard g.settings.albumColorNowPlaying, let thumb = track?.thumb else { tint = nil; return }
|
||||
tint = await albumColor(thumb, dark: base.dark)
|
||||
}
|
||||
}
|
||||
|
||||
/// Stems or Lyrics, and the button that moves Now Playing to the other side of the hinge.
|
||||
/// The page names, and the button that moves Now Playing to the other side of the hinge.
|
||||
private func header(_ c: Palette) -> some View {
|
||||
HStack(spacing: 18) {
|
||||
page("Stems", on: !ui.deckLyrics, c) { ui.showDeck(lyrics: false) }
|
||||
page("Lyrics", on: ui.deckLyrics, c) { ui.showDeck(lyrics: true) }
|
||||
ViewThatFits(in: .horizontal) {
|
||||
pages(c, spacing: 22)
|
||||
pages(c, spacing: 14)
|
||||
ScrollView(.horizontal) { pages(c, spacing: 18) }.scrollIndicators(.hidden)
|
||||
}
|
||||
Spacer(minLength: 0)
|
||||
Button { withAnimation(.spring(duration: 0.4, bounce: 0.1)) { swap.toggle() } } label: {
|
||||
Image(systemName: "arrow.left.arrow.right").font(.body.weight(.semibold)).foregroundStyle(c.label2)
|
||||
@@ -1068,12 +1070,18 @@ struct NowPlayingDeck: View {
|
||||
.padding(.horizontal, 24).frame(height: 36)
|
||||
}
|
||||
|
||||
private func page(_ title: String, on: Bool, _ c: Palette, _ action: @escaping () -> Void) -> some View {
|
||||
Button(action: action) {
|
||||
Text(title).font(.headline).foregroundStyle(on ? c.label : c.label3)
|
||||
private func pages(_ c: Palette, spacing: CGFloat) -> some View {
|
||||
HStack(spacing: spacing) {
|
||||
ForEach(DeckPage.allCases, id: \.self) { pg in
|
||||
let on = ui.deckPage == pg
|
||||
Button { withAnimation(.snappy(duration: 0.25)) { ui.showDeck(pg) } } label: {
|
||||
Text(pg.title).font(.headline).foregroundStyle(on ? c.label : c.label3)
|
||||
.lineLimit(1).fixedSize().frame(minHeight: 36).contentShape(Rectangle())
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.accessibilityAddTraits(on ? .isSelected : [])
|
||||
}
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.accessibilityAddTraits(on ? .isSelected : [])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1081,6 +1089,8 @@ struct NowPlayingDeck: View {
|
||||
|
||||
private struct QueuePanel: View {
|
||||
var close: () -> Void = {}
|
||||
/// The deck's header already says "Playing Next", so there it shows just the count.
|
||||
var title = true
|
||||
@Environment(\.palette) private var p
|
||||
private var g: AppGraph { .shared }
|
||||
|
||||
@@ -1091,8 +1101,8 @@ private struct QueuePanel: View {
|
||||
VStack(spacing: 0) {
|
||||
HStack(spacing: 8) {
|
||||
VStack(alignment: .leading, spacing: 1) {
|
||||
Text("Playing Next").font(.headline).foregroundStyle(p.label)
|
||||
Text(songs(upcoming.count)).font(.footnote).foregroundStyle(p.label2)
|
||||
if title { Text("Playing Next").font(.headline).foregroundStyle(p.label) }
|
||||
Text(songs(upcoming.count)).font(title ? .footnote : .subheadline).foregroundStyle(p.label2)
|
||||
}
|
||||
Spacer()
|
||||
QueueToggle(symbol: "shuffle", on: pm.shuffle, action: pm.toggleShuffle)
|
||||
|
||||
Reference in new issue
Block a user