Skip to content

Commit 2bbc049

Browse files
committed
feat(tui): add modal display functionality to command interface
- Add `showing` field to track modal visibility state - Implement `Show()` method with centered modal overlay rendering - Add border styling and padding for modal presentation - Include state management methods `IsShowing()` and `SetShowing()`
1 parent 221915e commit 2bbc049

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

internal/tui/command.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ type Command struct {
6161
list list.Model
6262
choice *Slide
6363
quitting bool
64+
showing bool
6465
}
6566

6667
func NewCommand(rootSlide *Slide) Command {
@@ -175,10 +176,38 @@ func (m Command) View() string {
175176
return "\n" + content
176177
}
177178

179+
func (m Command) Show(slideView string, width, height int) string {
180+
view := m.View()
181+
modalContent := lipgloss.NewStyle().
182+
Border(lipgloss.RoundedBorder()).
183+
Width(90).
184+
Height(15).
185+
Padding(0, 4, 0, 4).
186+
BorderForeground(lipgloss.Color("#9999CC")).
187+
Render(view)
188+
189+
_, modalWidth := getLines(modalContent)
190+
modalHeight := strings.Count(modalContent, "\n") + 1
191+
192+
centerX := (width - modalWidth) / 2
193+
centerY := (height - modalHeight) / 2
194+
195+
return placeOverlay(centerX, centerY, modalContent, slideView)
196+
}
197+
178198
func (m Command) Choice() *Slide {
179199
return m.choice
180200
}
181201

202+
func (m Command) IsShowing() bool {
203+
return m.showing
204+
}
205+
206+
func (m Command) SetShowing(showing bool) Command {
207+
m.showing = showing
208+
return m
209+
}
210+
182211
type OpenCommandMsg struct{}
183212
type CloseCommandMsg struct {
184213
SelectedSlide *Slide

0 commit comments

Comments
 (0)