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

Simplify the inclusion of the Common config settings into each module

Signed-off-by: Chris Cummer <chriscummer@me.com>
This commit is contained in:
Chris Cummer
2020-11-26 19:53:21 -08:00
parent f9a06540f1
commit d6a0797bf2
161 changed files with 378 additions and 330 deletions

View File

@@ -10,13 +10,13 @@ const (
)
type Settings struct {
common *cfg.Common
*cfg.Common
}
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
spacex := ymlConfig.UString("spacex")
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, spacex, defaultFocusable, ymlConfig, globalConfig),
Common: cfg.NewCommonSettingsFromModule(name, spacex, defaultFocusable, ymlConfig, globalConfig),
}
return &settings
}

View File

@@ -17,7 +17,7 @@ type Widget struct {
func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := &Widget{
TextWidget: view.NewTextWidget(app, nil, settings.common),
TextWidget: view.NewTextWidget(app, nil, settings.Common),
settings: settings,
}
return widget
@@ -46,19 +46,19 @@ func (widget *Widget) content() (string, string, bool) {
handleError(widget, err)
} else {
str = fmt.Sprintf("[%s]Mission[white]\n", widget.settings.common.Colors.Subheading)
str = fmt.Sprintf("[%s]Mission[white]\n", widget.settings.Colors.Subheading)
str += fmt.Sprintf("%s: %s\n", "Name", launch.MissionName)
str += fmt.Sprintf("%s: %s\n", "Date", wtf.UnixTime(launch.LaunchDate).Format(time.RFC822))
str += fmt.Sprintf("%s: %s\n", "Site", launch.LaunchSite.Name)
str += "\n"
str += fmt.Sprintf("[%s]Links[white]\n", widget.settings.common.Colors.Subheading)
str += fmt.Sprintf("[%s]Links[white]\n", widget.settings.Colors.Subheading)
str += fmt.Sprintf("%s: %s\n", "YouTube", launch.Links.YouTubeLink)
str += fmt.Sprintf("%s: %s\n", "Reddit", launch.Links.RedditLink)
if widget.CommonSettings().Height >= 2 {
str += "\n"
str += fmt.Sprintf("[%s]Details[white]\n", widget.settings.common.Colors.Subheading)
str += fmt.Sprintf("[%s]Details[white]\n", widget.settings.Colors.Subheading)
str += fmt.Sprintf("%s: %s\n", "RocketName", launch.Rocket.Name)
str += fmt.Sprintf("%s: %s\n", "Details", launch.Details)
}