Refine task due date color logic
This commit is contained in:
+15
-4
@@ -5,6 +5,7 @@ import (
|
|||||||
"ArinDash/util"
|
"ArinDash/util"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -101,20 +102,30 @@ func createBoard(ctx context.Context, _ terminalapi.Terminal, _ interface{}) wid
|
|||||||
title = title + strings.Repeat(" ", colWidth-len(title))
|
title = title + strings.Repeat(" ", colWidth-len(title))
|
||||||
}
|
}
|
||||||
|
|
||||||
color := cell.ColorGreen
|
fgColor := cell.ColorGreen
|
||||||
|
bgColor := cell.ColorBlack
|
||||||
durr := int(column.Tasks[i].DueDate.Sub(time.Now()).Hours() / 24)
|
durr := int(column.Tasks[i].DueDate.Sub(time.Now()).Hours() / 24)
|
||||||
|
if durr < 0 {
|
||||||
|
durr = math.MaxInt
|
||||||
|
}
|
||||||
if durr < 14 && !column.IsFinal {
|
if durr < 14 && !column.IsFinal {
|
||||||
color = cell.ColorRed
|
fgColor = cell.ColorBlack
|
||||||
|
bgColor = cell.ColorRed
|
||||||
d := fmt.Sprintf("%02dd", durr)
|
d := fmt.Sprintf("%02dd", durr)
|
||||||
title = title[0:colWidth-3] + d
|
title = title[0:colWidth-3] + d
|
||||||
}
|
}
|
||||||
if durr < 28 && !column.IsFinal {
|
if durr < 28 && !column.IsFinal {
|
||||||
color = cell.ColorYellow
|
bgColor = cell.ColorYellow
|
||||||
|
fgColor = cell.ColorBlack
|
||||||
d := fmt.Sprintf("%02dd", durr)
|
d := fmt.Sprintf("%02dd", durr)
|
||||||
title = title[0:colWidth-3] + d
|
title = title[0:colWidth-3] + d
|
||||||
}
|
}
|
||||||
|
if column.IsFinal {
|
||||||
|
bgColor = cell.ColorBlack
|
||||||
|
fgColor = cell.ColorGray
|
||||||
|
}
|
||||||
|
|
||||||
if err := widget.Write(title, text.WriteCellOpts(cell.FgColor(color))); err != nil {
|
if err := widget.Write(title, text.WriteCellOpts(cell.FgColor(fgColor), cell.BgColor(bgColor), cell.Bold())); err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user