card.go raw
1 package gel
2
3 import l "github.com/p9c/gio/layout"
4
5 func (w *Window) Card(background string, embed l.Widget,
6 ) func(gtx l.Context) l.Dimensions {
7 return w.Inset(0.0,
8 w.Fill(background, l.Center, w.TextSize.V, 0, w.Inset(0.25,
9 embed,
10 ).Fn).Fn,
11 ).Fn
12 }
13
14 func (w *Window) CardList(list *List, background string,
15 widgets ...l.Widget) func(gtx l.Context) l.Dimensions {
16 out := list.Vertical().ListElement(func(gtx l.Context, index int) l.Dimensions {
17 return w.Card(background, widgets[index])(gtx)
18 }).Length(len(widgets))
19 return out.Fn
20 }
21
22 func (w *Window) CardContent(title, color string, embed l.Widget) func(gtx l.Context) l.Dimensions {
23 out := w.VFlex()
24 if title != "" {
25 out.Rigid(w.H6(title).Color(color).Fn)
26 }
27 return out.Rigid(embed).Fn
28 }
29