Fix width in modal

Signed-off-by: Hadi <[email protected]>
This commit is contained in:
Hadi
2026-08-23 17:14:19 +02:00
parent 2d6c337610
commit 2e91b6bc2a
+9 -4
View File
@@ -2,6 +2,7 @@ package main
import ( import (
tea "charm.land/bubbletea/v2" tea "charm.land/bubbletea/v2"
"charm.land/lipgloss/v2"
"github.com/anotherhadi/ilovetui/app" "github.com/anotherhadi/ilovetui/app"
"github.com/anotherhadi/ilovetui/modal" "github.com/anotherhadi/ilovetui/modal"
"github.com/anotherhadi/ilovetui/notification" "github.com/anotherhadi/ilovetui/notification"
@@ -9,9 +10,10 @@ import (
) )
type appModel struct { type appModel struct {
core ui.Model core ui.Model
modals modal.Model modals modal.Model
notif notification.Model notif notification.Model
width, height int
} }
func newApp() appModel { func newApp() appModel {
@@ -30,6 +32,9 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
if _, ok := msg.(app.QuitMsg); ok { if _, ok := msg.(app.QuitMsg); ok {
return a, tea.Quit return a, tea.Quit
} }
if sizeMsg, ok := msg.(tea.WindowSizeMsg); ok {
a.width, a.height = sizeMsg.Width, sizeMsg.Height
}
a.core.ModalOpen = a.modals.Open() a.core.ModalOpen = a.modals.Open()
var coreCmd tea.Cmd var coreCmd tea.Cmd
@@ -43,7 +48,7 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
} }
func (a appModel) View() tea.View { func (a appModel) View() tea.View {
bg := a.core.View() bg := lipgloss.Place(a.width, a.height, lipgloss.Left, lipgloss.Top, a.core.View())
bg = a.modals.Render(bg) bg = a.modals.Render(bg)
bg = a.notif.Render(bg) bg = a.notif.Render(bg)
return tea.View{ return tea.View{