This commit is contained in:
jb
2026-03-05 08:46:04 -03:00
commit 315807bbab
10 changed files with 308 additions and 0 deletions
+65
View File
@@ -0,0 +1,65 @@
package tui
import (
"fmt"
"strings"
tea "charm.land/bubbletea/v2"
)
const header = "App do Dono - Instalador Cliente"
func (m Model) View() tea.View {
pad := strings.Repeat(" ", padding)
var body string
switch m.currentStep {
case StepCheckDocker:
body = m.viewCheckDocker()
case StepDockerInstall:
body = m.viewDockerInstall()
case StepIPQuestion:
body = m.viewIPQuestion()
}
help := HelpStyle.Render("Pressione q ou ctrl+c para sair")
return tea.NewView(fmt.Sprintf("\n%s%s\n\n%s\n\n%s%s\n",
pad, TitleStyle.Render(header),
body,
pad, help,
))
}
func (m Model) viewCheckDocker() string {
pad := strings.Repeat(" ", padding)
return pad + "Avaliando instalação do Docker. Aguarde..."
}
func (m Model) viewDockerInstall() string {
pad := strings.Repeat(" ", padding)
options := []string{"Instalar automaticamente", "Instalar manualmente"}
var sb strings.Builder
sb.WriteString(pad + "Nenhuma versão do Docker encontrada.\n")
sb.WriteString(pad + "Deseja:\n\n")
for i, opt := range options {
cursor := " "
if m.cursor == i {
cursor = CursorStyle.Render("> ")
}
sb.WriteString(pad + cursor + opt + "\n")
}
if m.err != nil {
sb.WriteString("\n" + pad + ErrorStyle.Render("Erro: "+m.err.Error()))
}
return sb.String()
}
func (m Model) viewIPQuestion() string {
pad := strings.Repeat(" ", padding)
return pad + "Existe IP público disponível para a máquina?"
}