package steps import ( "fmt" "miasma-installer/tui/styles" tea "github.com/charmbracelet/bubbletea" ) type ConfirmModel struct { Disk string EnableLUKS bool Hostname string Username string Confirmed bool Finished bool } func NewConfirmModel(disk string, enableLUKS bool, hostname string, username string) ConfirmModel { return ConfirmModel{ Disk: disk, EnableLUKS: enableLUKS, Hostname: hostname, Username: username, } } func (m ConfirmModel) Init() tea.Cmd { return nil } func (m ConfirmModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { if m.Finished { return m, nil } switch msg := msg.(type) { case tea.KeyMsg: switch msg.String() { case "y": m.Confirmed = true m.Finished = true return m, nil case "n": m.Confirmed = false m.Finished = true return m, nil } } return m, nil } func (m ConfirmModel) View() string { s := styles.TitleStyle.Render("Confirm Installation") s += "\n\n" s += "Please review your installation settings:\n\n" s += fmt.Sprintf(" Disk: %s\n", m.Disk) s += fmt.Sprintf(" Encryption: %s\n", map[bool]string{true: "Enabled (LUKS2)", false: "Disabled"}[m.EnableLUKS]) s += fmt.Sprintf(" Hostname: %s\n", m.Hostname) s += fmt.Sprintf(" Username: %s\n", m.Username) s += fmt.Sprintf(" Filesystem: btrfs\n") s += fmt.Sprintf(" Desktop: Cosmic Desktop\n") s += fmt.Sprintf(" Kernel: linux-hardened\n") s += fmt.Sprintf(" Bootloader: systemd-boot (UEFI)\n") s += "\n" s += styles.HelpStyle.Render("WARNING: This will ERASE ALL DATA on ") + m.Disk + "\n\n" s += styles.HelpStyle.Render("[y] Proceed with installation [n] Cancel") return styles.MainStyle.Render(s) }