Boards sheet, ⌘1–9 switching, unified player bar, input persistence
Boards sheet (BoardsSheetView): rename, drag-reorder, swipe-delete, plus per-board enable/solo/level and a Solo/Blend + crossfade header. Opened from a "Boards…" button in the builder; presented with medium/large detents on iOS. Makes ShoeGaze.moveBoard public to back the reorder. Keyboard switching: hidden ⌘1…⌘9 buttons in the builder solo (live-switch to) the matching board and select it as the edit target. Unified player: ShoeGazeView drops its bespoke Active picker + crossfade field and hosts the shared BoardBarView, matching the builder. Input persistence: the builder saves the input choice (test loop vs live channel) to UserDefaults and restores it on appear. With no saved choice it defaults to live input when the mic is already authorised and an input channel exists, else stays on the test loop. The iOS builder now opens one input channel so live input is actually available there. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -79,6 +79,10 @@ public struct ShoeGazeView: View {
|
||||
/// Crossfade duration used for the next board-select transition.
|
||||
@State private var crossfadeSeconds: Double = ShoeGazeView.defaultCrossfadeSeconds
|
||||
|
||||
/// Highlighted board in the board bar (the bar's edit-target binding). The player shows
|
||||
/// every board strip, so this only drives the bar's selection outline.
|
||||
@State private var selectedBoardIndex: Int = 0
|
||||
|
||||
/// Controls presentation of the iOS `.fileImporter` directory picker.
|
||||
/// On macOS the picker is opened imperatively via `NSOpenPanel`; this flag is
|
||||
/// only meaningful on iOS / non-macOS targets.
|
||||
@@ -108,7 +112,12 @@ public struct ShoeGazeView: View {
|
||||
recordingRow
|
||||
Divider()
|
||||
.overlay(Color.white.opacity(ShoeGazeView.dividerOpacity))
|
||||
boardSelectRow
|
||||
BoardBarView(
|
||||
shoeGaze: shoeGaze,
|
||||
editingBoardIndex: $selectedBoardIndex,
|
||||
crossfadeSeconds: $crossfadeSeconds,
|
||||
onAddBoard: { addBoard() }
|
||||
)
|
||||
Divider()
|
||||
.overlay(Color.white.opacity(ShoeGazeView.dividerOpacity))
|
||||
boardList
|
||||
@@ -230,77 +239,6 @@ public struct ShoeGazeView: View {
|
||||
}
|
||||
}
|
||||
|
||||
/// A `Binding<Int>` that maps between the Picker's integer tag and `ShoeGaze` select API.
|
||||
///
|
||||
/// Tag `-1` represents "All boards audible" (`activeBoardIndex == nil`).
|
||||
/// Tags `0 ..< boards.count` represent the soloed board at that index.
|
||||
/// Setting the binding calls `selectBoard(_:crossfadeSeconds:)` or
|
||||
/// `selectAllBoards(crossfadeSeconds:)` with the current `crossfadeSeconds` value.
|
||||
private var boardSelectBinding: Binding<Int> {
|
||||
Binding(
|
||||
get: { shoeGaze.activeBoardIndex ?? -1 },
|
||||
set: { newValue in
|
||||
// Clamp here so a value typed into the crossfade text field (which has no
|
||||
// built-in bounds) can never pass a negative or oversized lag time.
|
||||
let seconds: Double = min(max(crossfadeSeconds, 0.0), ShoeGazeView.maxCrossfadeSeconds)
|
||||
if newValue == -1 {
|
||||
shoeGaze.selectAllBoards(crossfadeSeconds: seconds)
|
||||
} else if newValue >= 0, newValue < shoeGaze.boards.count {
|
||||
shoeGaze.selectBoard(shoeGaze.boards[newValue], crossfadeSeconds: seconds)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/// Board-select row: an "Active" Picker to solo a board (or hear all), a crossfade-
|
||||
/// seconds text field, and a companion Stepper for convenient adjustment.
|
||||
///
|
||||
/// The row is always visible. When `boards.count <= 1` the Picker has only one or two
|
||||
/// options, which is still useful for the "All" / single-board toggle.
|
||||
private var boardSelectRow: some View {
|
||||
HStack(spacing: ShoeGazeView.boardSelectSpacing) {
|
||||
Text("Active:")
|
||||
.font(.subheadline)
|
||||
.foregroundStyle(Color.white.opacity(ShoeGazeView.labelOpacity))
|
||||
|
||||
Picker("Active", selection: boardSelectBinding) {
|
||||
Text("All").tag(-1)
|
||||
ForEach(Array(shoeGaze.boards.enumerated()), id: \.offset) { pair in
|
||||
let label: String = pair.element.label.isEmpty
|
||||
? "Board \(pair.offset + 1)"
|
||||
: pair.element.label
|
||||
Text(label).tag(pair.offset)
|
||||
}
|
||||
}
|
||||
.pickerStyle(.menu)
|
||||
.foregroundStyle(Color.white)
|
||||
|
||||
Spacer()
|
||||
|
||||
Text("Crossfade (s):")
|
||||
.font(.subheadline)
|
||||
.foregroundStyle(Color.white.opacity(ShoeGazeView.labelOpacity))
|
||||
|
||||
TextField(
|
||||
"s",
|
||||
value: $crossfadeSeconds,
|
||||
format: .number.precision(.fractionLength(1))
|
||||
)
|
||||
.frame(width: ShoeGazeView.crossfadeFieldWidth)
|
||||
#if os(macOS)
|
||||
.textFieldStyle(.squareBorder)
|
||||
#endif
|
||||
|
||||
Stepper(
|
||||
"",
|
||||
value: $crossfadeSeconds,
|
||||
in: 0...ShoeGazeView.maxCrossfadeSeconds,
|
||||
step: ShoeGazeView.crossfadeStepIncrement
|
||||
)
|
||||
.labelsHidden()
|
||||
}
|
||||
}
|
||||
|
||||
/// Vertically scrollable list of board strips.
|
||||
///
|
||||
/// Keyed by `\.offset` on an enumerated snapshot; see the doc-comment on
|
||||
|
||||
Reference in New Issue
Block a user