Handle UDAs for editing; Fix layout; Add annotations
This commit is contained in:
@ -149,65 +149,85 @@ func (m *Model) parseRowStyles(rows taskwarrior.Tasks) []lipgloss.Style {
|
||||
if len(rows) == 0 {
|
||||
return styles
|
||||
}
|
||||
taskstyle:
|
||||
for i, task := range rows {
|
||||
if task.Status == "deleted" {
|
||||
styles[i] = m.common.Styles.Deleted.Inherit(m.styles.Cell).Margin(m.styles.Cell.GetMargin()).Padding(m.styles.Cell.GetPadding())
|
||||
continue
|
||||
if c, ok := m.common.Styles.Colors["deleted"]; ok && c != nil {
|
||||
styles[i] = c.Inherit(m.styles.Cell).Margin(m.styles.Cell.GetMargin()).Padding(m.styles.Cell.GetPadding())
|
||||
continue
|
||||
}
|
||||
}
|
||||
if task.Status == "completed" {
|
||||
styles[i] = m.common.Styles.Completed.Inherit(m.styles.Cell).Margin(m.styles.Cell.GetMargin()).Padding(m.styles.Cell.GetPadding())
|
||||
continue
|
||||
if c, ok := m.common.Styles.Colors["completed"]; ok && c != nil {
|
||||
styles[i] = c.Inherit(m.styles.Cell).Margin(m.styles.Cell.GetMargin()).Padding(m.styles.Cell.GetPadding())
|
||||
continue
|
||||
}
|
||||
}
|
||||
if task.Status == "pending" && task.Start != "" {
|
||||
styles[i] = m.common.Styles.Active.Inherit(m.styles.Cell).Margin(m.styles.Cell.GetMargin()).Padding(m.styles.Cell.GetPadding())
|
||||
continue
|
||||
if c, ok := m.common.Styles.Colors["active"]; ok && c != nil {
|
||||
styles[i] = c.Inherit(m.styles.Cell).Margin(m.styles.Cell.GetMargin()).Padding(m.styles.Cell.GetPadding())
|
||||
continue
|
||||
}
|
||||
}
|
||||
// TODO: implement keyword
|
||||
// TODO: implement tag
|
||||
if task.HasTag("next") {
|
||||
if c, ok := m.common.Styles.Colors["tag.next"]; ok && c != nil {
|
||||
styles[i] = c.Inherit(m.styles.Cell).Margin(m.styles.Cell.GetMargin()).Padding(m.styles.Cell.GetPadding())
|
||||
continue
|
||||
}
|
||||
}
|
||||
// TODO: implement project
|
||||
if !task.GetDate("due").IsZero() && task.GetDate("due").Before(time.Now()) {
|
||||
styles[i] = m.common.Styles.Overdue.Inherit(m.styles.Cell).Margin(m.styles.Cell.GetMargin()).Padding(m.styles.Cell.GetPadding())
|
||||
continue
|
||||
if c, ok := m.common.Styles.Colors["overdue"]; ok && c != nil {
|
||||
styles[i] = c.Inherit(m.styles.Cell).Margin(m.styles.Cell.GetMargin()).Padding(m.styles.Cell.GetPadding())
|
||||
continue
|
||||
}
|
||||
}
|
||||
if task.Scheduled != "" {
|
||||
styles[i] = m.common.Styles.Scheduled.Inherit(m.styles.Cell).Margin(m.styles.Cell.GetMargin()).Padding(m.styles.Cell.GetPadding())
|
||||
continue
|
||||
if c, ok := m.common.Styles.Colors["scheduled"]; ok && c != nil {
|
||||
styles[i] = c.Inherit(m.styles.Cell).Margin(m.styles.Cell.GetMargin()).Padding(m.styles.Cell.GetPadding())
|
||||
continue
|
||||
}
|
||||
}
|
||||
if !task.GetDate("due").IsZero() && task.GetDate("due").Truncate(24*time.Hour).Equal(time.Now().Truncate(24*time.Hour)) {
|
||||
styles[i] = m.common.Styles.DueToday.Inherit(m.styles.Cell).Margin(m.styles.Cell.GetMargin()).Padding(m.styles.Cell.GetPadding())
|
||||
continue
|
||||
if c, ok := m.common.Styles.Colors["due.today"]; ok && c != nil {
|
||||
styles[i] = c.Inherit(m.styles.Cell).Margin(m.styles.Cell.GetMargin()).Padding(m.styles.Cell.GetPadding())
|
||||
continue
|
||||
}
|
||||
}
|
||||
if task.Due != "" {
|
||||
styles[i] = m.common.Styles.Due.Inherit(m.styles.Cell).Margin(m.styles.Cell.GetMargin()).Padding(m.styles.Cell.GetPadding())
|
||||
continue
|
||||
if c, ok := m.common.Styles.Colors["due"]; ok && c != nil {
|
||||
styles[i] = c.Inherit(m.styles.Cell).Margin(m.styles.Cell.GetMargin()).Padding(m.styles.Cell.GetPadding())
|
||||
continue
|
||||
}
|
||||
}
|
||||
if len(task.Depends) > 0 {
|
||||
styles[i] = m.common.Styles.Blocked.Inherit(m.styles.Cell).Margin(m.styles.Cell.GetMargin()).Padding(m.styles.Cell.GetPadding())
|
||||
continue
|
||||
if c, ok := m.common.Styles.Colors["blocked"]; ok && c != nil {
|
||||
styles[i] = c.Inherit(m.styles.Cell).Margin(m.styles.Cell.GetMargin()).Padding(m.styles.Cell.GetPadding())
|
||||
continue
|
||||
}
|
||||
}
|
||||
// TODO implement blocking
|
||||
if task.Recur != "" {
|
||||
styles[i] = m.common.Styles.Recurring.Inherit(m.styles.Cell).Margin(m.styles.Cell.GetMargin()).Padding(m.styles.Cell.GetPadding())
|
||||
continue
|
||||
if c, ok := m.common.Styles.Colors["recurring"]; ok && c != nil {
|
||||
styles[i] = c.Inherit(m.styles.Cell).Margin(m.styles.Cell.GetMargin()).Padding(m.styles.Cell.GetPadding())
|
||||
continue
|
||||
}
|
||||
}
|
||||
// TODO: make styles optional and discard if empty
|
||||
if len(task.Tags) > 0 {
|
||||
styles[i] = m.common.Styles.Tagged.Inherit(m.styles.Cell).Margin(m.styles.Cell.GetMargin()).Padding(m.styles.Cell.GetPadding())
|
||||
taskIteration:
|
||||
for _, tag := range task.Tags {
|
||||
if tag == "next" {
|
||||
styles[i] = m.common.Styles.TagNext.Inherit(m.styles.Cell).Margin(m.styles.Cell.GetMargin()).Padding(m.styles.Cell.GetPadding())
|
||||
break taskIteration
|
||||
}
|
||||
if c, ok := m.common.Styles.Colors["tagged"]; ok && c != nil {
|
||||
styles[i] = c.Inherit(m.styles.Cell).Margin(m.styles.Cell.GetMargin()).Padding(m.styles.Cell.GetPadding())
|
||||
continue
|
||||
}
|
||||
continue
|
||||
}
|
||||
if len(m.common.Udas) > 0 {
|
||||
for _, uda := range m.common.Udas {
|
||||
if u, ok := task.Udas[uda]; ok {
|
||||
if style, ok := m.common.Styles.Colors[fmt.Sprintf("uda.%s.%s", uda, u)]; ok {
|
||||
styles[i] = style.Inherit(m.styles.Cell).Margin(m.styles.Cell.GetMargin()).Padding(m.styles.Cell.GetPadding())
|
||||
continue
|
||||
if u, ok := task.Udas[uda.Name]; ok {
|
||||
if c, ok := m.common.Styles.Colors[fmt.Sprintf("uda.%s.%s", uda.Name, u)]; ok {
|
||||
styles[i] = c.Inherit(m.styles.Cell).Margin(m.styles.Cell.GetMargin()).Padding(m.styles.Cell.GetPadding())
|
||||
continue taskstyle
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user