iOS compact layout: canvas-first with composition panels in sheets

On narrow widths (iPhone, iPad portrait / split view) the docked desktop layout
overflowed and left the board canvas cramped. Add a size-class-gated compact
layout; regular widths (macOS, wide iPad) are unchanged.

Compact:
- Root drops the always-docked rig sidebar; it opens from a "Rigs" sheet button.
- Header keeps performance controls on screen (title, Start/Stop, Record badge,
  Bypass, Mute rig) with a scrollable row of panel toggles.
- Composition panels move to bottom sheets: Pedals (palette + routing),
  Settings (sample rate / channel counts / input source), Rigs (library).
- Board mixer, scope, CPU meters, and Tempo/Tuner stay docked above the
  full-bleed board canvas.

EngineConfigView gains a transportOnly mode (Start/Stop button only) so the
transport stays in the compact header while the config controls live in the
Settings sheet.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-04 14:33:19 -07:00
parent d07247e40e
commit 5b343a2cce
2 changed files with 256 additions and 39 deletions
@@ -42,6 +42,10 @@ public struct EngineConfigView: View {
private let hardwareSampleRate: () -> Double?
private let applyConfig: ((Double, Int, Int) throws -> Void)?
private let onConfigApplied: () -> Void
/// When `true`, renders only the Start/Stop transport button (the sample-rate / channel-count
/// controls are hidden). Used by the compact (iPhone / narrow iPad) layout, which keeps the
/// transport on screen and moves the config controls into a Settings sheet.
private let transportOnly: Bool
@State private var pendingSampleRate: Double
@State private var pendingInputs: Int
@@ -63,12 +67,14 @@ public struct EngineConfigView: View {
shoeGaze: ShoeGaze,
hardwareSampleRate: @escaping () -> Double? = { nil },
applyConfig: ((Double, Int, Int) throws -> Void)? = nil,
onConfigApplied: @escaping () -> Void = { }
onConfigApplied: @escaping () -> Void = { },
transportOnly: Bool = false
) {
self.shoeGaze = shoeGaze
self.hardwareSampleRate = hardwareSampleRate
self.applyConfig = applyConfig
self.onConfigApplied = onConfigApplied
self.transportOnly = transportOnly
_pendingSampleRate = State(initialValue: shoeGaze.engine.sampleRate)
_pendingInputs = State(initialValue: shoeGaze.engine.numInputChannels)
_pendingOutputs = State(initialValue: shoeGaze.engine.numOutputChannels)
@@ -78,35 +84,36 @@ public struct EngineConfigView: View {
public var body: some View {
_ = transportTick
let isRunning: Bool = shoeGaze.engine.isRunning
return HStack(spacing: EngineConfigView.rowSpacing) {
label("Rate")
Picker("Rate", selection: $pendingSampleRate) {
ForEach(EngineConfigView.standardRates, id: \.self) { rate in
Text("\(Int(rate)) Hz").tag(rate)
return Group {
if transportOnly {
transportButton
} else {
HStack(spacing: EngineConfigView.rowSpacing) {
label("Rate")
Picker("Rate", selection: $pendingSampleRate) {
ForEach(EngineConfigView.standardRates, id: \.self) { rate in
Text("\(Int(rate)) Hz").tag(rate)
}
}
.labelsHidden()
.pickerStyle(.menu)
.disabled(shoeGaze.engine.isRunning)
Stepper(value: $pendingInputs, in: 0...EngineConfigView.maxInputs) {
Text("In: \(pendingInputs)").foregroundStyle(Color.white)
}
.disabled(shoeGaze.engine.isRunning)
.fixedSize()
Stepper(value: $pendingOutputs, in: 1...EngineConfigView.maxOutputs) {
Text("Out: \(pendingOutputs)").foregroundStyle(Color.white)
}
.disabled(shoeGaze.engine.isRunning)
.fixedSize()
transportButton
}
}
.labelsHidden()
.pickerStyle(.menu)
.disabled(isRunning)
Stepper(value: $pendingInputs, in: 0...EngineConfigView.maxInputs) {
Text("In: \(pendingInputs)").foregroundStyle(Color.white)
}
.disabled(isRunning)
.fixedSize()
Stepper(value: $pendingOutputs, in: 1...EngineConfigView.maxOutputs) {
Text("Out: \(pendingOutputs)").foregroundStyle(Color.white)
}
.disabled(isRunning)
.fixedSize()
Button(isRunning ? "Stop" : "Start") {
if isRunning { stopEngine() } else { startEngine() }
}
.buttonStyle(.borderedProminent)
.tint(isRunning ? .red : .green)
}
.alert(alertTitle, isPresented: $showAlert) {
Button("OK", role: .cancel) { }
@@ -131,6 +138,16 @@ public struct EngineConfigView: View {
.onChange(of: pendingSampleRate) { applyConfigWhileStopped() }
}
/// The Start / Stop transport button, shared by the full and transport-only layouts.
private var transportButton: some View {
let isRunning: Bool = shoeGaze.engine.isRunning
return Button(isRunning ? "Stop" : "Start") {
if isRunning { stopEngine() } else { startEngine() }
}
.buttonStyle(.borderedProminent)
.tint(isRunning ? .red : .green)
}
/// Reconfigures the stopped engine with the pending values and notifies the host so views that
/// read non-observable engine state refresh. No-op while the engine is running.
private func applyConfigWhileStopped() {
@@ -157,6 +157,17 @@ public struct ShoeGazeBuilderView: View {
/// Help sheet presentation flag (iOS button; macOS uses the Help menu).
@State private var showHelpSheet: Bool = false
/// Compact-layout size class. `.compact` width (iPhone, iPad portrait / split view) switches to
/// the canvas-first layout where composition panels live in sheets; `.regular` keeps the docked
/// desktop-style layout. `nil` (unknown) is treated as regular.
@Environment(\.horizontalSizeClass) private var horizontalSizeClass: UserInterfaceSizeClass?
/// Compact-layout sheet flags — the composition panels docked in the regular layout become
/// bottom sheets so the board canvas gets the full screen.
@State private var showRigsSheet: Bool = false
@State private var showPaletteSheet: Bool = false
@State private var showSettingsSheet: Bool = false
#if !os(macOS)
/// iOS recording-folder picker presentation flag. (macOS uses the Record menu.)
@State private var showRecordingFolderImporter: Bool = false
@@ -197,12 +208,17 @@ public struct ShoeGazeBuilderView: View {
// MARK: - Body
/// `true` on narrow widths (iPhone, iPad portrait / split view) — the canvas-first layout.
private var isCompact: Bool {
#if os(iOS)
return horizontalSizeClass == .compact
#else
return false
#endif
}
public var body: some View {
HStack(alignment: .top, spacing: ShoeGazeBuilderView.columnSpacing) {
rigSidebar
Divider().overlay(Color.white.opacity(ShoeGazeBuilderView.dividerOpacity))
builderColumn
}
rootContent
.padding(ShoeGazeBuilderView.outerPadding)
.frame(
minWidth: ShoeGazeBuilderView.minWidth + ShoeGazeBuilderView.librarySidebarReserve,
@@ -309,9 +325,37 @@ public struct ShoeGazeBuilderView: View {
.sheet(isPresented: $showHelpSheet) {
HelpView()
}
.sheet(isPresented: $showRigsSheet) {
rigSidebar
.frame(minWidth: ShoeGazeBuilderView.librarySidebarReserve)
.presentationDetents([.large])
}
.sheet(isPresented: $showPaletteSheet) {
paletteSheet
.presentationDetents([.medium, .large])
}
.sheet(isPresented: $showSettingsSheet) {
settingsSheet
.presentationDetents([.medium])
}
.overlay(alignment: .top) { midiLearnBanner }
}
/// The whole-view layout: docked desktop layout on regular widths, canvas-first on compact.
@ViewBuilder
private var rootContent: some View {
if isCompact {
// No docked sidebar — the rig library is a sheet reached from the header.
builderColumn
} else {
HStack(alignment: .top, spacing: ShoeGazeBuilderView.columnSpacing) {
rigSidebar
Divider().overlay(Color.white.opacity(ShoeGazeBuilderView.dividerOpacity))
builderColumn
}
}
}
/// A banner shown while a control is armed for MIDI Learn, prompting the user to move it.
@ViewBuilder
private var midiLearnBanner: some View {
@@ -384,12 +428,21 @@ public struct ShoeGazeBuilderView: View {
/// board canvas.
private var builderColumn: some View {
VStack(alignment: .leading, spacing: ShoeGazeBuilderView.sectionSpacing) {
headerSection
#if !os(macOS)
recordingRow
#endif
Divider().overlay(Color.white.opacity(ShoeGazeBuilderView.dividerOpacity))
topSection
if isCompact {
compactHeader
#if !os(macOS)
recordingRow
#endif
Divider().overlay(Color.white.opacity(ShoeGazeBuilderView.dividerOpacity))
compactTopSection
} else {
headerSection
#if !os(macOS)
recordingRow
#endif
Divider().overlay(Color.white.opacity(ShoeGazeBuilderView.dividerOpacity))
topSection
}
Divider().overlay(Color.white.opacity(ShoeGazeBuilderView.dividerOpacity))
boardArea
}
@@ -397,6 +450,153 @@ public struct ShoeGazeBuilderView: View {
.environment(\.shoeGazeTempoEnabled, shoeGaze.tempoEnabled)
}
// MARK: - Compact layout (iPhone / narrow iPad)
/// The compact header: a performance row (title, transport, mute) always visible, plus a
/// horizontally scrollable row of panel toggles that open the composition sheets.
private var compactHeader: some View {
_ = transportTick
return VStack(alignment: .leading, spacing: ShoeGazeBuilderView.rowSpacing) {
HStack(spacing: ShoeGazeBuilderView.rowSpacing) {
VStack(alignment: .leading, spacing: 1) {
Text("ShoeGaze Builder").font(.headline).bold()
.foregroundStyle(Color.white)
currentRigLabel
}
if shoeGaze.isRecording { recordingBadge }
Spacer()
// Transport stays on screen (performance): Start / Stop only.
EngineConfigView(
shoeGaze: shoeGaze,
hardwareSampleRate: hardwareSampleRate,
onConfigApplied: { transportTick.toggle() },
transportOnly: true
)
}
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: ShoeGazeBuilderView.rowSpacing) {
compactPanelButton("Rigs", systemImage: "tray.full") { showRigsSheet = true }
compactPanelButton("Pedals", systemImage: "plus.app") { showPaletteSheet = true }
compactPanelButton("Settings", systemImage: "gearshape") { showSettingsSheet = true }
rigBypassButton
Toggle("Mute rig", isOn: Binding(
get: { shoeGaze.tunerMutesRig },
set: { shoeGaze.tunerMutesRig = $0 }
))
.toggleStyle(.switch)
helpButton
if let midi: MIDIController = midi {
MIDIIndicatorView(controller: midi) { showMIDISheet = true }
}
}
}
}
}
/// The recording indicator badge (extracted so both header variants can show it).
private var recordingBadge: some View {
HStack(spacing: 4) {
Circle()
.fill(Color.red)
.frame(width: ShoeGazeBuilderView.recordDotSize, height: ShoeGazeBuilderView.recordDotSize)
Text("REC")
.font(.caption.monospaced())
.foregroundStyle(Color.red)
}
}
/// A labelled icon button that opens one of the compact composition sheets.
private func compactPanelButton(
_ title: String,
systemImage: String,
action: @escaping () -> Void
) -> some View {
Button(action: action) {
Label(title, systemImage: systemImage)
.font(.subheadline)
}
.buttonStyle(.bordered)
.tint(.gray)
}
/// Compact top strip: performance monitoring kept on screen — the board switch/mixer bar, the
/// scope, and the CPU meters. Tempo / Tuner sit below so they don't crowd the transport row.
private var compactTopSection: some View {
VStack(alignment: .leading, spacing: ShoeGazeBuilderView.rowSpacing) {
HStack(spacing: ShoeGazeBuilderView.rowSpacing) {
TempoView(shoeGaze: shoeGaze)
TunerView(shoeGaze: shoeGaze)
}
.environment(\.shoeGazeTempoEnabled, shoeGaze.tempoEnabled)
BoardBarView(
shoeGaze: shoeGaze,
editingBoardIndex: $selectedBoardIndex,
crossfadeSeconds: $crossfadeSeconds,
onAddBoard: { addBoard() },
onClearBoards: { showClearDialog = true }
)
ShoeGazeScopeView(shoeGaze: shoeGaze)
LyrebirdStatusView(engine: shoeGaze.engine)
}
}
/// The Add-a-pedal palette + routing options, presented as a compact sheet.
private var paletteSheet: some View {
NavigationStack {
PedalPaletteView(
axis: .vertical,
onAdd: { type in addPedal(type: type); showPaletteSheet = false },
onRouting: { action in performRouting(action); showPaletteSheet = false }
)
.padding()
.navigationTitle("Add Pedal")
.toolbar {
ToolbarItem(placement: .confirmationAction) {
Button("Done") { showPaletteSheet = false }
}
}
}
.preferredColorScheme(.dark)
}
/// Engine configuration (sample rate, input/output channel counts, input source), presented as
/// a compact sheet — the set-and-forget composition controls.
private var settingsSheet: some View {
NavigationStack {
Form {
Section("Engine") {
EngineConfigView(
shoeGaze: shoeGaze,
hardwareSampleRate: hardwareSampleRate,
onConfigApplied: { transportTick.toggle() }
)
}
Section("Input") {
Picker("Input", selection: inputBinding) {
Text("Test Loop").tag(ShoeGazeBuilderView.testLoopTag)
if shoeGaze.engine.numInputChannels > 0 {
ForEach(Array(0..<shoeGaze.engine.numInputChannels), id: \.self) { channel in
Text("In \(channel)").tag(channel)
}
} else if onEnableLiveInput != nil {
Text("Live Input").tag(0)
}
}
}
}
.navigationTitle("Settings")
.toolbar {
ToolbarItem(placement: .confirmationAction) {
Button("Done") { showSettingsSheet = false }
}
}
}
.preferredColorScheme(.dark)
}
/// Top section: the scope + CPU meters on the left (sized to align with the mixer's
/// Solo/Blend/All control column), and a right column stacking the board mixer over the
/// horizontal pedal picker.