package main import ( "fmt" "completed/internal/model" ) // gameColumns are the games table's column headers, in order. Kept next to // gameCellText so the two can't drift apart. var gameColumns = []string{"Name", "Platform", "Score", "Released", "Finished"} // gameTableSize returns the (rows, cols) Fyne's widget.Table needs from its // Length function: one row per game, plus a header row. func gameTableSize(games []model.Game) (rows, cols int) { return len(games) + 1, len(gameColumns) } // gameCellText returns the text for row/col in the games table. row 0 is // the header; row i (i>0) is games[i-1]. It has no Fyne dependency, so it's // tested directly without needing any widget or display. func gameCellText(games []model.Game, row, col int) string { if row == 0 { return gameColumns[col] } g := games[row-1] switch col { case 0: return g.Name case 1: return g.PlatformName case 2: return fmt.Sprintf("%d", g.Score) case 3: return g.ReleaseDate case 4: if g.Finished != "" { return "✓" } return "" default: return "" } }