initialize authors and repos

This commit is contained in:
2023-02-26 23:03:02 -08:00
parent 91545e2e09
commit aea58da34b
2 changed files with 20 additions and 6 deletions

View File

@@ -1,11 +1,10 @@
package ui
import (
"fmt"
"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/list"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/taigrr/gico/commits"
)
@@ -90,7 +89,8 @@ func (m Settings) Init() tea.Cmd {
}
func (m Settings) View() string {
return fmt.Sprintf("This is the settings view %s", "fmt")
return lipgloss.JoinHorizontal(lipgloss.Top, m.AuthorList.View(), m.RepoList.View())
// return fmt.Sprintf("This is the settings view %s", "fmt")
}
func NewSettings() (Settings, error) {
@@ -133,5 +133,16 @@ func NewSettings() (Settings, error) {
}
}
}
repoItems := []list.Item{}
for _, v := range m.AllRepos {
repoItems = append(repoItems, v)
}
m.RepoList = list.New(repoItems, newItemDelegate(newDelegateKeyMap()), 0, 4)
authItems := []list.Item{}
for _, v := range m.AllAuthors {
authItems = append(authItems, v)
}
m.AuthorList = list.New(authItems, newItemDelegate(newDelegateKeyMap()), 0, 4)
return m, nil
}

View File

@@ -131,9 +131,12 @@ func (m model) View() string {
if m.quitting {
return ""
}
mainView := lipgloss.JoinVertical(lipgloss.Top, m.GraphModel.View(), m.CommitLogModel.View(), m.HelpModel.ShortHelpView(m.Bindings))
if m.cursor == settings {
return lipgloss.JoinHorizontal(lipgloss.Left, m.SettingsModel.View(), mainView)
return m.SettingsModel.View()
}
return mainView
return lipgloss.JoinVertical(lipgloss.Top,
m.GraphModel.View(),
m.CommitLogModel.View(),
m.HelpModel.ShortHelpView(m.Bindings),
)
}