mirror of
https://github.com/anotherhadi/usbguard-tui.git
synced 2026-10-05 18:28:24 +02:00
@@ -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"
|
||||||
@@ -12,6 +13,7 @@ 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{
|
||||||
|
|||||||
Reference in New Issue
Block a user