kanban

Kanban client in Gio
Log | Files | Refs | README | LICENSE

commit 0c7a6c943c36f848082b3d8587b833ce84601cb0
parent 76a1f7b0a3e3380ebd38e46cf4b8d9cc59d9c3ac
Author: Jack Mordaunt <jackmordaunt@gmail.com>
Date:   Thu,  5 Nov 2020 13:44:36 +0800

feat: basic card layout

Diffstat:
Mcmd/kanban/layout.go | 98+++++++++++++++++++++++++++++++++++++++++++------------------------------------
1 file changed, 54 insertions(+), 44 deletions(-)

diff --git a/cmd/kanban/layout.go b/cmd/kanban/layout.go @@ -9,8 +9,59 @@ import ( "gioui.org/widget/material" ) -// Modal renders content centered with decorations. -func Modal(gtx C, th *material.Theme, title string, w layout.Widget) D { +// Card lays the content out with a title for context. +type Card struct { + Title string +} + +func (c Card) Layout(gtx C, th *material.Theme, w layout.Widget) D { + return layout.Stack{}.Layout( + gtx, + layout.Expanded(func(gtx C) D { + return Rect{ + Color: color.RGBA{R: 255, G: 255, B: 255, A: 255}, + Size: layout.FPt(gtx.Constraints.Min), + Radii: 4, + }.Layout(gtx) + }), + layout.Stacked(func(gtx C) D { + inset := layout.UniformInset(unit.Dp(10)) + return layout.Flex{ + Axis: layout.Vertical, + }.Layout( + gtx, + layout.Rigid(func(gtx C) D { + return layout.Stack{}.Layout( + gtx, + layout.Expanded(func(gtx C) D { + return Rect{ + Color: color.RGBA{A: 100}, + Size: f32.Point{ + X: float32(gtx.Constraints.Max.X), + Y: float32(gtx.Constraints.Min.Y), + }, + }.Layout(gtx) + }), + layout.Stacked(func(gtx C) D { + return inset.Layout(gtx, func(gtx C) D { + return material.H6(th, c.Title).Layout(gtx) + }) + }), + ) + }), + layout.Rigid(func(gtx C) D { + return inset.Layout(gtx, func(gtx C) D { + return w(gtx) + }) + }), + ) + }), + ) + +} + +// Modal renders content centered on a translucent scrim. +func Modal(gtx C, w layout.Widget) D { return layout.Stack{}.Layout( gtx, layout.Stacked(func(gtx C) D { @@ -25,48 +76,7 @@ func Modal(gtx C, th *material.Theme, title string, w layout.Widget) D { if gtx.Constraints.Max.X > gtx.Px(unit.Dp(600)) { gtx.Constraints.Max.X = gtx.Px(unit.Dp(600)) } - return layout.Stack{}.Layout( - gtx, - layout.Expanded(func(gtx C) D { - return Rect{ - Color: color.RGBA{R: 255, G: 255, B: 255, A: 255}, - Size: layout.FPt(gtx.Constraints.Min), - Radii: 4, - }.Layout(gtx) - }), - layout.Stacked(func(gtx C) D { - inset := layout.UniformInset(unit.Dp(10)) - return layout.Flex{ - Axis: layout.Vertical, - }.Layout( - gtx, - layout.Rigid(func(gtx C) D { - return layout.Stack{}.Layout( - gtx, - layout.Expanded(func(gtx C) D { - return Rect{ - Color: color.RGBA{A: 100}, - Size: f32.Point{ - X: float32(gtx.Constraints.Max.X), - Y: float32(gtx.Constraints.Min.Y), - }, - }.Layout(gtx) - }), - layout.Stacked(func(gtx C) D { - return inset.Layout(gtx, func(gtx C) D { - return material.H6(th, title).Layout(gtx) - }) - }), - ) - }), - layout.Rigid(func(gtx C) D { - return inset.Layout(gtx, func(gtx C) D { - return w(gtx) - }) - }), - ) - }), - ) + return w(gtx) }) }), )