2
0
mirror of https://github.com/edouardparis/lntop synced 2024-11-04 06:00:14 +00:00
lntop/ui/views/views.go
2019-03-29 09:37:24 +01:00

42 lines
720 B
Go

package views
import (
"github.com/edouardparis/lntop/ui/models"
"github.com/jroimartin/gocui"
)
type Views struct {
Header *Header
Summary *Summary
Channels *Channels
Footer *Footer
}
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
}
err = v.Channels.Set(g, 0, 6, maxX-1, maxY-1)
if err != nil {
return err
}
return v.Footer.Set(g, 0, maxY-2, maxX, maxY)
}
func New(m *models.Models) *Views {
return &Views{
Header: NewHeader(m.Info),
Footer: NewFooter(),
Summary: NewSummary(m.Info),
Channels: NewChannels(m.Channels),
}
}