batman
This commit is contained in:
+65
@@ -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?"
|
||||
}
|
||||
Reference in New Issue
Block a user