example/kitchen: add a button that is {dis,en}abled by the switch

This adds a simple button that defaults to being disabled, but can
be enabled by toggling the state of the existing Switch widget.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
Chris Waldon
2020-06-02 16:26:22 -04:00
committed by Elias Naur
parent cc5f8fcffe
commit bda315e687
5 changed files with 18 additions and 6 deletions
+12
View File
@@ -147,6 +147,7 @@ var (
iconTextButton = new(widget.Clickable)
iconButton = new(widget.Clickable)
flatBtn = new(widget.Clickable)
disableBtn = new(widget.Clickable)
radioButtonsGroup = new(widget.Enum)
list = &layout.List{
Axis: layout.Vertical,
@@ -266,6 +267,17 @@ func kitchen(gtx layout.Context, th *material.Theme) layout.Dimensions {
material.Switch(th, swtch).Layout,
)
}),
layout.Rigid(func(gtx C) D {
return layout.Inset{Left: unit.Dp(16)}.Layout(gtx, func(gtx C) D {
text := "enabled"
if !swtch.Value {
text = "disabled"
gtx = gtx.Disabled()
}
btn := material.Button(th, disableBtn, text)
return btn.Layout(gtx)
})
}),
)
},
func(gtx C) D {