Made it look cooler

This commit is contained in:
Sasha Koshka 2022-10-14 02:30:44 -04:00
parent fb2e2a831e
commit 22e9aaf60e
3 changed files with 120 additions and 74 deletions

View File

@ -24,59 +24,77 @@ type Application struct {
func NewApplication() *Application { func NewApplication() *Application {
pBar := NewProgressBar() // progress bar
pBar.SetProgressFunc(ProgressFunction) progressBar := NewProgressBar()
progressBar.SetProgressFunc(ProgressFunction)
// main view
expandedView := tview.NewTable() expandedView := tview.NewTable()
Navbar := tview.NewTable() expandedView.SetBackgroundColor(tcell.ColorDefault)
searchBar := tview.NewInputField() expandedView.SetBorderPadding(0, 1, 1, 1).SetBorder(false)
searchBar.SetFieldBackgroundColor(tcell.ColorDefault) expandedView.SetSelectable(true, false)
// image preview
imagePreviewer := tview.NewBox() imagePreviewer := tview.NewBox()
imagePreviewer.SetBorder(true) imagePreviewer.SetBorder(false)
imagePreviewer.SetDrawFunc(func(s tcell.Screen, x, y, width, height int) (int, int, int, int) { imagePreviewer.SetDrawFunc(func(
screen tcell.Screen,
x, y,
width, height int,
) (
int, int,
int, int,
) {
ImgX, ImgY, ImgW, ImgH = imagePreviewer.GetRect() ImgX, ImgY, ImgW, ImgH = imagePreviewer.GetRect()
return imagePreviewer.GetInnerRect() return imagePreviewer.GetInnerRect()
}) })
expandedView.SetBackgroundColor(tcell.ColorDefault)
Navbar.SetBackgroundColor(tcell.ColorDefault)
searchBar.SetBackgroundColor(tcell.ColorDefault)
imagePreviewer.SetBackgroundColor(tcell.ColorDefault) imagePreviewer.SetBackgroundColor(tcell.ColorDefault)
searchBar.SetTitle("Search").SetTitleAlign(tview.AlignLeft) // nav bar
searchBar.SetAutocompleteBackgroundColor(tcell.ColorBlack) navBar := tview.NewTable()
searchBar.SetAutocompleteSelectBackgroundColor(tcell.ColorWhite) navBar.SetBackgroundColor(tcell.ColorDefault)
searchBar.SetAutocompleteMainTextColor(tcell.ColorDarkGray) navBar.SetBorderPadding(1, 1, 2, 2).SetBorder(false)
searchBar.SetAutocompleteSelectedTextColor(tcell.ColorBlack) navBar.SetBackgroundColor(tcell.ColorBlack)
Navbar.SetBorder(true) navBar.SetSelectable(true, false)
Navbar.SetSelectable(true, false) navBar.SetSelectedStyle(
Navbar.SetCell(0, 0, tview.NewTableCell("PlayList")) tcell.Style{}.
Navbar.SetCell(1, 0, tview.NewTableCell("Files")) Background(tcell.ColorGrey))
Navbar.SetCell(2, 0, tview.NewTableCell("Most Played")) navBar.SetCell(0, 0, tview.NewTableCell("playlist"))
Navbar.SetCell(3, 0, tview.NewTableCell("Search")) navBar.SetCell(1, 0, tview.NewTableCell("files"))
navBar.SetCell(2, 0, tview.NewTableCell("most played"))
navBar.SetCell(3, 0, tview.NewTableCell("search"))
searchNavFlex := tview.NewFlex().SetDirection(tview.FlexRow). // search bar
AddItem(Navbar, 0, 4, false). searchBar := tview.NewInputField()
searchBar.SetFieldBackgroundColor(tcell.ColorDefault)
searchBar.SetBackgroundColor(tcell.ColorDefault)
searchBar.SetTitle("search").SetTitleAlign(tview.AlignLeft)
searchBar.SetAutocompleteBackgroundColor(tcell.ColorBlack)
searchBar.SetAutocompleteSelectBackgroundColor(tcell.ColorGray)
searchBar.SetAutocompleteMainTextColor(tcell.ColorDefault)
searchBar.SetAutocompleteSelectedTextColor(tcell.ColorDefault)
searchBar.SetBorder(true)
searchBar.SetBorderColor(tcell.ColorGray)
// layout
sidebar := tview.NewFlex().SetDirection(tview.FlexRow).
AddItem(navBar, 0, 4, false).
AddItem(imagePreviewer, 9, 3, false) AddItem(imagePreviewer, 9, 3, false)
sNavExpViewFlex := tview.NewFlex(). middleRow := tview.NewFlex().
AddItem(searchNavFlex, 17, 1, false). AddItem(sidebar, 17, 1, false).
AddItem(expandedView, 0, 4, false) AddItem(expandedView, 0, 4, false)
searchBar.SetBorder(true) mainLayout := tview.NewFlex().SetDirection(tview.FlexRow).
searchBarFlex := tview.NewFlex().SetDirection(tview.FlexRow).
AddItem(searchBar, 3, 1, false). AddItem(searchBar, 3, 1, false).
AddItem(sNavExpViewFlex, 0, 1, false) AddItem(middleRow, 0, 1, false).
AddItem(progressBar, 5, 1, false)
MainFlex := tview.NewFlex().SetDirection(tview.FlexRow).
AddItem(searchBarFlex, 0, 8, false).
AddItem(pBar, 5, 1, false)
expandedView.SetBorderPadding(1, 1, 1, 1).SetBorder(true)
expandedView.SetSelectable(true, false)
// pages
rootPages := tview.NewPages() rootPages := tview.NewPages()
rootPages.AddPage("Main", MainFlex, true, true) rootPages.AddPage("Main", mainLayout, true, true)
// application
App := tview.NewApplication() App := tview.NewApplication()
App.SetRoot(rootPages, true).SetFocus(expandedView) App.SetRoot(rootPages, true).SetFocus(expandedView)