2021-12-02 04:00:33 +00:00
|
|
|
package components
|
|
|
|
|
|
|
|
import (
|
|
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
|
|
"github.com/charmbracelet/lipgloss"
|
2022-10-14 16:11:16 +00:00
|
|
|
|
2021-12-02 04:00:33 +00:00
|
|
|
"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
|
|
|
|
}
|
|
|
|
|
2023-06-18 15:48:53 +00:00
|
|
|
func (h headerComponent) Update(_ tea.Msg) (tea.Model, tea.Cmd) {
|
2021-12-02 04:00:33 +00:00
|
|
|
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"
|
|
|
|
}
|
2023-12-06 04:02:06 +00:00
|
|
|
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"
|
|
|
|
}
|
2021-12-02 04:00:33 +00:00
|
|
|
|
2023-12-07 16:57:31 +00:00
|
|
|
if h.root.GetProvider().IsOffline() {
|
2023-12-06 04:47:41 +00:00
|
|
|
out += "\n"
|
|
|
|
out += h.labelStyle.Render("Offline")
|
|
|
|
}
|
|
|
|
|
2021-12-02 04:00:33 +00:00
|
|
|
return lipgloss.NewStyle().Margin(1, 0).Render(out)
|
|
|
|
}
|