Focus can now be switched from one primitive to other

This commit is contained in:
aditya-K2
2023-04-13 23:24:27 +05:30
parent c14b0b0316
commit a181569048
2 changed files with 25 additions and 1 deletions

View File

@@ -32,6 +32,7 @@ type Application struct {
CoverArt *CoverArt
Main *interactiveView
NavMenu *NavMenu
PlaylistNav *PlaylistNav
SearchBar *tview.Box
ProgressBar *ProgressBar
Root *Root
@@ -122,7 +123,6 @@ func NewApplication() *Application {
AddItem(pBar, 5, 1, false)
Root.Primitive("Main", MainFlex)
App.EnableMouse(true)
App.SetRoot(Root.Root, true).SetFocus(playlistNav.Table)
InitNotifier()
@@ -180,10 +180,26 @@ func NewApplication() *Application {
}
}()
App.SetInputCapture(func(e *tcell.EventKey) *tcell.EventKey {
if e.Rune() == '1' {
Ui.App.SetFocus(NavMenu.Table)
return nil
}
if e.Rune() == '2' {
Ui.App.SetFocus(playlistNav.Table)
return nil
}
if e.Rune() == '3' {
Ui.App.SetFocus(Main.Table)
return nil
}
return e
})
Ui = &Application{
App: App,
Main: Main,
CoverArt: coverArt,
PlaylistNav: playlistNav,
NavMenu: NavMenu,
SearchBar: searchbar,
ProgressBar: pBar,

8
ui/view_artist.go Normal file
View File

@@ -0,0 +1,8 @@
package ui
import "github.com/zmb3/spotify/v2"
type ArtistView struct {
topTracks []spotify.FullTrack
albums []spotify.SimpleAlbum
}