widget/material: move Icon to its own file and add Color; add CornerRadius to Button

This commit is contained in:
Alexander Arin
2019-11-03 18:11:18 +03:00
committed by Elias Naur
parent ec0c2498a1
commit 2a06f3d3b2
3 changed files with 89 additions and 55 deletions
+17 -1
View File
@@ -14,6 +14,7 @@ import (
"gioui.org/op/paint"
"gioui.org/text"
"gioui.org/unit"
"golang.org/x/exp/shiny/materialdesign/icons"
)
type Theme struct {
@@ -22,8 +23,11 @@ type Theme struct {
Primary color.RGBA
Text color.RGBA
Hint color.RGBA
InvText color.RGBA
}
TextSize unit.Value
TextSize unit.Value
checkedStateIcon *Icon
uncheckedStateIcon *Icon
}
func NewTheme() *Theme {
@@ -33,10 +37,22 @@ func NewTheme() *Theme {
t.Color.Primary = rgb(0x3f51b5)
t.Color.Text = rgb(0x000000)
t.Color.Hint = rgb(0xbbbbbb)
t.Color.InvText = rgb(0xffffff)
t.TextSize = unit.Sp(16)
t.checkedStateIcon = mustIcon(NewIcon(icons.ToggleCheckBox))
t.uncheckedStateIcon = mustIcon(NewIcon(icons.ToggleCheckBoxOutlineBlank))
return t
}
func mustIcon(ic *Icon, err error) *Icon {
if err != nil {
panic(err)
}
return ic
}
func rgb(c uint32) color.RGBA {
return argb(0xff000000 | c)
}