Integrate tasktable
This commit is contained in:
@@ -4,7 +4,7 @@ import (
|
||||
"tasksquire/internal/common"
|
||||
|
||||
tea "charm.land/bubbletea/v2"
|
||||
// "charm.land/bubbles/v2/key"
|
||||
"charm.land/bubbles/v2/key"
|
||||
"charm.land/lipgloss/v2"
|
||||
)
|
||||
|
||||
@@ -34,33 +34,30 @@ func NewMainPage(common *common.Common) *MainPage {
|
||||
}
|
||||
|
||||
func (m *MainPage) Init() tea.Cmd {
|
||||
return tea.Batch(m.taskPage.Init())
|
||||
// return tea.Batch(m.taskPage.Init(), m.timePage.Init())
|
||||
return tea.Batch()
|
||||
}
|
||||
|
||||
func (m *MainPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
var cmd tea.Cmd
|
||||
|
||||
// switch msg := msg.(type) {
|
||||
// case tea.WindowSizeMsg:
|
||||
// m.width = msg.Width
|
||||
// m.height = msg.Height
|
||||
// m.common.SetSize(msg.Width, msg.Height)
|
||||
//
|
||||
// tabHeight := lipgloss.Height(m.renderTabBar())
|
||||
// contentHeight := msg.Height - tabHeight
|
||||
// if contentHeight < 0 {
|
||||
// contentHeight = 0
|
||||
// }
|
||||
//
|
||||
// newMsg := tea.WindowSizeMsg{Width: msg.Width, Height: contentHeight}
|
||||
// activePage, cmd := m.activePage.Update(newMsg)
|
||||
// m.activePage = activePage.(common.Component)
|
||||
// return m, cmd
|
||||
//
|
||||
// case tea.KeyMsg:
|
||||
// // Only handle tab key for page switching when at the top level (no subpages active)
|
||||
// if key.Matches(msg, m.common.Keymap.Next) && !m.common.HasSubpages() {
|
||||
switch msg := msg.(type) {
|
||||
case tea.WindowSizeMsg:
|
||||
m.width = msg.Width
|
||||
m.height = msg.Height
|
||||
m.common.SetSize(msg.Width, msg.Height)
|
||||
|
||||
tabHeight := lipgloss.Height(m.renderTabBar())
|
||||
contentHeight := max(msg.Height - tabHeight, 0)
|
||||
|
||||
newMsg := tea.WindowSizeMsg{Width: msg.Width, Height: contentHeight}
|
||||
activePage, cmd := m.activePage.Update(newMsg)
|
||||
m.activePage = activePage.(common.Component)
|
||||
return m, cmd
|
||||
|
||||
case tea.KeyMsg:
|
||||
// Only handle tab key for page switching when at the top level (no subpages active)
|
||||
if key.Matches(msg, m.common.Keymap.Next) && !m.common.HasSubpages() {
|
||||
// if m.activePage == m.taskPage {
|
||||
// m.activePage = m.timePage
|
||||
// m.currentTab = 1
|
||||
@@ -69,18 +66,16 @@ func (m *MainPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
// m.currentTab = 0
|
||||
// }
|
||||
//
|
||||
// tabHeight := lipgloss.Height(m.renderTabBar())
|
||||
// contentHeight := m.height - tabHeight
|
||||
// if contentHeight < 0 {
|
||||
// contentHeight = 0
|
||||
// }
|
||||
// m.activePage.SetSize(m.width, contentHeight)
|
||||
//
|
||||
// // Trigger a refresh/init on switch? Maybe not needed if we keep state.
|
||||
// // But we might want to refresh data.
|
||||
// return m, m.activePage.Init()
|
||||
// }
|
||||
// }
|
||||
tabHeight := lipgloss.Height(m.renderTabBar())
|
||||
contentHeight := m.height - tabHeight
|
||||
if contentHeight < 0 {
|
||||
contentHeight = 0
|
||||
}
|
||||
m.activePage.SetSize(m.width, contentHeight)
|
||||
|
||||
return m, m.activePage.Init()
|
||||
}
|
||||
}
|
||||
//
|
||||
activePage, cmd := m.activePage.Update(msg)
|
||||
m.activePage = activePage.(common.Component)
|
||||
|
||||
Reference in New Issue
Block a user