Newer
Older
import (
"code.fbi.h-da.de/cocsn/gosdn/cmd/gosdn-tview/app"
"github.com/rivo/tview"
"google.golang.org/grpc"
)
//MainView is an application view to display the main content of the application.
//It is the entry point for the application and contains all necessary views for
//for that purpose
type MainView struct {
pages *tview.Pages
commandsListView *CommandListView
resultAndInputView *ResultAndInputView
func NewMainView(app *app.App, conn *grpc.ClientConn) *MainView {
pages: tview.NewPages(),
mainGrid: tview.NewGrid(),
commandsListView: NewCommandListView("commands"),
headerView: NewHeaderView(),
footerView: NewFooterView(app, conn),
mv.resultAndInputView = NewResultAndInputView("result and input", app, mv.commandsListView.GetContent(), conn)
mv.commandsListView.GetCommands(app, mv.resultAndInputView, conn)
AddItem(mv.headerView.GetContent(), 0, 0, 1, 2, 0, 0, false).
AddItem(mv.footerView.GetContent(), 2, 0, 1, 2, 0, 0, false)
mv.mainGrid.
AddItem(mv.commandsListView.GetContent(), 1, 0, 1, 1, 0, 0, true).
AddItem(mv.resultAndInputView.GetContent(), 1, 1, 1, 1, 0, 0, false)
mv.pages.AddPage("main", mv.mainGrid, true, true)
//GetContent returns the tview.Primitive belonging to the MainView
func (mv *MainView) GetContent() tview.Primitive {
return mv.pages
}