2
0
mirror of https://github.com/edouardparis/lntop synced 2024-11-04 06:00:14 +00:00
lntop/ui/views/views.go

42 lines
720 B
Go
Raw Normal View History

2019-03-28 08:47:47 +00:00
package views
2019-03-28 13:07:46 +00:00
import (
"github.com/edouardparis/lntop/ui/models"
"github.com/jroimartin/gocui"
)
2019-03-28 08:47:47 +00:00
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)
}
2019-03-28 13:07:46 +00:00
func New(m *models.Models) *Views {
2019-03-28 08:47:47 +00:00
return &Views{
2019-03-28 13:07:46 +00:00
Header: NewHeader(m.Info),
2019-03-28 08:47:47 +00:00
Footer: NewFooter(),
2019-03-29 08:37:24 +00:00
Summary: NewSummary(m.Info),
2019-03-29 08:30:05 +00:00
Channels: NewChannels(m.Channels),
2019-03-28 08:47:47 +00:00
}
}