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

Constantize the defaultFocus value for each module

This commit is contained in:
Chris Cummer
2019-09-18 20:34:53 -07:00
parent d6208b4730
commit bf877f5fa7
120 changed files with 421 additions and 255 deletions

View File

@@ -5,17 +5,20 @@ import (
"github.com/wtfutil/wtf/cfg"
)
const defaultTitle = "ARPANSA UV Data"
const (
defaultFocusable = false
defaultTitle = "ARPANSA UV Data"
)
type Settings struct {
common *cfg.Common
city string;
city string
}
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
city: ymlConfig.UString("locationid"),
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
city: ymlConfig.UString("locationid"),
}
return &settings

View File

@@ -8,18 +8,18 @@ import (
type Widget struct {
view.TextWidget
location *location
location *location
lastError error
settings *Settings
settings *Settings
}
func NewWidget(app *tview.Application, settings *Settings) *Widget {
locationData, err := GetLocationData(settings.city)
widget := Widget {
TextWidget: view.NewTextWidget(app, settings.common, false),
location: locationData,
lastError: err,
settings: settings,
widget := Widget{
TextWidget: view.NewTextWidget(app, settings.common),
location: locationData,
lastError: err,
settings: settings,
}
widget.View.SetWrap(true)
@@ -50,32 +50,32 @@ func formatLocationData(location *location) string {
var color string
var content string
if(location.name == "") {
if location.name == "" {
return "[red]No data?"
}
if(location.status != "ok") {
if location.status != "ok" {
content = "[red]Data unavailable for "
content += location.name
return content
}
switch {
case location.index < 2.5:
color = "[green]"
level = " (LOW)"
case location.index >= 2.5 && location.index < 5.5:
color = "[yellow]"
level = " (MODERATE)"
case location.index >= 5.5 && location.index < 7.5:
color = "[orange]"
level = " (HIGH)"
case location.index >= 7.5 && location.index < 10.5:
color = "[red]"
level = " (VERY HIGH)"
case location.index >= 10.5:
color = "[fuchsia]"
level = " (EXTREME)"
case location.index < 2.5:
color = "[green]"
level = " (LOW)"
case location.index >= 2.5 && location.index < 5.5:
color = "[yellow]"
level = " (MODERATE)"
case location.index >= 5.5 && location.index < 7.5:
color = "[orange]"
level = " (HIGH)"
case location.index >= 7.5 && location.index < 10.5:
color = "[red]"
level = " (VERY HIGH)"
case location.index >= 10.5:
color = "[fuchsia]"
level = " (EXTREME)"
}
content = "Location: "

View File

@@ -5,7 +5,10 @@ import (
"github.com/wtfutil/wtf/cfg"
)
const defaultTitle = "Pretty Weather"
const (
defaultFocusable = false
defaultTitle = "Pretty Weather"
)
type Settings struct {
common *cfg.Common
@@ -17,9 +20,8 @@ type Settings struct {
}
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
city: ymlConfig.UString("city", "Barcelona"),
language: ymlConfig.UString("language", "en"),

View File

@@ -19,7 +19,7 @@ type Widget struct {
func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, settings.common, false),
TextWidget: view.NewTextWidget(app, settings.common),
settings: settings,
}

View File

@@ -7,7 +7,10 @@ import (
"github.com/wtfutil/wtf/cfg"
)
const defaultTitle = "Weather"
const (
defaultFocusable = true
defaultTitle = "Weather"
)
type colors struct {
current string
@@ -24,9 +27,8 @@ type Settings struct {
}
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_OWM_API_KEY"))),
cityIDs: ymlConfig.UList("cityids"),

View File

@@ -25,7 +25,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
widget := Widget{
KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
MultiSourceWidget: view.NewMultiSourceWidget(settings.common, "cityid", "cityids"),
TextWidget: view.NewTextWidget(app, settings.common, true),
TextWidget: view.NewTextWidget(app, settings.common),
pages: pages,
settings: settings,