example/kitchen: place buttons on the same row

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-10-12 16:52:00 +02:00
parent e1de1ba591
commit 5a82fc9267
+29 -18
View File
@@ -104,24 +104,35 @@ func kitchen(gtx *layout.Context, th *material.Theme) {
} }
}, },
func() { func() {
for button.Clicked(gtx) { buttons := layout.Flex{Alignment: layout.Middle}
enabled = !enabled in := layout.UniformInset(unit.Dp(8))
} b1 := buttons.Rigid(gtx, func() {
th.Button("Click me!").Layout(gtx, button) in.Layout(gtx, func() {
}, for iconButton.Clicked(gtx) {
func() { }
if enabled { th.IconButton(icon).Layout(gtx, iconButton)
for disabledButton.Clicked(gtx) { })
} })
th.Button("Enabled").Layout(gtx, disabledButton) b2 := buttons.Rigid(gtx, func() {
} else { in.Layout(gtx, func() {
th.Button("Disabled").Layout(gtx, disabledButton) for button.Clicked(gtx) {
} enabled = !enabled
}, }
func() { th.Button("Click me!").Layout(gtx, button)
for iconButton.Clicked(gtx) { })
} })
th.IconButton(icon).Layout(gtx, iconButton) b3 := buttons.Rigid(gtx, func() {
in.Layout(gtx, func() {
if enabled {
for disabledButton.Clicked(gtx) {
}
th.Button("Enabled").Layout(gtx, disabledButton)
} else {
th.Button("Disabled").Layout(gtx, disabledButton)
}
})
})
buttons.Layout(gtx, b1, b2, b3)
}, },
} }
list.Layout(gtx, len(widgets), func(i int) { list.Layout(gtx, len(widgets), func(i int) {