Files
luma/Luma/HookPackConfigView.swift
Ole André Vadla Ravnås bf06ef8b8e Make HookPack/custom-instrument panes scrollable
Wrap the config view in ScrollView (SwiftUI) and the detail
UI's outer Box in a ScrolledWindow (GTK) so widgets past the
visible area can be reached.
2026-05-20 21:31:56 +02:00

66 lines
2.3 KiB
Swift

import SwiftUI
import LumaCore
struct HookPackConfigView: View {
let pack: HookPack
@Binding var config: HookPackConfig
let engine: Engine
@Binding var selection: SidebarItemID?
var body: some View {
ScrollView {
VStack(alignment: .leading, spacing: 12) {
HStack(spacing: 8) {
InstrumentIconView(icon: pack.resolvedIcon, pointSize: 14)
Text(pack.manifest.name).font(.headline)
Spacer()
}
GroupBox("Features") {
Group {
if pack.manifest.features.isEmpty {
Text("This hook-pack does not declare any features.")
.font(.subheadline)
.foregroundStyle(.secondary)
} else {
VStack(alignment: .leading, spacing: 12) {
ForEach(pack.manifest.features) { feature in
InstrumentFeatureRow(
feature: feature,
state: stateBinding(for: feature)
)
}
}
}
}
.padding(.leading, 12)
.padding(.vertical, 4)
.frame(maxWidth: .infinity, alignment: .leading)
}
InstrumentWidgetsRenderer(
widgets: pack.manifest.widgets,
engine: engine,
selection: $selection
)
}
.frame(maxWidth: .infinity, alignment: .leading)
.padding(8)
}
}
private func stateBinding(for feature: CustomInstrumentDef.Feature) -> Binding<FeatureState> {
Binding(
get: {
config.features[feature.id]
?? FeatureState(enabled: feature.enabledByDefault, value: feature.schema.defaultValue)
},
set: { newValue in
var updated = config
updated.features[feature.id] = newValue
config = updated
}
)
}
}