[WIP] Layout

This commit is contained in:
Martin Pander
2024-05-22 16:20:57 +02:00
parent a23b76c3c9
commit 14dbfc406d
15 changed files with 378 additions and 160 deletions

View File

@ -4,24 +4,47 @@ import (
"context"
"tasksquire/taskwarrior"
tea "github.com/charmbracelet/bubbletea"
)
type Common struct {
Ctx context.Context
PageStack *Stack[tea.Model]
TW taskwarrior.TaskWarrior
Keymap *Keymap
Styles *Styles
Ctx context.Context
TW taskwarrior.TaskWarrior
Keymap *Keymap
Styles *Styles
pageStack *Stack[Component]
width int
height int
}
func NewCommon(ctx context.Context, tw taskwarrior.TaskWarrior) *Common {
return &Common{
Ctx: ctx,
PageStack: NewStack[tea.Model](),
TW: tw,
Keymap: NewKeymap(),
Styles: NewStyles(tw.GetConfig()),
Ctx: ctx,
TW: tw,
Keymap: NewKeymap(),
Styles: NewStyles(tw.GetConfig()),
pageStack: NewStack[Component](),
}
}
func (c *Common) SetSize(width, height int) {
c.width = width
c.height = height
}
func (c *Common) Width() int {
return c.width
}
func (c *Common) Height() int {
return c.height
}
func (c *Common) PushPage(page Component) {
c.pageStack.Push(page)
}
func (c *Common) PopPage() (Component, error) {
return c.pageStack.Pop()
}