mirror of
https://github.com/anotherhadi/usbguard-tui.git
synced 2026-10-05 18:28:24 +02:00
Min-width, style & mouse support
Signed-off-by: Hadi <[email protected]>
This commit is contained in:
+22
-3
@@ -4,23 +4,33 @@ import (
|
||||
tea "charm.land/bubbletea/v2"
|
||||
"charm.land/lipgloss/v2"
|
||||
"github.com/anotherhadi/ilovetui/app"
|
||||
"github.com/anotherhadi/ilovetui/minsize"
|
||||
"github.com/anotherhadi/ilovetui/modal"
|
||||
"github.com/anotherhadi/ilovetui/notification"
|
||||
"github.com/anotherhadi/usbguard-tui/ui"
|
||||
zone "github.com/lrstanley/bubblezone/v2"
|
||||
)
|
||||
|
||||
const (
|
||||
minWidth = 40
|
||||
minHeight = 15
|
||||
)
|
||||
|
||||
type appModel struct {
|
||||
core ui.Model
|
||||
modals modal.Model
|
||||
notif notification.Model
|
||||
minsize minsize.Model
|
||||
width, height int
|
||||
}
|
||||
|
||||
func newApp() appModel {
|
||||
zone.NewGlobal()
|
||||
return appModel{
|
||||
core: ui.New(),
|
||||
modals: modal.New(),
|
||||
notif: notification.New(),
|
||||
core: ui.New(),
|
||||
modals: modal.New(),
|
||||
notif: notification.New(),
|
||||
minsize: minsize.New(minWidth, minHeight),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,9 +58,18 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
}
|
||||
|
||||
func (a appModel) View() tea.View {
|
||||
if !a.minsize.Fits(a.width, a.height) {
|
||||
return tea.View{
|
||||
Content: a.minsize.View(a.width, a.height),
|
||||
AltScreen: true,
|
||||
WindowTitle: "USBGuard TUI",
|
||||
}
|
||||
}
|
||||
|
||||
bg := lipgloss.Place(a.width, a.height, lipgloss.Left, lipgloss.Top, a.core.View())
|
||||
bg = a.modals.Render(bg)
|
||||
bg = a.notif.Render(bg)
|
||||
bg = zone.Scan(bg)
|
||||
return tea.View{
|
||||
Content: bg,
|
||||
AltScreen: true,
|
||||
|
||||
Reference in New Issue
Block a user