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 -------------------- */
|
/* -------------------- Public Functions -------------------- */
|
||||||
|
|
||||||
|
func (item *Item) IsOneDay() bool {
|
||||||
|
return item.Start == item.End
|
||||||
|
}
|
||||||
|
|
||||||
func (item *Item) Name() string {
|
func (item *Item) Name() string {
|
||||||
if (item.Employee != Employee{}) {
|
if (item.Employee != Employee{}) {
|
||||||
return item.Employee.Name
|
return item.Employee.Name
|
||||||
|
@ -12,15 +12,26 @@ func Widget() tview.Primitive {
|
|||||||
widget := tview.NewTextView()
|
widget := tview.NewTextView()
|
||||||
widget.SetBorder(true)
|
widget.SetBorder(true)
|
||||||
widget.SetDynamicColors(true)
|
widget.SetDynamicColors(true)
|
||||||
widget.SetTitle(" 🐨 Away ")
|
widget.SetTitle(fmt.Sprintf(" 🐨 Away (%d)", len(items)))
|
||||||
|
|
||||||
data := ""
|
data := ""
|
||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
str := fmt.Sprintf(" [green]%s[white]\n %s - %s\n\n", item.Name(), item.PrettyStart(), item.PrettyEnd())
|
data = data + display(item)
|
||||||
data = data + str
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprintf(widget, "%s", data)
|
fmt.Fprintf(widget, "%s", data)
|
||||||
|
|
||||||
return widget
|
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
|
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()
|
app := tview.NewApplication()
|
||||||
|
|
||||||
grid := tview.NewGrid()
|
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.SetColumns(40, 40) // How _wide_ the column is, in terminal columns
|
||||||
grid.SetBorder(false)
|
grid.SetBorder(false)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user