mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Improve display of single-day away? date durations
This commit is contained in:
parent
07059749d6
commit
8d7c163d37
@ -22,6 +22,10 @@ func (item *Item) String() string {
|
||||
|
||||
/* -------------------- Public Functions -------------------- */
|
||||
|
||||
func (item *Item) IsOneDay() bool {
|
||||
return item.Start == item.End
|
||||
}
|
||||
|
||||
func (item *Item) Name() string {
|
||||
if (item.Employee != Employee{}) {
|
||||
return item.Employee.Name
|
||||
|
@ -12,15 +12,26 @@ func Widget() tview.Primitive {
|
||||
widget := tview.NewTextView()
|
||||
widget.SetBorder(true)
|
||||
widget.SetDynamicColors(true)
|
||||
widget.SetTitle(" 🐨 Away ")
|
||||
widget.SetTitle(fmt.Sprintf(" 🐨 Away (%d)", len(items)))
|
||||
|
||||
data := ""
|
||||
for _, item := range items {
|
||||
str := fmt.Sprintf(" [green]%s[white]\n %s - %s\n\n", item.Name(), item.PrettyStart(), item.PrettyEnd())
|
||||
data = data + str
|
||||
data = data + display(item)
|
||||
}
|
||||
|
||||
fmt.Fprintf(widget, "%s", data)
|
||||
|
||||
return widget
|
||||
}
|
||||
|
||||
func display(item Item) string {
|
||||
var str string
|
||||
|
||||
if item.IsOneDay() {
|
||||
str = fmt.Sprintf(" [green]%s[white]\n %s\n\n", item.Name(), item.PrettyEnd())
|
||||
} else {
|
||||
str = fmt.Sprintf(" [green]%s[white]\n %s - %s\n\n", item.Name(), item.PrettyStart(), item.PrettyEnd())
|
||||
}
|
||||
|
||||
return str
|
||||
}
|
||||
|
@ -29,3 +29,8 @@ func Widget() tview.Primitive {
|
||||
|
||||
return widget
|
||||
}
|
||||
|
||||
// icon returns an emoji for the current weather
|
||||
func icon() string {
|
||||
return ""
|
||||
}
|
||||
|
2
wtf.go
2
wtf.go
@ -12,7 +12,7 @@ func main() {
|
||||
app := tview.NewApplication()
|
||||
|
||||
grid := tview.NewGrid()
|
||||
grid.SetRows(10, 40, 4) // How _high_ the row is, in terminal rows
|
||||
grid.SetRows(14, 36, 4) // How _high_ the row is, in terminal rows
|
||||
grid.SetColumns(40, 40) // How _wide_ the column is, in terminal columns
|
||||
grid.SetBorder(false)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user