kanban

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

commit 40b17b11d9b2508060926717cdbeff4d2feb4dd6
parent f5d0cbf64a6cc63579130ab6099e131b00fcdea6
Author: Jack Mordaunt <jackmordaunt@gmail.com>
Date:   Mon, 12 Apr 2021 16:27:21 +0800

ux: warn user before archiving project

Diffstat:
Mcmd/kanban/control/card.go | 41+++++++++++++++++++++++++++++++++++++----
Mcmd/kanban/ui.go | 5+++--
Mcmd/kanban/widgets.go | 17++++++++---------
3 files changed, 48 insertions(+), 15 deletions(-)

diff --git a/cmd/kanban/control/card.go b/cmd/kanban/control/card.go @@ -11,6 +11,13 @@ import ( "git.sr.ht/~jackmordaunt/kanban/cmd/kanban/util" ) +type Float int + +const ( + FloatLeft Float = iota + FloatRight +) + // Card implements "https://material.io/components/cards". type Card struct { // Media image.Image @@ -25,6 +32,7 @@ type Action struct { Label string Fg color.NRGBA Bg color.NRGBA + Float Float } func (c Card) Layout(gtx C, th *material.Theme) D { @@ -92,17 +100,42 @@ func (c Card) Layout(gtx C, th *material.Theme) D { Axis: layout.Horizontal, }.Layout( gtx, - func() (actions []layout.FlexChild) { + func() (flex []layout.FlexChild) { + var ( + floatRight []Action + floatLeft []Action + ) for ii := range c.Actions { - action := &c.Actions[ii] - actions = append(actions, layout.Rigid(func(gtx C) D { + if c.Actions[ii].Float == FloatRight { + floatRight = append(floatRight, c.Actions[ii]) + } else { + floatLeft = append(floatLeft, c.Actions[ii]) + } + } + for ii := range floatLeft { + action := &floatLeft[ii] + flex = append(flex, layout.Rigid(func(gtx C) D { + btn := material.Button(th, action.Clickable, action.Label) + btn.Color = action.Fg + btn.Background = action.Bg + return btn.Layout(gtx) + })) + } + if len(floatRight) > 0 { + flex = append(flex, layout.Flexed(1, func(gtx C) D { + return D{Size: image.Point{X: gtx.Constraints.Max.X, Y: gtx.Constraints.Min.Y}} + })) + } + for ii := range floatRight { + action := &floatRight[ii] + flex = append(flex, layout.Rigid(func(gtx C) D { btn := material.Button(th, action.Clickable, action.Label) btn.Color = action.Fg btn.Background = action.Bg return btn.Layout(gtx) })) } - return actions + return flex }()..., ) }), diff --git a/cmd/kanban/ui.go b/cmd/kanban/ui.go @@ -276,7 +276,7 @@ func (ui *UI) Update(gtx C) { ui.EditProject() } if ui.ProjectForm.Delete.Button.Clicked() { - ui.ShowDeleteProjectConfirmation() + ui.ShowArchiveProjectConfirmation() } if ui.ArchiveProjectConfirmation.SubmitBtn.Clicked() { if ui.ArchiveProjectConfirmation.Confirmation.Text() == ui.Project.Name { @@ -534,13 +534,14 @@ func (ui *UI) EditProject() { } } -func (ui *UI) ShowDeleteProjectConfirmation() { +func (ui *UI) ShowArchiveProjectConfirmation() { if ui.Project == nil { return } ui.Modal = func(gtx C) D { return ui.ArchiveProjectConfirmation.Layout(gtx, ui.Th) } + ui.ArchiveProjectConfirmation.Confirmation.Focus() } // Projects is a list of Project entities with added behaviours. diff --git a/cmd/kanban/widgets.go b/cmd/kanban/widgets.go @@ -151,14 +151,6 @@ func (f *ProjectForm) Layout(gtx C, th *material.Theme) D { layout.Rigid(func(gtx C) D { return f.Name.Layout(gtx, th, "Project Name") }), - layout.Rigid(func(gtx C) D { - if f.Mode() != ModeEdit { - return D{} - } - btn := material.Button(th, &f.Delete.Button, "Archive") - btn.Background = color.NRGBA{R: 200, A: 200} - return btn.Layout(gtx) - }), ) }, Actions: []control.Action{ @@ -174,6 +166,13 @@ func (f *ProjectForm) Layout(gtx C, th *material.Theme) D { Fg: th.Fg, Bg: th.Bg, }, + { + Clickable: &f.Delete.Button, + Label: "Archive", + Fg: th.ContrastFg, + Bg: color.NRGBA{R: 200, A: 200}, + Float: control.FloatRight, + }, }, }.Layout(gtx, th) } @@ -490,7 +489,7 @@ func (dpc *ArchiveProjectConfirmation) Layout(gtx C, th *material.Theme) D { }.Layout( gtx, layout.Rigid(func(gtx C) D { - return dpc.Confirmation.Layout(gtx, th, "Project") + return dpc.Confirmation.Layout(gtx, th, "Confirm project name") }), ) },