You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lntop/ui/views/views.go

62 lines
1.1 KiB
Go

package views
import (
"github.com/edouardparis/lntop/ui/models"
"github.com/jroimartin/gocui"
)
type view interface {
Set(*gocui.Gui, int, int, int, int) error
Name() string
}
type Views struct {
Previous view
Help *Help
Header *Header
Summary *Summary
Channels *Channels
Channel *Channel
}
func (v Views) Get(name string) view {
switch name {
case CHANNELS:
return v.Channels
case HELP:
return v.Help
case CHANNEL:
return v.Channel
default:
return nil
}
}
func (v *Views) SetPrevious(p view) {
v.Previous = p
}
func (v *Views) Layout(g *gocui.Gui, maxX, maxY int) error {
err := v.Header.Set(g, 0, -1, maxX, 1)
if err != nil {
return err
}
err = v.Summary.Set(g, 0, 1, maxX, 6)
if err != nil {
return err
}
return v.Channels.Set(g, 0, 6, maxX-1, maxY)
}
func New(m *models.Models) *Views {
return &Views{
Header: NewHeader(m.Info),
Help: NewHelp(),
Summary: NewSummary(m.Info, m.ChannelsBalance, m.WalletBalance, m.Channels),
Channels: NewChannels(m.Channels),
Channel: NewChannel(m.CurrentChannel),
}
}