1package repo
 2
 3import (
 4	tea "github.com/charmbracelet/bubbletea"
 5	"github.com/charmbracelet/soft-serve/ui/common"
 6	"github.com/charmbracelet/soft-serve/ui/components/selector"
 7	"github.com/charmbracelet/soft-serve/ui/components/viewport"
 8)
 9
10type view int
11
12const (
13	logView view = iota
14	commitView
15)
16
17type Log struct {
18	common     common.Common
19	selector   *selector.Selector
20	vp         *viewport.Viewport
21	activeView view
22}
23
24func NewLog(common common.Common) *Log {
25	l := &Log{
26		common:     common,
27		selector:   selector.New(common, []selector.IdentifiableItem{}, LogItemDelegate{common.Styles}),
28		vp:         viewport.New(),
29		activeView: logView,
30	}
31	return l
32}
33
34func (l *Log) SetSize(width, height int) {
35	l.common.SetSize(width, height)
36	l.selector.SetSize(width, height)
37	l.vp.SetSize(width, height)
38}
39
40func (l *Log) Init() tea.Cmd {
41	return nil
42}
43
44func (l *Log) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
45	return l, nil
46}
47
48func (l *Log) View() string {
49	switch l.activeView {
50	case logView:
51		return l.selector.View()
52	case commitView:
53		return l.vp.View()
54	default:
55		return ""
56	}
57}