mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
WTF-400 Move name and configKey values from widget to settings
This commit is contained in:
@@ -5,6 +5,8 @@ import (
|
||||
"github.com/wtfutil/wtf/cfg"
|
||||
)
|
||||
|
||||
const configKey = "prettyweather"
|
||||
|
||||
type Settings struct {
|
||||
common *cfg.Common
|
||||
|
||||
@@ -14,11 +16,11 @@ type Settings struct {
|
||||
language string
|
||||
}
|
||||
|
||||
func NewSettingsFromYAML(ymlConfig *config.Config) *Settings {
|
||||
localConfig, _ := ymlConfig.Get("wtf.mods.prettyweather")
|
||||
func NewSettingsFromYAML(name string, ymlConfig *config.Config) *Settings {
|
||||
localConfig, _ := ymlConfig.Get("wtf.mods." + configKey)
|
||||
|
||||
settings := Settings{
|
||||
common: cfg.NewCommonSettingsFromYAML(ymlConfig),
|
||||
common: cfg.NewCommonSettingsFromYAML(name, configKey, ymlConfig),
|
||||
|
||||
city: localConfig.UString("city", "Barcelona"),
|
||||
language: localConfig.UString("language", "en"),
|
||||
|
||||
@@ -18,7 +18,7 @@ type Widget struct {
|
||||
|
||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(app, "Pretty Weather", "prettyweather", false),
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common.Name, settings.common.ConfigKey, false),
|
||||
|
||||
settings: settings,
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import (
|
||||
"github.com/wtfutil/wtf/cfg"
|
||||
)
|
||||
|
||||
const configKey = "weather"
|
||||
|
||||
type colors struct {
|
||||
current string
|
||||
}
|
||||
@@ -21,11 +23,11 @@ type Settings struct {
|
||||
tempUnit string
|
||||
}
|
||||
|
||||
func NewSettingsFromYAML(ymlConfig *config.Config) *Settings {
|
||||
localConfig, _ := ymlConfig.Get("wtf.mods.weather")
|
||||
func NewSettingsFromYAML(name string, ymlConfig *config.Config) *Settings {
|
||||
localConfig, _ := ymlConfig.Get("wtf.mods." + configKey)
|
||||
|
||||
settings := Settings{
|
||||
common: cfg.NewCommonSettingsFromYAML(ymlConfig),
|
||||
common: cfg.NewCommonSettingsFromYAML(name, configKey, ymlConfig),
|
||||
|
||||
apiKey: localConfig.UString("apiKey", os.Getenv("WTF_OWM_API_KEY")),
|
||||
cityIDs: localConfig.UList("cityids"),
|
||||
|
||||
@@ -33,7 +33,7 @@ type Widget struct {
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
TextWidget: wtf.NewTextWidget(app, "Weather", "weather", true),
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common.Name, settings.common.ConfigKey, true),
|
||||
|
||||
Idx: 0,
|
||||
settings: settings,
|
||||
|
||||
Reference in New Issue
Block a user