ficsit-cli-flake/tea/components/header.go
Vilsol 5f2e60a9e2
feat: multi targets (#44)
* feat: use mod version targets

* chore: lint

* chore: remove unused

* chore: target dev on ci

* fix: rename WindowsNoEditor target to Windows
fix: close file reader

* fix: ensure closure of downloaded mod

* fix: ensure all important events are sent

* fix: lock adding files to cache

---------

Co-authored-by: mircearoata <mircearoatapalade@gmail.com>
2023-12-07 18:57:31 +02:00

66 lines
1.3 KiB
Go

package components
import (
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/satisfactorymodding/ficsit-cli/tea/utils"
)
var _ tea.Model = (*headerComponent)(nil)
type headerComponent struct {
root RootModel
labelStyle lipgloss.Style
}
func NewHeaderComponent(root RootModel) tea.Model {
return headerComponent{
root: root,
labelStyle: utils.LabelStyle,
}
}
func (h headerComponent) Init() tea.Cmd {
return nil
}
func (h headerComponent) Update(_ tea.Msg) (tea.Model, tea.Cmd) {
return h, nil
}
func (h headerComponent) View() string {
out := h.labelStyle.Render("Installation: ")
if h.root.GetCurrentInstallation() != nil {
out += h.root.GetCurrentInstallation().Path
} else {
out += "None"
}
out += "\n"
out += h.labelStyle.Render("Profile: ")
if h.root.GetCurrentProfile() != nil {
out += h.root.GetCurrentProfile().Name
} else {
out += "None"
}
out += "\n"
out += h.labelStyle.Render("Vanilla: ")
if h.root.GetCurrentInstallation() != nil {
if h.root.GetCurrentInstallation().Vanilla {
out += "On"
} else {
out += "Off"
}
} else {
out += "N/A"
}
if h.root.GetProvider().IsOffline() {
out += "\n"
out += h.labelStyle.Render("Offline")
}
return lipgloss.NewStyle().Margin(1, 0).Render(out)
}