Fix table formatting

This commit is contained in:
Martin
2024-05-25 00:28:34 +02:00
parent f7b54b607b
commit 5d930685a3
8 changed files with 235 additions and 249 deletions

View File

@ -96,7 +96,7 @@ func (p *ContextPickerPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
func (p *ContextPickerPage) View() string {
return p.common.Styles.Main.Render(p.form.View())
return p.common.Styles.Base.Render(p.form.View())
}
func (p *ContextPickerPage) updateContextCmd() tea.Msg {

View File

@ -92,7 +92,7 @@ func (p *ProjectPickerPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
func (p *ProjectPickerPage) View() string {
return p.common.Styles.Main.Render(p.form.View())
return p.common.Styles.Base.Render(p.form.View())
}
func (p *ProjectPickerPage) updateProjectCmd() tea.Msg {

View File

@ -2,7 +2,6 @@
package pages
import (
"log/slog"
"tasksquire/common"
"tasksquire/components/table"
"tasksquire/taskwarrior"
@ -34,15 +33,15 @@ func NewReportPage(com *common.Common, report *taskwarrior.Report) *ReportPage {
activeReport: report,
activeContext: com.TW.GetActiveContext(),
activeProject: "",
taskTable: table.New(com),
}
}
func (p *ReportPage) SetSize(width int, height int) {
p.common.SetSize(width, height)
slog.Info("FramSize", "vert", p.common.Styles.Main.GetVerticalFrameSize(), "horz", p.common.Styles.Main.GetHorizontalFrameSize())
p.taskTable.SetWidth(width - p.common.Styles.Main.GetVerticalFrameSize())
p.taskTable.SetHeight(height - p.common.Styles.Main.GetHorizontalFrameSize())
p.taskTable.SetWidth(width - p.common.Styles.Base.GetVerticalFrameSize())
p.taskTable.SetHeight(height - p.common.Styles.Base.GetHorizontalFrameSize())
}
func (p *ReportPage) Init() tea.Cmd {
@ -130,9 +129,9 @@ func (p *ReportPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
func (p *ReportPage) View() string {
// return p.common.Styles.Main.Render(p.taskTable.View()) + "\n"
if p.tasks == nil || len(p.tasks) == 0 {
return p.common.Styles.Main.Render("No tasks found")
return p.common.Styles.Base.Render("No tasks found")
}
return p.common.Styles.Main.Render(p.taskTable.View())
return p.taskTable.View()
}
func (p *ReportPage) populateTaskTable(tasks taskwarrior.Tasks) {
@ -151,11 +150,12 @@ func (p *ReportPage) populateTaskTable(tasks taskwarrior.Tasks) {
}
p.taskTable = table.New(
p.common,
table.WithReport(p.activeReport),
table.WithTasks(tasks),
table.WithFocused(true),
table.WithWidth(p.common.Width()-p.common.Styles.Main.GetVerticalFrameSize()),
table.WithHeight(p.common.Height()-p.common.Styles.Main.GetHorizontalFrameSize()-10),
table.WithWidth(p.common.Width()-p.common.Styles.Base.GetVerticalFrameSize()),
table.WithHeight(p.common.Height()-p.common.Styles.Base.GetHorizontalFrameSize()-1),
table.WithStyles(p.common.Styles.TableStyle),
)

View File

@ -93,7 +93,7 @@ func (p *ReportPickerPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
func (p *ReportPickerPage) View() string {
return p.common.Styles.Main.Render(p.form.View())
return p.common.Styles.Base.Render(p.form.View())
}
func (p *ReportPickerPage) updateReportCmd() tea.Msg {

View File

@ -314,7 +314,7 @@ func (s *StatusLine) View() string {
var mode string
switch s.mode {
case ModeNormal:
mode = s.common.Styles.Main.Render("NORMAL")
mode = s.common.Styles.Base.Render("NORMAL")
case ModeInsert:
mode = s.common.Styles.Active.Inline(true).Render("INSERT")
}