[WIP] Layout
This commit is contained in:
45
pages/main.go
Normal file
45
pages/main.go
Normal file
@ -0,0 +1,45 @@
|
||||
package pages
|
||||
|
||||
import (
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
|
||||
"tasksquire/common"
|
||||
)
|
||||
|
||||
type MainPage struct {
|
||||
common *common.Common
|
||||
activePage common.Component
|
||||
}
|
||||
|
||||
func NewMainPage(common *common.Common) *MainPage {
|
||||
m := &MainPage{
|
||||
common: common,
|
||||
}
|
||||
|
||||
m.activePage = NewReportPage(common, common.TW.GetReport(common.TW.GetConfig().Get("uda.tasksquire.report.default")))
|
||||
|
||||
return m
|
||||
|
||||
}
|
||||
|
||||
func (m *MainPage) Init() tea.Cmd {
|
||||
return m.activePage.Init()
|
||||
}
|
||||
|
||||
func (m *MainPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
var cmd tea.Cmd
|
||||
|
||||
switch msg := msg.(type) {
|
||||
case tea.WindowSizeMsg:
|
||||
m.common.SetSize(msg.Width, msg.Height)
|
||||
}
|
||||
|
||||
activePage, cmd := m.activePage.Update(msg)
|
||||
m.activePage = activePage.(common.Component)
|
||||
|
||||
return m, cmd
|
||||
}
|
||||
|
||||
func (m *MainPage) View() string {
|
||||
return m.activePage.View()
|
||||
}
|
||||
Reference in New Issue
Block a user