diff options
author | T <t@tjp.lol> | 2025-08-06 16:00:05 -0600 |
---|---|---|
committer | T <t@tjp.lol> | 2025-08-06 16:26:00 -0600 |
commit | c53e8c4e41aa88566b101431bcd104ebf7b34312 (patch) | |
tree | 614e1c911fae328cfdb1a35050bf94658d9253f8 /internal/tui/modal.go | |
parent | 65e2ed65775d64afbc6065a3b4ac1069020093ca (diff) |
TUI fixes, and WIP modal dialog rendering
Diffstat (limited to 'internal/tui/modal.go')
-rw-r--r-- | internal/tui/modal.go | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/internal/tui/modal.go b/internal/tui/modal.go new file mode 100644 index 0000000..3a57880 --- /dev/null +++ b/internal/tui/modal.go @@ -0,0 +1,59 @@ +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 +} |