mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Widgetized Status
This commit is contained in:
parent
951da43f99
commit
8a258225c9
@ -2,17 +2,47 @@ package status
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
func Widget() tview.Primitive {
|
||||
widget := tview.NewTextView()
|
||||
widget.SetBorder(true)
|
||||
widget.SetDynamicColors(true)
|
||||
widget.SetTitle(" 🦊 Status ")
|
||||
|
||||
fmt.Fprintf(widget, "%s", "cats and gods\ndogs and tacs")
|
||||
|
||||
return widget
|
||||
type Widget struct {
|
||||
RefreshedAt time.Time
|
||||
View *tview.TextView
|
||||
}
|
||||
|
||||
func NewWidget() *Widget {
|
||||
widget := Widget{
|
||||
RefreshedAt: time.Now(),
|
||||
}
|
||||
|
||||
widget.addView()
|
||||
|
||||
return &widget
|
||||
}
|
||||
|
||||
/* -------------------- Exported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) Refresh() {
|
||||
widget.View.SetTitle(" 🦊 Status ")
|
||||
widget.RefreshedAt = time.Now()
|
||||
|
||||
fmt.Fprintf(widget.View, "%s", widget.contentFrom())
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) addView() {
|
||||
view := tview.NewTextView()
|
||||
|
||||
view.SetBorder(true)
|
||||
view.SetDynamicColors(true)
|
||||
view.SetTitle(" BambooHR ")
|
||||
|
||||
widget.View = view
|
||||
}
|
||||
|
||||
func (widget *Widget) contentFrom() string {
|
||||
return "cats and gods\ndogs and tacs"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user