mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user