mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Seperate calendar coloring code from widget code
This commit is contained in:
parent
0b86262560
commit
bb71396291
@ -6,6 +6,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rivo/tview"
|
"github.com/rivo/tview"
|
||||||
|
"google.golang.org/api/calendar/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Widget() tview.Primitive {
|
func Widget() tview.Primitive {
|
||||||
@ -21,14 +22,7 @@ func Widget() tview.Primitive {
|
|||||||
ts, _ := time.Parse(time.RFC3339, item.Start.DateTime)
|
ts, _ := time.Parse(time.RFC3339, item.Start.DateTime)
|
||||||
timestamp := ts.Format("Mon Jan _2 15:04:05 2006")
|
timestamp := ts.Format("Mon Jan _2 15:04:05 2006")
|
||||||
|
|
||||||
color := "red"
|
color := colorize(item, ts)
|
||||||
if strings.Contains(item.Summary, "1on1") {
|
|
||||||
color = "green"
|
|
||||||
}
|
|
||||||
|
|
||||||
if ts.Before(time.Now()) {
|
|
||||||
color = "grey"
|
|
||||||
}
|
|
||||||
|
|
||||||
str := fmt.Sprintf(" [%s]%s[white]\n %s\n\n", color, item.Summary, timestamp)
|
str := fmt.Sprintf(" [%s]%s[white]\n %s\n\n", color, item.Summary, timestamp)
|
||||||
data = data + str
|
data = data + str
|
||||||
@ -38,3 +32,16 @@ func Widget() tview.Primitive {
|
|||||||
|
|
||||||
return widget
|
return widget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func colorize(item *calendar.Event, ts time.Time) string {
|
||||||
|
color := "red"
|
||||||
|
if strings.Contains(item.Summary, "1on1") {
|
||||||
|
color = "green"
|
||||||
|
}
|
||||||
|
|
||||||
|
if ts.Before(time.Now()) {
|
||||||
|
color = "grey"
|
||||||
|
}
|
||||||
|
|
||||||
|
return color
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user