From a1815690489e9f38806ca00e42b405b3839bdf78 Mon Sep 17 00:00:00 2001 From: aditya-K2 Date: Thu, 13 Apr 2023 23:24:27 +0530 Subject: [PATCH] Focus can now be switched from one primitive to other --- ui/app.go | 18 +++++++++++++++++- ui/view_artist.go | 8 ++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 ui/view_artist.go diff --git a/ui/app.go b/ui/app.go index fff65f2..a812e48 100644 --- a/ui/app.go +++ b/ui/app.go @@ -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, diff --git a/ui/view_artist.go b/ui/view_artist.go new file mode 100644 index 0000000..cbbb73c --- /dev/null +++ b/ui/view_artist.go @@ -0,0 +1,8 @@ +package ui + +import "github.com/zmb3/spotify/v2" + +type ArtistView struct { + topTracks []spotify.FullTrack + albums []spotify.SimpleAlbum +}