diff options
Diffstat (limited to 'src/page_queue.go')
-rw-r--r-- | src/page_queue.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/page_queue.go b/src/page_queue.go new file mode 100644 index 0000000..fe8910f --- /dev/null +++ b/src/page_queue.go | |||
@@ -0,0 +1,38 @@ | |||
1 | package src | ||
2 | |||
3 | import ( | ||
4 | "fmt" | ||
5 | |||
6 | "github.com/rivo/tview" | ||
7 | ) | ||
8 | |||
9 | func (a *app) queuePage() tview.Primitive { | ||
10 | a.playQueueList = tview.NewList(). | ||
11 | ShowSecondaryText(false). | ||
12 | SetHighlightFullLine(true) | ||
13 | |||
14 | a.setupMusicControlKeys(a.playQueueList.Box) | ||
15 | |||
16 | a.updatePageQueue() | ||
17 | |||
18 | return a.playQueueList | ||
19 | } | ||
20 | |||
21 | func (a *app) updatePageQueue() { | ||
22 | sel := a.playQueueList.GetCurrentItem() | ||
23 | a.playQueueList.Clear() | ||
24 | |||
25 | for _, song := range a.playQueue.GetSongs() { | ||
26 | ownSong := *song | ||
27 | a.playQueueList.AddItem(fmt.Sprintf("* %s - %s", song.Title, song.Artist), "", 0, func() { | ||
28 | a.playQueue.SkipTo(&ownSong) | ||
29 | a.playQueueList.SetCurrentItem(0) | ||
30 | }) | ||
31 | } | ||
32 | |||
33 | if sel < a.playQueueList.GetItemCount() { | ||
34 | a.playQueueList.SetCurrentItem(sel) | ||
35 | } else { | ||
36 | a.playQueueList.SetCurrentItem(a.playQueueList.GetItemCount() - 1) | ||
37 | } | ||
38 | } | ||