Add-Pedal sheet: scrollable list, fixed header with type filter, stable size

The sheet couldn't scroll — PedalPaletteView doesn't self-wrap in a ScrollView
(the host must) and the sheet had none, so the list overflowed and drags just
resized the detent. Rework:

- Wrap the palette in a ScrollView; single fixed detent (fraction 0.82) so the
  sheet no longer resizes, and presentationContentInteraction(.scrolls) so drags
  scroll the list.
- Fixed header with the "Add Pedal" title, the type-filter menu, and Done —
  PedalPaletteView gains an external filter binding + showsFilterMenu flag so the
  filter can be hoisted out of the scrolling content.
- PedalCategory made public (+ Sendable) so the filter binding can cross the
  public palette init.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-04 17:21:49 -07:00
parent f97ba90ea6
commit 19feb03fe8
3 changed files with 83 additions and 27 deletions
@@ -52,6 +52,8 @@ public struct ShoeGazeBuilderView: View {
/// Narrow scope shown in the compact (iPad) header, tucked left of the transport buttons.
private static let compactHeaderScopeWidth: CGFloat = 340
private static let compactHeaderScopeHeight: CGFloat = 76
/// Stable height (fraction of the screen) for the Add-Pedal sheet — a single, non-resizable detent.
private static let paletteSheetHeightFraction: CGFloat = 0.82
private static let columnSpacing: CGFloat = 14
private static let backgroundRed: Double = 0.08
private static let backgroundGreen: Double = 0.07
@@ -171,6 +173,9 @@ public struct ShoeGazeBuilderView: View {
@State private var showPaletteSheet: Bool = false
@State private var showSettingsSheet: Bool = false
/// Type filter for the compact Add-Pedal sheet, hoisted so it sits in the sheet's fixed header.
@State private var pedalFilter: PedalCategory?
#if !os(macOS)
/// iOS recording-folder picker presentation flag. (macOS uses the Record menu.)
@State private var showRecordingFolderImporter: Bool = false
@@ -371,7 +376,6 @@ public struct ShoeGazeBuilderView: View {
Color.clear
.sheet(isPresented: $showPaletteSheet) {
paletteSheet
.presentationDetents([.medium, .large])
}
}
@@ -609,29 +613,57 @@ public struct ShoeGazeBuilderView: View {
/// 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 }
)
// A fixed header (title, type filter, Done) over a scrolling list. Not a NavigationStack —
// its transparent bar let the list scroll under the title. The palette does not self-wrap in
// a ScrollView (the host must), so it is wrapped here.
VStack(spacing: 0) {
HStack(spacing: ShoeGazeBuilderView.rowSpacing) {
Text("Add Pedal")
.font(.headline)
.foregroundStyle(Color.white)
Spacer()
pedalFilterMenu
Button("Done") { showPaletteSheet = false }
.fontWeight(.semibold)
}
.padding()
.navigationTitle("Add Pedal")
#if os(iOS)
.navigationBarTitleDisplayMode(.inline)
.toolbarBackground(.visible, for: .navigationBar)
#endif
.toolbar {
ToolbarItem(placement: .confirmationAction) {
Button("Done") { showPaletteSheet = false }
}
Divider().overlay(Color.white.opacity(ShoeGazeBuilderView.dividerOpacity))
ScrollView {
PedalPaletteView(
axis: .vertical,
filter: $pedalFilter,
showsFilterMenu: false,
onAdd: { type in addPedal(type: type); showPaletteSheet = false },
onRouting: { action in performRouting(action); showPaletteSheet = false }
)
.padding()
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
.preferredColorScheme(.dark)
// Drag inside the list scrolls it instead of resizing the sheet detent.
// One fixed detent (no resize-drag) and drags scroll the list instead of the sheet.
.presentationDetents([.fraction(ShoeGazeBuilderView.paletteSheetHeightFraction)])
.presentationContentInteraction(.scrolls)
}
/// The type-filter menu shown in the Add-Pedal sheet header, bound to `pedalFilter`.
private var pedalFilterMenu: some View {
Menu {
Button("All Types") { pedalFilter = nil }
Divider()
ForEach(PedalCategory.allCases) { category in
Button(category.rawValue) { pedalFilter = category }
}
} label: {
HStack(spacing: 3) {
Image(systemName: "line.3.horizontal.decrease.circle")
Text(pedalFilter?.rawValue ?? "All").lineLimit(1)
}
}
}
/// 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 {