mirror of
https://github.com/aditya-K2/gspt.git
synced 2026-01-09 13:58:05 -05:00
Rename Main=>Root MainS=>Main
This commit is contained in:
28
ui/app.go
28
ui/app.go
@@ -15,11 +15,11 @@ var (
|
||||
|
||||
type Application struct {
|
||||
App *tview.Application
|
||||
MainS *interactiveView
|
||||
Main *interactiveView
|
||||
Navbar *tview.Table
|
||||
SearchBar *tview.Box
|
||||
ProgressBar *tview.Box
|
||||
Root *Main
|
||||
Root *Root
|
||||
ImagePreviewer *tview.Box
|
||||
}
|
||||
|
||||
@@ -30,17 +30,17 @@ func NewApplication() *Application {
|
||||
pBar := tview.NewBox().SetBorder(true).SetTitle("PROGRESS").SetBackgroundColor(tcell.ColorDefault)
|
||||
searchbar := tview.NewBox().SetBorder(true).SetTitle("SEARCH").SetBackgroundColor(tcell.ColorDefault)
|
||||
SetCurrentView(PView)
|
||||
mainS := NewInteractiveView()
|
||||
mainS.View.SetBorder(true)
|
||||
mains := NewInteractiveView()
|
||||
mains.View.SetBorder(true)
|
||||
|
||||
mainS.SetContentFunc(GetCurrentView().Content)
|
||||
mainS.SetContextKey(GetCurrentView().ContextKey())
|
||||
mains.SetContentFunc(GetCurrentView().Content)
|
||||
mains.SetContextKey(GetCurrentView().ContextKey())
|
||||
f := func() {
|
||||
GetCurrentView().ContextOpener(Main, mainS.SelectionHandler)
|
||||
GetCurrentView().ContextOpener(Main, mains.SelectionHandler)
|
||||
}
|
||||
mainS.SetContextOpener(f)
|
||||
mainS.SetContextHandler(GetCurrentView().ContextHandler)
|
||||
mainS.SetExternalCapture(GetCurrentView().ExternalInputCapture)
|
||||
mains.SetContextOpener(f)
|
||||
mains.SetContextHandler(GetCurrentView().ContextHandler)
|
||||
mains.SetExternalCapture(GetCurrentView().ExternalInputCapture)
|
||||
|
||||
Navbar := tview.NewTable()
|
||||
imagePreviewer := tview.NewBox()
|
||||
@@ -67,10 +67,10 @@ func NewApplication() *Application {
|
||||
PlaylistActions = map[string]*Action{
|
||||
"playEntry": NewAction(playlistNav.PlaySelectEntry, nil),
|
||||
"openEntry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
Main.AfterContextClose(func() { App.SetFocus(mainS.View) })
|
||||
Main.AfterContextClose(func() { App.SetFocus(mains.View) })
|
||||
r, _ := playlistNav.Table.GetSelection()
|
||||
PView.SetPlaylist(&(*playlistNav.Playlists)[r])
|
||||
App.SetFocus(mainS.View)
|
||||
App.SetFocus(mains.View)
|
||||
return nil
|
||||
}, nil),
|
||||
}
|
||||
@@ -85,7 +85,7 @@ func NewApplication() *Application {
|
||||
|
||||
sNavExpViewFlex := tview.NewFlex().
|
||||
AddItem(searchNavFlex, 17, 1, false).
|
||||
AddItem(mainS.View, 0, 4, false)
|
||||
AddItem(mains.View, 0, 4, false)
|
||||
|
||||
searchBarFlex := tview.NewFlex().SetDirection(tview.FlexRow).
|
||||
AddItem(searchbar, 3, 1, false).
|
||||
@@ -101,7 +101,7 @@ func NewApplication() *Application {
|
||||
|
||||
Ui = &Application{
|
||||
App: App,
|
||||
MainS: mainS,
|
||||
Main: mains,
|
||||
Navbar: Navbar,
|
||||
SearchBar: searchbar,
|
||||
ProgressBar: pBar,
|
||||
|
||||
12
ui/root.go
12
ui/root.go
@@ -7,13 +7,13 @@ import (
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
type Main struct {
|
||||
type Root struct {
|
||||
Root *tview.Pages
|
||||
after func()
|
||||
}
|
||||
|
||||
func NewMain() *Main {
|
||||
m := &Main{}
|
||||
func NewMain() *Root {
|
||||
m := &Root{}
|
||||
|
||||
Root := tview.NewPages()
|
||||
|
||||
@@ -21,11 +21,11 @@ func NewMain() *Main {
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *Main) Primitive(name string, t tview.Primitive) {
|
||||
func (m *Root) Primitive(name string, t tview.Primitive) {
|
||||
m.Root.AddPage(name, t, true, true)
|
||||
}
|
||||
|
||||
func (m *Main) AfterContextClose(f func()) {
|
||||
func (m *Root) AfterContextClose(f func()) {
|
||||
m.after = f
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ type CenteredWidget interface {
|
||||
Size(mw, mh int) (int, int, int, int)
|
||||
}
|
||||
|
||||
func (m *Main) AddCenteredWidget(t CenteredWidget) {
|
||||
func (m *Root) AddCenteredWidget(t CenteredWidget) {
|
||||
p := (t.Primitive())
|
||||
closec := make(chan bool)
|
||||
currentTime := time.Now().String()
|
||||
|
||||
@@ -9,7 +9,7 @@ var (
|
||||
|
||||
type View interface {
|
||||
Content() [][]Content
|
||||
ContextOpener(*Main, func(int))
|
||||
ContextOpener(*Root, func(int))
|
||||
ContextKey() rune
|
||||
ContextHandler(start, end, sel int)
|
||||
ExternalInputCapture(e *tcell.EventKey) *tcell.EventKey
|
||||
|
||||
@@ -45,7 +45,7 @@ func (p *PlaylistView) Content() [][]Content {
|
||||
return c
|
||||
}
|
||||
|
||||
func (p *PlaylistView) ContextOpener(m *Main, s func(s int)) {
|
||||
func (p *PlaylistView) ContextOpener(m *Root, s func(s int)) {
|
||||
c := NewMenu()
|
||||
cc := []string{}
|
||||
plist, err := spt.CurrentUserPlaylists(func(s bool, err error) {})
|
||||
@@ -81,7 +81,7 @@ func (p *PlaylistView) ContextHandler(start, end, sel int) {
|
||||
|
||||
func (p *PlaylistView) ExternalInputCapture(e *tcell.EventKey) *tcell.EventKey {
|
||||
if e.Key() == tcell.KeyEnter {
|
||||
r, _ := Ui.MainS.View.GetSelection()
|
||||
r, _ := Ui.Main.View.GetSelection()
|
||||
if err := spt.PlaySongWithContext(&p.currentPlaylist.URI, r); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user