package tui import "github.com/charmbracelet/lipgloss/v2" type ModalType int const ( ModalTypeSearch ModalType = iota ModalTypeClient ModalTypeProject ModalTypeDeleteConfirmation ModalTypeEntry ) type ModalBoxModel struct { Active bool Type ModalType } func (m ModalBoxModel) RenderCenteredOver(mainContent string, app AppModel) string { if !m.Active { return mainContent } modalContent := m.Render() base := lipgloss.NewLayer(mainContent) overlayWidth := 60 overlayHeight := 5 overlayLeft := (app.width - overlayWidth) / 2 overlayTop := (app.height - overlayHeight) / 2 overlayStyle := lipgloss.NewStyle().Height(overlayHeight).Width(overlayWidth).Border(lipgloss.RoundedBorder()).BorderForeground(lipgloss.Color("238")) overlay := lipgloss.NewLayer(overlayStyle.Render(modalContent)).Width(overlayWidth).Height(overlayHeight) canvas := lipgloss.NewCanvas( base.Z(0), overlay.X(overlayLeft).Y(overlayTop).Z(1), ) return canvas.Render() } func (m ModalBoxModel) Render() string { switch m.Type { case ModalTypeSearch: return "SEARCH BOX" default: // REMOVE ME return "DEFAULT CONTENT" } } func (m *ModalBoxModel) activate(t ModalType) { m.Active = true m.Type = t }