iOS Duo: system tab bar instead of the rail, lyrics in the deck, stems fit, DEV banner

Split panes live inside each tab so the system's vertical bar is never covered.
Docked Now Playing no longer opens its own queue; the deck's queue scrolls under the stems.
Meters run full colour over a dimmed fill. Folded mixer rows shrink to fit every stem,
preset chips fall back to a menu instead of being cut off. Dev builds show DEV BUILD <n>.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rootandClaude Opus 5.5 committed 2026-11-18 14:11:22 -08:00
1 parent aa7cfe6c67
commit bc30b43eb1
5 files changed
+236 -169

No files matched your search

+64 -84
View File
@@ -2,41 +2,35 @@ import SwiftUI
import UIKit
/// The tab bar, a navigation stack per tab, the mini player and the Now Playing sheet.
/// On an unfolded iPhone Duo Now Playing takes one side of the hinge, the stems and queue (or a tab)
/// the other, and the tabs move to a rail on the right edge beside the status bar.
/// On an unfolded iPhone Duo each tab splits at the hinge: Now Playing docks on one side, the tab
/// (or the stems, queue and lyrics deck) on the other, and the tabs stay in the system's own bar.
struct RootView: View {
@State private var ui = Ui(overlays: Overlays())
/// Unfolded iPhone Duo: Now Playing on the left of the hinge instead of the right.
@AppStorage("duoSwap") private var duoSwap = false
private var g: AppGraph { .shared }
var body: some View {
let s = g.settings
let p = Palette.of(s.theme, s.accent)
DuoSplit(swap: duoSwap, showDeck: ui.deck, onSplit: { ui.setSplit($0) }) {
TabView(selection: Binding(get: { ui.tab }, set: { ui.selectTab($0) })) {
ForEach(Tab.layout(s.tabLayout), id: \.self) { t in
NavigationStack(path: ui.path(t)) {
root(t).miniPlayerRoom()
.navigationDestination(for: Route.self) { destination($0).miniPlayerRoom() }
DuoPane {
NavigationStack(path: ui.path(t)) {
root(t).miniPlayerRoom()
.navigationDestination(for: Route.self) { destination($0).miniPlayerRoom() }
}
.modifier(FloatingMiniPlayer())
}
.modifier(FloatingMiniPlayer())
.tabItem { Label(t.rawValue, systemImage: t.icon) }
.tag(t)
}
}
.modifier(GlassMiniPlayerHost())
} deck: {
NowPlayingDeck()
} docked: {
NowPlayingScreen(docked: true)
} rail: {
DuoRail(swap: $duoSwap)
}
.background(p.bg.ignoresSafeArea())
.devBanner()
.onChange(of: s.tabLayout) { _, _ in ui.ensureValidTab() }
.fullScreenCover(isPresented: Binding(get: { ui.nowPlayingOpen }, set: { ui.nowPlayingOpen = $0 })) {
NowPlayingScreen()
.devBanner()
.overlayHost(ui.overlays, level: 1)
.environment(ui)
.environment(\.palette, p)
@@ -142,8 +136,20 @@ private struct MiniPlayerRoom: ViewModifier {
content.safeAreaInset(edge: .bottom, spacing: 0) {
if !glassAccessory && !ui.split && g.playback.current != nil { Color.clear.frame(height: 66) }
}
// Split, the rail stands in for the tab bar.
.toolbar(ui.split ? .hidden : .automatic, for: .tabBar)
.modifier(PaneToolbar())
}
}
/// Split, each pane is phone-sized, so its nav bar stays across the top instead of moving into
/// the Duo's vertical bar (the tab bar still goes there).
private struct PaneToolbar: ViewModifier {
@Environment(Ui.self) private var ui
func body(content: Content) -> some View {
if #available(iOS 27.1, *) {
content.toolbarVerticalBehavior(ui.split ? .disabled : .automatic)
} else {
content
}
}
}
@@ -151,56 +157,44 @@ private extension View {
func miniPlayerRoom() -> some View { modifier(MiniPlayerRoom()) }
}
/// Splits the screen at the iPhone Duo's hinge (the system's division region). [library] (with
/// [deck] over it while [showDeck]) goes on one side and [docked] on the other, left and right
/// trading places with [swap]; [rail] runs down the right edge in the status bar's strip.
/// Anywhere without a hinge it's just [library]. The library stays put in the view tree, so its
/// tab and scroll state survive folding, unfolding and swapping.
private struct DuoSplit<Library: View, Deck: View, Docked: View, Rail: View>: View {
var swap: Bool
var showDeck: Bool
var onSplit: (Bool) -> Void
@ViewBuilder var library: Library
@ViewBuilder var deck: Deck
@ViewBuilder var docked: Docked
@ViewBuilder var rail: Rail
private static var railWidth: CGFloat { 64 }
/// 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
/// 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.
private struct DuoPane<Content: View>: View {
@ViewBuilder var content: Content
@Environment(Ui.self) private var ui
@AppStorage("duoSwap") private var swap = false
private var g: AppGraph { .shared }
var body: some View {
GeometryReader { geo in
let cut = Self.cut(geo)
let inset = geo.safeAreaInsets.trailing
// The rail lives in the status bar's strip; if that's too thin it borrows from the right pane.
let steal = cut == nil ? 0 : max(0, Self.railWidth - inset)
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 {
library
if cut != nil && showDeck { deck.transition(.opacity) }
content
if deck { NowPlayingDeck().transition(.opacity) }
}
.environment(\.layoutDirection, .leftToRight)
.frame(width: cut.map { $0.vertical ? (flip ? $0.second - steal : $0.first) : geo.size.width - steal } ?? geo.size.width,
.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)
if let cut {
docked
NowPlayingScreen(docked: true)
.environment(\.layoutDirection, .leftToRight)
.frame(width: cut.vertical ? (flip ? cut.first : cut.second - steal) : geo.size.width - steal,
.frame(width: cut.vertical ? (flip ? cut.first : cut.second) : geo.size.width,
height: cut.vertical ? geo.size.height : cut.second)
}
}
// Right-to-left lays the same two children out mirrored, so swapping doesn't rebuild either.
.environment(\.layoutDirection, flip ? .rightToLeft : .leftToRight)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
.overlay(alignment: .topTrailing) {
if cut != nil {
rail.frame(width: max(inset, Self.railWidth), height: geo.size.height).offset(x: inset)
}
}
.animation(.spring(duration: 0.4, bounce: 0.1), value: flip)
.animation(.easeInOut(duration: 0.2), value: showDeck)
.onChange(of: cut != nil, initial: true) { _, on in onSplit(on) }
.animation(.easeInOut(duration: 0.2), value: deck)
.onChange(of: cut != nil, initial: true) { _, on in ui.setSplit(on) }
}
}
@@ -217,7 +211,7 @@ private struct DuoSplit<Library: View, Deck: View, Docked: View, Rail: View>: Vi
c = vertical
? Cut(vertical: true, first: r.minX, gap: r.width, second: size.width - r.maxX)
: Cut(vertical: false, first: r.minY, gap: r.height, second: size.height - r.maxY)
} else if UIDevice.current.userInterfaceIdiom == .phone, size.width >= 760, size.height >= 560 {
} else if UIDevice.current.userInterfaceIdiom == .phone, size.width >= 700, size.height >= 500 {
// No region reported: only an unfolded Duo gives an iPhone this much room both ways.
// The hinge sits at the middle of the screen, not of the safe area, so place it from there.
let screenW = (UIApplication.shared.connectedScenes.first as? UIWindowScene)?.screen.bounds.width
@@ -230,42 +224,28 @@ private struct DuoSplit<Library: View, Deck: View, Docked: View, Rail: View>: Vi
}
}
/// The tab bar's stand-in on an unfolded iPhone Duo: Now Playing's stems and queue, the tabs, and
/// a button that swaps which side of the hinge Now Playing sits on.
private struct DuoRail: View {
@Binding var swap: Bool
@Environment(Ui.self) private var ui
@Environment(\.palette) private var p
var body: some View {
// Sits at the bottom of the strip: the top is where the panes' back buttons and the
// status bar live, and the tabs used to land right on them.
VStack(spacing: 4) {
Spacer(minLength: 160)
item("Playing", "waveform", on: ui.deck) { ui.showDeck() }
ForEach(ui.tabs, id: \.self) { t in
item(t.rawValue, t.icon, on: !ui.deck && ui.tab == t) { ui.selectTab(t) }
/// Dev builds only: a strip over the app with the build number, so they're never mistaken for release.
private struct DevBanner: ViewModifier {
private static let label: String? = {
let info = Bundle.main.infoDictionary
guard info?["StemifyChannel"] as? String == "dev" else { return nil }
let v = info?["StemifyVersionLabel"] as? String ?? ""
let b = info?["CFBundleVersion"] as? String ?? ""
return "DEV BUILD \(b) · \(v)"
}()
func body(content: Content) -> some View {
if let label = Self.label {
content.safeAreaInset(edge: .top, spacing: 0) {
Text(label).font(.caption2.weight(.bold)).foregroundStyle(.black)
.frame(maxWidth: .infinity).frame(height: 16)
.background(Color.orange)
}
Capsule().fill(p.label3.opacity(0.4)).frame(width: 24, height: 2).padding(.vertical, 8)
item("Swap", "arrow.left.arrow.right", on: false) { swap.toggle() }
} else {
content
}
.padding(.bottom, 20)
.frame(maxWidth: .infinity)
}
private func item(_ title: String, _ icon: String, on: Bool, _ action: @escaping () -> Void) -> some View {
Button { withAnimation(.snappy(duration: 0.25)) { action() } } label: {
VStack(spacing: 3) {
Image(systemName: icon).font(.system(size: 19, weight: on ? .semibold : .regular)).frame(height: 24)
Text(title).font(.system(size: 10, weight: .medium)).lineLimit(1).minimumScaleFactor(0.7)
}
.foregroundStyle(on ? p.accent : p.label2)
.frame(width: 56, height: 52)
.background(on ? p.accent.opacity(0.14) : .clear, in: RoundedRectangle(cornerRadius: 12, style: .continuous))
.contentShape(Rectangle())
}
.buttonStyle(PressFade())
.accessibilityLabel(title)
.accessibilityAddTraits(on ? .isSelected : [])
}
}
extension View {
func devBanner() -> some View { modifier(DevBanner()) }
}