diff --git a/apis/kaneo/main.go b/apis/kaneo/main.go index 0cd4813..38a8245 100644 --- a/apis/kaneo/main.go +++ b/apis/kaneo/main.go @@ -27,6 +27,7 @@ type Column struct { Position int `json:"position"` Name string `json:"name"` Tasks []Task `json:"tasks"` + IsFinal bool `json:"isFinal"` } type Task struct { diff --git a/widgets/board.go b/widgets/board.go index 77591f9..2c741d5 100644 --- a/widgets/board.go +++ b/widgets/board.go @@ -4,6 +4,7 @@ import ( "ArinDash/apis/kaneo" "ArinDash/util" "context" + "fmt" "sort" "strings" "time" @@ -60,7 +61,7 @@ func createBoard(ctx context.Context, _ terminalapi.Terminal, _ interface{}) wid name = name + strings.Repeat(" ", colWidth-len(name)) } - if err := widget.Write(name, text.WriteCellOpts(cell.FgColor(cell.ColorGreen))); err != nil { + if err := widget.Write(name, text.WriteCellOpts(cell.FgColor(cell.ColorWhite))); err != nil { return nil } } @@ -72,7 +73,7 @@ func createBoard(ctx context.Context, _ terminalapi.Terminal, _ interface{}) wid return err } - for i := range 6 { + for i := range 10 { if i != 0 { if err := writeMiddle(widget, colWidth, widget.board.Columns); err != nil { return err @@ -99,7 +100,21 @@ func createBoard(ctx context.Context, _ terminalapi.Terminal, _ interface{}) wid if len(title) < colWidth { title = title + strings.Repeat(" ", colWidth-len(title)) } - if err := widget.Write(title, text.WriteCellOpts(cell.FgColor(cell.ColorWhite))); err != nil { + + color := cell.ColorGreen + durr := int(column.Tasks[i].DueDate.Sub(time.Now()).Hours() / 24) + if durr < 14 && !column.IsFinal { + color = cell.ColorRed + d := fmt.Sprintf("%02dd", durr) + title = title[0:colWidth-3] + d + } + if durr < 28 && !column.IsFinal { + color = cell.ColorYellow + d := fmt.Sprintf("%02dd", durr) + title = title[0:colWidth-3] + d + } + + if err := widget.Write(title, text.WriteCellOpts(cell.FgColor(color))); err != nil { return nil } } else {