iOS dev 31: folded left-align art setting, folded Duo locked upright, tab bar order stable across fold/unfold

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rootandClaude Opus 5.5 committed 2026-11-18 17:20:32 -08:00
1 parent 150e47a305
commit 1072dde293
7 files changed
+96 -27

No files matched your search

+48 -21
View File
@@ -11,28 +11,10 @@ struct RootView: View {
var body: some View {
let s = g.settings
let p = Palette.of(s.theme, s.accent)
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()
.navigationDestination(for: Route.self) { destination($0).miniPlayerRoom() }
}
.modifier(FloatingMiniPlayer())
}
.tabItem { Label(t.rawValue, systemImage: t.icon) }
.tag(BarItem.tab(t))
}
}
bar
.modifier(GlassMiniPlayerHost())
// Folded on the Duo the app stays upright (the window's trailing inset gives the Duo away).
.onGeometryChange(for: CGFloat.self) { $0.safeAreaInsets.trailing } action: { ui.sawInsets(trailing: $0, upright: vSize == .regular) }
.background(p.bg.ignoresSafeArea())
.onChange(of: ui.tabs) { _, _ in ui.ensureValidTab() }
.fullScreenCover(isPresented: Binding(get: { ui.nowPlayingOpen }, set: { ui.nowPlayingOpen = $0 })) {
@@ -53,8 +35,53 @@ struct RootView: View {
.tint(p.accent)
}
@Environment(\.verticalSizeClass) private var vSize
private enum BarItem: Hashable { case deck, tab(Tab) }
private var selection: Binding<BarItem> {
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. On iOS 18 every item stays in
/// the bar and only hides, so folding and unfolding can't shuffle the order.
@ViewBuilder private var bar: some View {
if #available(iOS 18, *) {
let shown = ui.tabs
TabView(selection: selection) {
SwiftUI.Tab("Now Playing", systemImage: "waveform", value: BarItem.deck) { DuoPane { NowPlayingDeck() } }
.hidden(!ui.hasDeckTab)
ForEach(Tab.layout(g.settings.tabLayout), id: \.self) { t in
SwiftUI.Tab(t.rawValue, systemImage: t.icon, value: BarItem.tab(t)) { page(t) }
.hidden(!shown.contains(t))
}
}
} else {
TabView(selection: selection) {
if ui.hasDeckTab {
DuoPane { NowPlayingDeck() }
.tabItem { Label("Now Playing", systemImage: "waveform") }
.tag(BarItem.deck)
}
ForEach(ui.tabs, id: \.self) { t in
page(t).tabItem { Label(t.rawValue, systemImage: t.icon) }.tag(BarItem.tab(t))
}
}
}
}
private func page(_ t: Tab) -> some View {
DuoPane {
NavigationStack(path: ui.path(t)) {
root(t).miniPlayerRoom()
.navigationDestination(for: Route.self) { destination($0).miniPlayerRoom() }
}
.modifier(FloatingMiniPlayer())
}
}
@ViewBuilder private func root(_ t: Tab) -> some View {
switch t {
case .Library: LibraryHome()