1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

BaseWidget added to start reducing some of the code duplication

This commit is contained in:
Chris Cummer
2018-03-30 22:29:19 -07:00
committed by Chris Cummer
parent a09691c86f
commit b937d64d75
5 changed files with 36 additions and 22 deletions

View File

@@ -7,18 +7,21 @@ import (
owm "github.com/briandowns/openweathermap"
"github.com/rivo/tview"
"github.com/senorprogrammer/wtf/wtf"
)
type Widget struct {
RefreshedAt time.Time
RefreshInterval int
View *tview.TextView
wtf.BaseWidget
View *tview.TextView
}
func NewWidget() *Widget {
widget := Widget{
RefreshedAt: time.Now(),
RefreshInterval: 600,
BaseWidget: wtf.BaseWidget{
Name: "Weather",
RefreshedAt: time.Now(),
RefreshInterval: 600,
},
}
widget.addView()
@@ -110,6 +113,8 @@ func icon(data *owm.CurrentWeatherData) string {
icon = "🌥"
case "partly cloudy":
icon = "🌤"
case "scattered clouds":
icon = "☁️"
case "snow":
icon = "❄️"
case "sunny":