Skip to content

Commit

Permalink
Sort completions and tasks by points in descending order for improved…
Browse files Browse the repository at this point in the history
… UI display
  • Loading branch information
ndonathan committed Nov 24, 2024
1 parent 4bba0b5 commit 2207c56
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmd/tasks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"fyne.io/fyne/v2/widget"
"image/color"
"log"
"sort"
"strconv"
"time"
)
Expand Down Expand Up @@ -289,6 +290,11 @@ func createUI(window fyne.Window, state *AppState) fyne.CanvasObject {
completionsContainer.Objects = nil // Clear existing items
completions, _ := GetCompletions(state.db)

// Sort completions by points in descending order
sort.Slice(completions, func(i, j int) bool {
return completions[i].Points > completions[j].Points
})

for _, c := range completions {
// Create a styled completion entry
dateStr := c.CompletedAt.Format("Jan 2, 2006")
Expand Down Expand Up @@ -341,6 +347,11 @@ func createUI(window fyne.Window, state *AppState) fyne.CanvasObject {
return
}

// Sort tasks by points in descending order
sort.Slice(tasks, func(i, j int) bool {
return tasks[i].Points > tasks[j].Points
})

for _, task := range tasks {
// Create a styled task entry with hover effect
completeBtn := widget.NewButton("Complete", nil)
Expand Down

0 comments on commit 2207c56

Please sign in to comment.