diff --git a/internal/ui/initial.go b/internal/ui/initial.go index b5f0fe1..a1c8f9b 100644 --- a/internal/ui/initial.go +++ b/internal/ui/initial.go @@ -19,9 +19,9 @@ func InitialModel(db *sql.DB, config Config) model { var taskList list.Model switch config.ListDensity { case Compact: - taskList = list.New(taskItems, newCompactListDel(lipgloss.Color(config.TaskListColor)), taskSummaryWidth, defaultListHeight) + taskList = list.New(taskItems, newListDelegate(lipgloss.Color(config.TaskListColor), false), taskSummaryWidth, defaultListHeight) case Spacious: - taskList = list.New(taskItems, newSpaciousListDel(lipgloss.Color(config.TaskListColor)), taskSummaryWidth, defaultListHeight) + taskList = list.New(taskItems, newListDelegate(lipgloss.Color(config.TaskListColor), true), taskSummaryWidth, defaultListHeight) } taskList.Title = config.TaskListTitle taskList.SetFilteringEnabled(true) @@ -44,9 +44,9 @@ func InitialModel(db *sql.DB, config Config) model { var archivedTaskList list.Model switch config.ListDensity { case Compact: - archivedTaskList = list.New(archivedTaskItems, newCompactListDel(lipgloss.Color(config.ArchivedTaskListColor)), taskSummaryWidth, defaultListHeight) + archivedTaskList = list.New(archivedTaskItems, newListDelegate(lipgloss.Color(config.ArchivedTaskListColor), false), taskSummaryWidth, defaultListHeight) case Spacious: - archivedTaskList = list.New(archivedTaskItems, newSpaciousListDel(lipgloss.Color(config.ArchivedTaskListColor)), taskSummaryWidth, defaultListHeight) + archivedTaskList = list.New(archivedTaskItems, newListDelegate(lipgloss.Color(config.ArchivedTaskListColor), true), taskSummaryWidth, defaultListHeight) } archivedTaskList.Title = "archived" archivedTaskList.SetShowStatusBar(true) @@ -68,7 +68,7 @@ func InitialModel(db *sql.DB, config Config) model { taskInput.CharLimit = types.TaskSummaryMaxLen taskInput.Width = taskSummaryWidth - contextBMList := list.New(nil, newContextURLListDel(contextBMColor), taskSummaryWidth, defaultListHeight) + contextBMList := list.New(nil, newListDelegate(lipgloss.Color(contextBMColor), false), taskSummaryWidth, defaultListHeight) contextBMList.Title = "task bookmarks" contextBMList.SetShowHelp(false) diff --git a/internal/ui/list_delegate.go b/internal/ui/list_delegate.go index 59f4cc9..5effbac 100644 --- a/internal/ui/list_delegate.go +++ b/internal/ui/list_delegate.go @@ -5,22 +5,10 @@ import ( "github.com/charmbracelet/lipgloss" ) -func newCompactListDel(color lipgloss.Color) list.DefaultDelegate { +func newListDelegate(color lipgloss.Color, showDesc bool) list.DefaultDelegate { d := list.NewDefaultDelegate() - d.ShowDescription = false - d.SetHeight(1) - d.Styles.SelectedTitle = d.Styles. - SelectedTitle. - Foreground(color). - BorderLeftForeground(color) - d.Styles.FilterMatch = lipgloss.NewStyle() - - return d -} - -func newSpaciousListDel(color lipgloss.Color) list.DefaultDelegate { - d := list.NewDefaultDelegate() + d.ShowDescription = showDesc d.Styles.SelectedTitle = d.Styles. SelectedTitle. @@ -34,20 +22,3 @@ func newSpaciousListDel(color lipgloss.Color) list.DefaultDelegate { return d } - -func newContextURLListDel(color lipgloss.Color) list.DefaultDelegate { - d := list.NewDefaultDelegate() - d.SetSpacing(1) - d.ShowDescription = false - d.SetHeight(1) - - d.Styles.SelectedTitle = d.Styles. - SelectedTitle. - Foreground(color). - BorderLeftForeground(color) - - d.Styles.SelectedDesc = d.Styles. - SelectedTitle - - return d -} diff --git a/internal/ui/update.go b/internal/ui/update.go index 3c9b079..15917a9 100644 --- a/internal/ui/update.go +++ b/internal/ui/update.go @@ -577,14 +577,14 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch m.cfg.ListDensity { case Compact: - tlDel = newSpaciousListDel(lipgloss.Color(m.cfg.TaskListColor)) - atlDel = newSpaciousListDel(lipgloss.Color(m.cfg.ArchivedTaskListColor)) + tlDel = newListDelegate(lipgloss.Color(m.cfg.TaskListColor), true) + atlDel = newListDelegate(lipgloss.Color(m.cfg.ArchivedTaskListColor), true) m.cfg.ListDensity = Spacious case Spacious: - tlDel = newCompactListDel(lipgloss.Color(m.cfg.TaskListColor)) - atlDel = newCompactListDel(lipgloss.Color(m.cfg.ArchivedTaskListColor)) + tlDel = newListDelegate(lipgloss.Color(m.cfg.TaskListColor), false) + atlDel = newListDelegate(lipgloss.Color(m.cfg.ArchivedTaskListColor), false) m.cfg.ListDensity = Compact }