@@ -99,7 +99,9 @@ func (t taskItem) Description() string {
9999 }
100100 dueText := ""
101101 if t .HasDue {
102- dueText = fmt .Sprintf ("due %s" , t .Due .Format ("2006-01-02" ))
102+ if formatted := formatDueText (t .Due ); formatted != "" {
103+ dueText = fmt .Sprintf ("due %s" , formatted )
104+ }
103105 }
104106 return dueText
105107}
@@ -866,23 +868,82 @@ func (m *tuiModel) splitPane(left, right string) string {
866868}
867869
868870func (m * tuiModel ) detailsView () string {
869- task , ok := m .selectedTask ()
870- if ! ok {
871- return gray ("Select a task to see details" )
872- }
873- dueText := "None"
874- if task .HasDue {
875- dueText = task .Due .Format ("2006-01-02" )
876- }
877871 label := lipgloss .NewStyle ().Foreground (colorMuted )
878- lines := []string {
879- lipgloss .NewStyle ().Bold (true ).Render (task .TitleVal ),
880- "" ,
881- fmt .Sprintf ("%s %s" , label .Render ("List:" ), task .ListName ),
882- fmt .Sprintf ("%s %s" , label .Render ("Section:" ), task .Section ),
883- fmt .Sprintf ("%s %s" , label .Render ("Due:" ), dueText ),
872+ item := m .tasksList .SelectedItem ()
873+ if item == nil {
874+ return gray ("Select a task or event to see details" )
875+ }
876+
877+ switch value := item .(type ) {
878+ case taskItem :
879+ if value .IsHeader {
880+ return gray ("Select a task or event to see details" )
881+ }
882+ dueText := "None"
883+ if value .HasDue {
884+ if formatted := formatDueText (value .Due ); formatted != "" {
885+ dueText = formatted
886+ }
887+ }
888+ lines := []string {
889+ lipgloss .NewStyle ().Bold (true ).Render (value .TitleVal ),
890+ "" ,
891+ fmt .Sprintf ("%s %s" , label .Render ("List:" ), value .ListName ),
892+ fmt .Sprintf ("%s %s" , label .Render ("Section:" ), value .Section ),
893+ fmt .Sprintf ("%s %s" , label .Render ("Due:" ), dueText ),
894+ }
895+ return strings .Join (lines , "\n " )
896+ case searchItem :
897+ task := value .Task
898+ if task .IsHeader {
899+ return gray ("Select a task or event to see details" )
900+ }
901+ dueText := "None"
902+ if task .HasDue {
903+ if formatted := formatDueText (task .Due ); formatted != "" {
904+ dueText = formatted
905+ }
906+ }
907+ lines := []string {
908+ lipgloss .NewStyle ().Bold (true ).Render (task .TitleVal ),
909+ "" ,
910+ fmt .Sprintf ("%s %s" , label .Render ("List:" ), task .ListName ),
911+ fmt .Sprintf ("%s %s" , label .Render ("Section:" ), task .Section ),
912+ fmt .Sprintf ("%s %s" , label .Render ("Due:" ), dueText ),
913+ }
914+ return strings .Join (lines , "\n " )
915+ case calendarEventItem :
916+ when := ""
917+ if value .AllDay {
918+ if formatted := formatAllDayRange (value .Start , value .End ); formatted != "" {
919+ when = fmt .Sprintf ("%s (all-day)" , formatted )
920+ }
921+ } else {
922+ dateText := value .Start .Format ("2006-01-02" )
923+ timeText := formatTimeRange (value .Start , value .End )
924+ if timeText != "" {
925+ when = fmt .Sprintf ("%s %s" , dateText , timeText )
926+ } else {
927+ when = dateText
928+ }
929+ }
930+ if when == "" {
931+ when = "Unknown"
932+ }
933+ calendarName := strings .TrimSpace (value .CalendarName )
934+ if calendarName == "" {
935+ calendarName = value .CalendarID
936+ }
937+ lines := []string {
938+ lipgloss .NewStyle ().Bold (true ).Render (value .Summary ),
939+ "" ,
940+ fmt .Sprintf ("%s %s" , label .Render ("Calendar:" ), calendarName ),
941+ fmt .Sprintf ("%s %s" , label .Render ("When:" ), when ),
942+ }
943+ return strings .Join (lines , "\n " )
944+ default :
945+ return gray ("Select a task or event to see details" )
884946 }
885- return strings .Join (lines , "\n " )
886947}
887948
888949func renderStatus (msg string ) string {
0 commit comments