💄 feat(ui): List bullets
This commit is contained in:
parent
b2e01ebd60
commit
b556cdfa22
1 changed files with 16 additions and 4 deletions
20
main.go
20
main.go
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/charmbracelet/bubbles/key"
|
"github.com/charmbracelet/bubbles/key"
|
||||||
tea "github.com/charmbracelet/bubbletea"
|
tea "github.com/charmbracelet/bubbletea"
|
||||||
gloss "github.com/charmbracelet/lipgloss"
|
gloss "github.com/charmbracelet/lipgloss"
|
||||||
|
"github.com/charmbracelet/lipgloss/list"
|
||||||
"golang.org/x/term"
|
"golang.org/x/term"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
@ -17,7 +18,6 @@ var width, height, _ = term.GetSize(int(os.Stdout.Fd()))
|
||||||
type menu struct {
|
type menu struct {
|
||||||
order SoftwarePackages
|
order SoftwarePackages
|
||||||
current int
|
current int
|
||||||
done int
|
|
||||||
keys keyMap
|
keys keyMap
|
||||||
help help.Model
|
help help.Model
|
||||||
inputStyle gloss.Style
|
inputStyle gloss.Style
|
||||||
|
@ -25,7 +25,7 @@ type menu struct {
|
||||||
|
|
||||||
func initialModel() menu {
|
func initialModel() menu {
|
||||||
return menu{
|
return menu{
|
||||||
current: 0,
|
current: 3,
|
||||||
keys: keys,
|
keys: keys,
|
||||||
help: help.New(),
|
help: help.New(),
|
||||||
}
|
}
|
||||||
|
@ -174,12 +174,24 @@ func (m menu) View() string {
|
||||||
Width(int(float64(width) * 0.3))
|
Width(int(float64(width) * 0.3))
|
||||||
|
|
||||||
mainContent := ""
|
mainContent := ""
|
||||||
sidebarContent := ""
|
|
||||||
|
softwareListEnumerator := func(l list.Items, i int) string {
|
||||||
|
if m.current == i {
|
||||||
|
return ">"
|
||||||
|
} else if m.current > i {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
software := list.New().Enumerator(softwareListEnumerator)
|
||||||
|
|
||||||
for _, item := range m.order {
|
for _, item := range m.order {
|
||||||
sidebarContent += fmt.Sprintf("%s\n", item.Name)
|
software.Item(item.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sidebarContent := software.String()
|
||||||
|
|
||||||
main := mainStyle.Render(mainContent)
|
main := mainStyle.Render(mainContent)
|
||||||
sidebar := sidebarStyle.Render(sidebarContent)
|
sidebar := sidebarStyle.Render(sidebarContent)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue