This actually works in GarageBand, by the way -- I defined my own View, IsleButton, to look and act exactly like a Button, and replaced my usages of Button with IsleButton:
import SwiftUI
struct IsleButton: View { var label: String
var action: () -> Void
@State var backgroundColor = Color(red: 0.4, green: 0.4, blue: 0.4)
var body: some View { Group {
Text(label) }
.padding(EdgeInsets(top: 2.0, leading: 10.0, bottom: 2.5, trailing: 10.0)) .background(RoundedRectangle(cornerRadius: 5.0).fill(backgroundColor))
.gesture(DragGesture(minimumDistance: 0) .onChanged({ _ in
backgroundColor = Color.blue action()
}) .onEnded({ _ in
backgroundColor = Color(red: 0.4, green: 0.4, blue: 0.4) })
) }
}
import SwiftUI
struct SystemLevelView: View { @ObservedObject var patchBank: PatchBank
@State var dialogDisplayed: Bool = false
var body: some View { GeometryReader { parent in
ZStack { VStack {
HStack { /Button("System-Wide Oscillators") {
dialogDisplayed = true }/
IsleButton(label: "System-Wide Oscillators", action: { dialogDisplayed = true
}) Spacer()
/*Button("System-Wide Effects Send") {}*/ IsleButton(label: "System-Wide Effects Send", action: {})
} .padding(6.0)
Spacer() }
HStack { Spacer()
VStack(alignment: .center) { ParameterSliderView(parameter: patchBank.gain, minMaxLabelToggle: .constant(false))
ParameterSliderView(parameter: patchBank.tempo, minMaxLabelToggle: .constant(false)) }.frame(width: 600.0)
Spacer() }
} }
.sheet(isPresented: $dialogDisplayed) { SystemLevelPatchEditView(patchBank: patchBank, dialogDisplayed: $dialogDisplayed)
} }
`}
Still, though, I should just be able to use Button, shouldn't I?
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: