From edaa93de69455328636f33796d7e251927682d6d Mon Sep 17 00:00:00 2001 From: aditya-K2 Date: Wed, 19 Apr 2023 09:17:07 +0530 Subject: [PATCH] Using Updated Ui values --- main.go | 2 +- ui/cover_art.go | 2 +- ui/device.go | 2 +- ui/interactive.go | 4 ++-- ui/nav.go | 1 + ui/notify.go | 16 ++++++++-------- ui/progress.go | 6 +++--- ui/search.go | 4 ++-- ui/view_album.go | 2 +- ui/view_albums.go | 4 ++-- ui/view_artist.go | 4 ++-- ui/view_artists.go | 2 +- ui/view_liked.go | 2 +- ui/view_playlist.go | 2 +- ui/view_recent.go | 2 +- ui/view_search.go | 2 +- ui/view_top.go | 4 ++-- 17 files changed, 31 insertions(+), 30 deletions(-) diff --git a/main.go b/main.go index 627e7cc..c8ef527 100644 --- a/main.go +++ b/main.go @@ -11,7 +11,7 @@ func main() { if err := spt.InitClient(); err != nil { panic(err) } - if err := ui.NewApplication().App.Run(); err != nil { + if err := ui.NewApplication().Run(); err != nil { panic(err) } } diff --git a/ui/cover_art.go b/ui/cover_art.go index 0fee859..d8524a0 100644 --- a/ui/cover_art.go +++ b/ui/cover_art.go @@ -60,7 +60,7 @@ func getFontWidth() (int, int, error) { if err != nil { return 0, 0, err } - _, _, rw, rh := Ui.Root.Root.GetRect() + _, _, rw, rh := root.Root.GetRect() if rw == 0 || rh == 0 { return 0, 0, errors.New("Unable to get row width and height") } diff --git a/ui/device.go b/ui/device.go index 7e825a6..37852b5 100644 --- a/ui/device.go +++ b/ui/device.go @@ -23,5 +23,5 @@ func OpenDeviceMenu() { RefreshProgress(true) } }) - Ui.Root.AddCenteredWidget(m) + root.AddCenteredWidget(m) } diff --git a/ui/interactive.go b/ui/interactive.go index e9b3090..0bb0d7a 100644 --- a/ui/interactive.go +++ b/ui/interactive.go @@ -3,8 +3,8 @@ package ui import ( "errors" - "github.com/gdamore/tcell/v2" "github.com/aditya-K2/tview" + "github.com/gdamore/tcell/v2" ) var ( @@ -162,7 +162,7 @@ func (i *interactiveView) getHandler(s string) func(e *tcell.EventKey) *tcell.Ev }, "openCtx": func(e *tcell.EventKey) *tcell.EventKey { if GetCurrentView().ContextOpener() != nil { - GetCurrentView().ContextOpener()(Ui.Root, Ui.Main.SelectionHandler) + GetCurrentView().ContextOpener()(root, Main.SelectionHandler) return nil } return e diff --git a/ui/nav.go b/ui/nav.go index 3d48d8d..c99bcc3 100644 --- a/ui/nav.go +++ b/ui/nav.go @@ -56,6 +56,7 @@ func NewPlaylistNav() *PlaylistNav { T := tview.NewTable() T.SetSelectable(true, false).SetBorder(true) T.SetTitle("Playlists").SetTitleAlign(tview.AlignLeft) + T.SetBackgroundColor(tcell.ColorDefault) v := &PlaylistNav{&defView{}, T, nil, make(chan bool), func(err error) { if err != nil { SendNotification(err.Error()) diff --git a/ui/notify.go b/ui/notify.go index 061f2e5..44abace 100644 --- a/ui/notify.go +++ b/ui/notify.go @@ -6,8 +6,8 @@ import ( "github.com/aditya-K2/utils" - "github.com/gdamore/tcell/v2" "github.com/aditya-K2/tview" + "github.com/gdamore/tcell/v2" ) var ( @@ -138,18 +138,18 @@ func notify(n *notification) { npos = posArr.GetNextPosition() } n.position = npos - Ui.Root.Root.AddPage(currentTime, n, false, true) - Ui.App.Draw() - Ui.App.SetFocus(Ui.Main.Table) + root.Root.AddPage(currentTime, n, false, true) + App.Draw() + App.SetFocus(Main.Table) if n.msg != nil { n.text = <-n.msg - Ui.App.Draw() + App.Draw() } time.Sleep(n.timer) - Ui.Root.Root.RemovePage(currentTime) + root.Root.RemovePage(currentTime) posArr.Free(npos) - Ui.App.SetFocus(Ui.Main.Table) - Ui.App.Draw() + App.SetFocus(Main.Table) + App.Draw() }() } diff --git a/ui/progress.go b/ui/progress.go index 9496b1f..a777610 100644 --- a/ui/progress.go +++ b/ui/progress.go @@ -11,8 +11,8 @@ import ( "github.com/aditya-K2/gspt/config" "github.com/aditya-K2/gspt/spt" - "github.com/aditya-K2/utils" "github.com/aditya-K2/tview" + "github.com/aditya-K2/utils" ) var ( @@ -89,7 +89,7 @@ func RefreshProgress(force bool) { stateLock.Lock() state = s stateLock.Unlock() - if Ui != nil && Ui.CoverArt != nil { + if coverArt != nil { // If No Item is playing if (state.Item == nil) || // An Item is Playing but doesn't match the cached Track ID @@ -100,7 +100,7 @@ func RefreshProgress(force bool) { ctrackId = state.Item.ID } if !config.Config.HideImage { - Ui.CoverArt.RefreshState() + coverArt.RefreshState() } } } diff --git a/ui/search.go b/ui/search.go index 06becd8..28f2274 100644 --- a/ui/search.go +++ b/ui/search.go @@ -22,14 +22,14 @@ func NewSearchBar() *tview.InputField { switch k { case tcell.KeyEscape: { - Ui.App.SetFocus(Ui.Main.Table) + App.SetFocus(Main.Table) T.SetText("") } case tcell.KeyEnter: { searchView.SetSearch(T.GetText()) SetCurrentView(searchView) - Ui.App.SetFocus(Ui.Main.Table) + App.SetFocus(Main.Table) T.SetText("") } } diff --git a/ui/view_album.go b/ui/view_album.go index 5bd920e..9f9d5d5 100644 --- a/ui/view_album.go +++ b/ui/view_album.go @@ -88,7 +88,7 @@ func (a *AlbumView) ContextHandler() func(start, end, sel int) { } func (a *AlbumView) PlaySelectEntry() { - r, _ := Ui.Main.Table.GetSelection() + r, _ := Main.Table.GetSelection() if err := spt.PlaySongWithContext(&a.currentFullAlbum.URI, r); err != nil { SendNotification(err.Error()) } diff --git a/ui/view_albums.go b/ui/view_albums.go index 962c402..04dd5e8 100644 --- a/ui/view_albums.go +++ b/ui/view_albums.go @@ -48,13 +48,13 @@ func (a *AlbumsView) Content() func() [][]Content { } func (a *AlbumsView) OpenAlbum() { - r, _ := Ui.Main.Table.GetSelection() + r, _ := Main.Table.GetSelection() albumView.SetAlbum((*a.savedAlbums)[r].Name, &(*a.savedAlbums)[r].ID) SetCurrentView(albumView) } func (a *AlbumsView) PlaySelectEntry() { - r, _ := Ui.Main.Table.GetSelection() + r, _ := Main.Table.GetSelection() if err := spt.PlayContext(&(*a.savedAlbums)[r].URI); err != nil { SendNotification(err.Error()) } diff --git a/ui/view_artist.go b/ui/view_artist.go index c6dcc91..3cd5457 100644 --- a/ui/view_artist.go +++ b/ui/view_artist.go @@ -67,7 +67,7 @@ func (a *ArtistView) Content() func() [][]Content { } func (a *ArtistView) PlayEntry() { - r, _ := Ui.Main.Table.GetSelection() + r, _ := Main.Table.GetSelection() if r > 0 { if r < (len(a.albums) + 1) { if err := spt.PlayContext(&a.albums[r-1].URI); err != nil { @@ -78,7 +78,7 @@ func (a *ArtistView) PlayEntry() { } func (a *ArtistView) OpenEntry() { - r, _ := Ui.Main.Table.GetSelection() + r, _ := Main.Table.GetSelection() if r > 0 { if r < (len(a.albums) + 1) { albumView.SetAlbum(a.albums[r-1].Name, &a.albums[r-1].ID) diff --git a/ui/view_artists.go b/ui/view_artists.go index 64fbc13..ae25608 100644 --- a/ui/view_artists.go +++ b/ui/view_artists.go @@ -47,7 +47,7 @@ func (a *ArtistsView) Content() func() [][]Content { } func (a *ArtistsView) OpenArtist() { - r, _ := Ui.Main.Table.GetSelection() + r, _ := Main.Table.GetSelection() artistView.SetArtist(&(*a.followedArtists)[r].ID) artistView.RefreshState() SetCurrentView(artistView) diff --git a/ui/view_liked.go b/ui/view_liked.go index 14e89bf..aa11a42 100644 --- a/ui/view_liked.go +++ b/ui/view_liked.go @@ -75,7 +75,7 @@ func (l *LikedSongsView) ContextHandler() func(start, end, sel int) { } func (l *LikedSongsView) OpenEntry() { - r, _ := Ui.Main.Table.GetSelection() + r, _ := Main.Table.GetSelection() if err := spt.PlaySong((*l.likedSongs)[r].URI); err != nil { SendNotification(err.Error()) } diff --git a/ui/view_playlist.go b/ui/view_playlist.go index 1f74bd6..6362611 100644 --- a/ui/view_playlist.go +++ b/ui/view_playlist.go @@ -86,7 +86,7 @@ func (p *PlaylistView) ContextHandler() func(start, end, sel int) { } func (p *PlaylistView) PlaySelectEntry() { - r, _ := Ui.Main.Table.GetSelection() + r, _ := Main.Table.GetSelection() if err := spt.PlaySongWithContext(&p.currentPlaylist.URI, r); err != nil { SendNotification(err.Error()) } diff --git a/ui/view_recent.go b/ui/view_recent.go index d9e94ec..81af374 100644 --- a/ui/view_recent.go +++ b/ui/view_recent.go @@ -84,7 +84,7 @@ func (r *RecentlyPlayedView) RefreshState() { } func (re *RecentlyPlayedView) SelectEntry(e *tcell.EventKey) *tcell.EventKey { - r, _ := Ui.Main.Table.GetSelection() + r, _ := Main.Table.GetSelection() contextUri := re.recentlyPlayed[r].PlaybackContext.URI if string(contextUri) != "" { if err := spt.PlaySongWithContextURI(&re.recentlyPlayed[r].PlaybackContext.URI, &re.recentlyPlayed[r].Track.URI); err != nil { diff --git a/ui/view_search.go b/ui/view_search.go index 075193d..e9a6f71 100644 --- a/ui/view_search.go +++ b/ui/view_search.go @@ -102,7 +102,7 @@ func (a *SearchView) Content() func() [][]Content { } func (a *SearchView) SelectEntry() { - r, _ := Ui.Main.Table.GetSelection() + r, _ := Main.Table.GetSelection() switch a.searchContent[r].Type { case "track": { diff --git a/ui/view_top.go b/ui/view_top.go index 93aebb4..de697c7 100644 --- a/ui/view_top.go +++ b/ui/view_top.go @@ -70,7 +70,7 @@ func (a *TopTracksView) Content() func() [][]Content { } func (a *TopTracksView) PlaySelectedEntry() { - r, _ := Ui.Main.Table.GetSelection() + r, _ := Main.Table.GetSelection() if r > 0 { if r < (len(a.topArtists) + 1) { if err := spt.PlayContext(&a.topArtists[r-1].URI); err != nil { @@ -82,7 +82,7 @@ func (a *TopTracksView) PlaySelectedEntry() { } func (a *TopTracksView) OpenSelectEntry() { - r, _ := Ui.Main.Table.GetSelection() + r, _ := Main.Table.GetSelection() if r > 0 { if r < (len(a.topArtists) + 1) { artistView.SetArtist(&(a.topArtists)[r-1].ID)