Skip to content

Commit

Permalink
feat: remove spacing in full screen compact mode
Browse files Browse the repository at this point in the history
Spacing needs to be 1 for compact mode when the context pane is visible.
This is due to a quirk in how the list bubble renders. The list renders
with 1 extra line in this case, which pushes the whole view up, causing
UI inconsistencies. Handling this case by investigating the state of the
model has been frustratingly futile, so spacing stays at 1 for this view
for now.
  • Loading branch information
dhth committed Jul 25, 2024
1 parent 87f3c26 commit ef9543c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
8 changes: 6 additions & 2 deletions internal/ui/initial.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down
21 changes: 19 additions & 2 deletions internal/ui/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit ef9543c

Please sign in to comment.