Skip to content
Snippets Groups Projects
mainView.go 1.22 KiB
Newer Older
  • Learn to ignore specific revisions
  • package views
    
    
    Malte Bauch's avatar
    Malte Bauch committed
    import (
    	"code.fbi.h-da.de/cocsn/gosdn/cmd/gosdn-tview/app"
    	"github.com/rivo/tview"
    	"google.golang.org/grpc"
    )
    
    
    type MainView struct {
    	pages              *tview.Pages
    
    	mainGrid           *tview.Grid
    
    	commandsListView   *CommandListView
    	resultAndInputView *ResultAndInputView
    
    Malte Bauch's avatar
    Malte Bauch committed
    	headerView         *HeaderView
    
    Malte Bauch's avatar
    Malte Bauch committed
    	footerView         *FooterView
    
    Malte Bauch's avatar
    Malte Bauch committed
    func NewMainView(app *app.App, conn *grpc.ClientConn) *MainView {
    
    Malte Bauch's avatar
    Malte Bauch committed
    	mv := &MainView{
    
    Malte Bauch's avatar
    Malte Bauch committed
    		pages:              tview.NewPages(),
    
    		mainGrid:           tview.NewGrid(),
    
    Malte Bauch's avatar
    Malte Bauch committed
    		commandsListView:   NewCommandListView(),
    
    		resultAndInputView: NewResultAndInputView(app),
    
    Malte Bauch's avatar
    Malte Bauch committed
    		headerView:         NewHeaderView(),
    
    Malte Bauch's avatar
    Malte Bauch committed
    		footerView:         NewFooterView(app, conn),
    
    Malte Bauch's avatar
    Malte Bauch committed
    	}
    
    Malte Bauch's avatar
    Malte Bauch committed
    	mv.commandsListView.GetCommands(app, mv.resultAndInputView, conn)
    
    Malte Bauch's avatar
    Malte Bauch committed
    		SetRows(8, 0, 5).
    
    		SetColumns(40, 0).
    
    Malte Bauch's avatar
    Malte Bauch committed
    		AddItem(mv.headerView.GetContent(), 0, 0, 1, 2, 0, 0, false).
    
    Malte Bauch's avatar
    Malte Bauch committed
    		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)
    
    Malte Bauch's avatar
    Malte Bauch committed
    	return mv
    
    }
    
    func (mv *MainView) GetContent() tview.Primitive {
    	return mv.pages
    }