example: bump gio version and add flat button example to kitchen

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-05-11 13:20:04 +02:00
parent 23baeff18d
commit a0df8ba59b
6 changed files with 30 additions and 14 deletions
+23 -7
View File
@@ -128,10 +128,11 @@ var (
SingleLine: true,
Submit: true,
}
button = new(widget.Button)
greenButton = new(widget.Button)
iconTextButton = new(widget.Button)
iconButton = new(widget.Button)
button = new(widget.Clickable)
greenButton = new(widget.Clickable)
iconTextButton = new(widget.Clickable)
iconButton = new(widget.Clickable)
flatBtn = new(widget.Clickable)
radioButtonsGroup = new(widget.Enum)
list = &layout.List{
Axis: layout.Vertical,
@@ -145,7 +146,7 @@ var (
swtch = new(widget.Bool)
)
func (b iconAndTextButton) Layout(gtx *layout.Context, button *widget.Button, icon *widget.Icon, word string) {
func (b iconAndTextButton) Layout(gtx *layout.Context, button *widget.Clickable, icon *widget.Icon, word string) {
material.ButtonLayout(b.theme).Layout(gtx, button, func() {
iconAndLabel := layout.Flex{Axis: layout.Horizontal, Alignment: layout.Middle}
textIconSpacer := unit.Dp(5)
@@ -204,7 +205,7 @@ func kitchen(gtx *layout.Context, th *material.Theme) {
}),
layout.Rigid(func() {
in.Layout(gtx, func() {
iconAndTextButton{th}.Layout(gtx, iconTextButton, icon, "Horizontal button")
iconAndTextButton{th}.Layout(gtx, iconTextButton, icon, "Icon")
})
}),
layout.Rigid(func() {
@@ -217,13 +218,28 @@ func kitchen(gtx *layout.Context, th *material.Theme) {
}),
layout.Rigid(func() {
in.Layout(gtx, func() {
btn := material.Button(th, "Green button")
l := "Green"
if !green {
l = "Blue"
}
btn := material.Button(th, l)
if green {
btn.Background = color.RGBA{A: 0xff, R: 0x9e, G: 0x9d, B: 0x24}
}
btn.Layout(gtx, greenButton)
})
}),
layout.Rigid(func() {
in.Layout(gtx, func() {
material.Clickable(gtx, flatBtn, func() {
layout.UniformInset(unit.Dp(12)).Layout(gtx, func() {
layout.Center.Layout(gtx, func() {
material.Body1(th, "Flat").Layout(gtx)
})
})
})
})
}),
)
},
func() {