bold-brew/internal/ui/components/table.go
Vito Castellano 6d10e0beab
Some checks are pending
Quality / golangci-lint (push) Waiting to run
Quality / Build (push) Waiting to run
Quality / Build-1 (push) Waiting to run
Security / Go Vulnerability Check (push) Waiting to run
Security / Security Scanner (push) Waiting to run
feat: improve UI color scheme for better readability across terminal themes
Updates the UI theme system and improves visual consistency and accessibility across different terminal themes. The main changes include refactoring how colors are handled, updating component styles for better visibility, and ensuring that global styles adapt to the user's terminal settings.
2025-11-23 19:09:32 +01:00

52 lines
1.1 KiB
Go

package components
import (
"bbrew/internal/ui/theme"
"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"
)
type Table struct {
view *tview.Table
theme *theme.Theme
}
func NewTable(theme *theme.Theme) *Table {
table := &Table{
view: tview.NewTable(),
theme: theme,
}
table.view.SetBorders(false)
table.view.SetSelectable(true, false)
table.view.SetFixed(1, 0)
// Use reverse video for selection to ensure visibility on any terminal theme
table.view.SetSelectedStyle(tcell.StyleDefault.Reverse(true))
return table
}
func (t *Table) SetSelectionHandler(handler func(row, column int)) {
t.view.SetSelectionChangedFunc(handler)
}
func (t *Table) View() *tview.Table {
return t.view
}
func (t *Table) Clear() {
t.view.Clear()
}
func (t *Table) SetTableHeaders(headers ...string) {
for i, header := range headers {
t.view.SetCell(0, i, &tview.TableCell{
Text: header,
NotSelectable: true,
Align: tview.AlignLeft,
Color: t.theme.TableHeaderColor,
BackgroundColor: t.theme.DefaultBgColor,
})
}
}