diff --git a/internal/ui/initial.go b/internal/ui/initial.go index 74d0d56..cc28117 100644 --- a/internal/ui/initial.go +++ b/internal/ui/initial.go @@ -17,9 +17,13 @@ func InitialModel(db *sql.DB, config Config) model { tlSelItemStyle := lipgloss.NewStyle().Foreground(lipgloss.Color(config.TaskListColor)) var taskList list.Model + var spacing int + if config.ShowContext { + spacing = 1 + } switch config.ListDensity { case Compact: - taskList = list.New(taskItems, newListDelegate(lipgloss.Color(config.TaskListColor), false, 1), taskSummaryWidth, defaultListHeight) + taskList = list.New(taskItems, newListDelegate(lipgloss.Color(config.TaskListColor), false, spacing), taskSummaryWidth, defaultListHeight) case Spacious: taskList = list.New(taskItems, newListDelegate(lipgloss.Color(config.TaskListColor), true, 1), taskSummaryWidth, defaultListHeight) } @@ -45,7 +49,7 @@ func InitialModel(db *sql.DB, config Config) model { var archivedTaskList list.Model switch config.ListDensity { case Compact: - archivedTaskList = list.New(archivedTaskItems, newListDelegate(lipgloss.Color(config.ArchivedTaskListColor), false, 1), taskSummaryWidth, defaultListHeight) + archivedTaskList = list.New(archivedTaskItems, newListDelegate(lipgloss.Color(config.ArchivedTaskListColor), false, spacing), taskSummaryWidth, defaultListHeight) case Spacious: archivedTaskList = list.New(archivedTaskItems, newListDelegate(lipgloss.Color(config.ArchivedTaskListColor), true, 1), taskSummaryWidth, defaultListHeight) } diff --git a/internal/ui/update.go b/internal/ui/update.go index 92f2902..824e537 100644 --- a/internal/ui/update.go +++ b/internal/ui/update.go @@ -807,6 +807,11 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { var tlDel list.DefaultDelegate var atlDel list.DefaultDelegate + var spacing int + if m.cfg.ShowContext { + spacing = 1 + } + switch m.cfg.ListDensity { case Compact: tlDel = newListDelegate(lipgloss.Color(m.cfg.TaskListColor), true, 1) @@ -815,13 +820,14 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.cfg.ListDensity = Spacious case Spacious: - tlDel = newListDelegate(lipgloss.Color(m.cfg.TaskListColor), false, 1) - atlDel = newListDelegate(lipgloss.Color(m.cfg.ArchivedTaskListColor), false, 1) + tlDel = newListDelegate(lipgloss.Color(m.cfg.TaskListColor), false, spacing) + atlDel = newListDelegate(lipgloss.Color(m.cfg.ArchivedTaskListColor), false, spacing) m.cfg.ListDensity = Compact } m.taskList.SetDelegate(tlDel) m.archivedTaskList.SetDelegate(atlDel) + for i, li := range m.taskList.Items() { t, ok := li.(types.Task) if ok { @@ -860,6 +866,17 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { listHeight = m.terminalHeight - h - h3 - 1 } + if m.cfg.ListDensity == Compact { + var spacing int + if m.cfg.ShowContext { + spacing = 1 + } + tlDel := newListDelegate(lipgloss.Color(m.cfg.TaskListColor), false, spacing) + atlDel := newListDelegate(lipgloss.Color(m.cfg.ArchivedTaskListColor), false, spacing) + m.taskList.SetDelegate(tlDel) + m.archivedTaskList.SetDelegate(atlDel) + } + m.taskList.SetHeight(listHeight) m.archivedTaskList.SetHeight(listHeight)