show full size cover when clicking thumbnail in now playing display
This commit is contained in:
+18
-6
@@ -3,6 +3,7 @@ package ui
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"image"
|
"image"
|
||||||
|
"log"
|
||||||
"supersonic/backend"
|
"supersonic/backend"
|
||||||
"supersonic/player"
|
"supersonic/player"
|
||||||
"supersonic/ui/controller"
|
"supersonic/ui/controller"
|
||||||
@@ -25,12 +26,14 @@ type BottomPanel struct {
|
|||||||
NowPlaying *widgets.NowPlayingCard
|
NowPlaying *widgets.NowPlayingCard
|
||||||
Controls *widgets.PlayerControls
|
Controls *widgets.PlayerControls
|
||||||
AuxControls *widgets.AuxControls
|
AuxControls *widgets.AuxControls
|
||||||
container *fyne.Container
|
|
||||||
|
coverArtID string
|
||||||
|
container *fyne.Container
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ fyne.Widget = (*BottomPanel)(nil)
|
var _ fyne.Widget = (*BottomPanel)(nil)
|
||||||
|
|
||||||
func NewBottomPanel(p *player.Player, nav func(controller.Route)) *BottomPanel {
|
func NewBottomPanel(p *player.Player, contr *controller.Controller) *BottomPanel {
|
||||||
bp := &BottomPanel{}
|
bp := &BottomPanel{}
|
||||||
bp.ExtendBaseWidget(bp)
|
bp.ExtendBaseWidget(bp)
|
||||||
p.OnPaused(func() {
|
p.OnPaused(func() {
|
||||||
@@ -44,11 +47,19 @@ func NewBottomPanel(p *player.Player, nav func(controller.Route)) *BottomPanel {
|
|||||||
})
|
})
|
||||||
|
|
||||||
bp.NowPlaying = widgets.NewNowPlayingCard()
|
bp.NowPlaying = widgets.NewNowPlayingCard()
|
||||||
|
bp.NowPlaying.OnShowCoverImage = func() {
|
||||||
|
im, err := bp.ImageManager.GetFullSizeCoverArt(bp.coverArtID)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("error getting full size cover image: %s", err.Error())
|
||||||
|
} else {
|
||||||
|
contr.ShowPopUpImage(im)
|
||||||
|
}
|
||||||
|
}
|
||||||
bp.NowPlaying.OnAlbumNameTapped(func() {
|
bp.NowPlaying.OnAlbumNameTapped(func() {
|
||||||
nav(controller.AlbumRoute(bp.playbackManager.NowPlaying().AlbumID))
|
contr.NavigateTo(controller.AlbumRoute(bp.playbackManager.NowPlaying().AlbumID))
|
||||||
})
|
})
|
||||||
bp.NowPlaying.OnArtistNameTapped(func() {
|
bp.NowPlaying.OnArtistNameTapped(func() {
|
||||||
nav(controller.ArtistRoute(bp.playbackManager.NowPlaying().ArtistID))
|
contr.NavigateTo(controller.ArtistRoute(bp.playbackManager.NowPlaying().ArtistID))
|
||||||
})
|
})
|
||||||
bp.Controls = widgets.NewPlayerControls()
|
bp.Controls = widgets.NewPlayerControls()
|
||||||
bp.Controls.OnPlayPause(func() {
|
bp.Controls.OnPlayPause(func() {
|
||||||
@@ -86,8 +97,9 @@ func (bp *BottomPanel) SetPlaybackManager(pm *backend.PlaybackManager) {
|
|||||||
|
|
||||||
func (bp *BottomPanel) onSongChange(song *subsonic.Child, _ *subsonic.Child) {
|
func (bp *BottomPanel) onSongChange(song *subsonic.Child, _ *subsonic.Child) {
|
||||||
if song == nil {
|
if song == nil {
|
||||||
bp.NowPlaying.Update("", "", "", nil)
|
bp.NowPlaying.Update("", "", false, "", nil)
|
||||||
} else {
|
} else {
|
||||||
|
bp.coverArtID = song.CoverArt
|
||||||
var im image.Image
|
var im image.Image
|
||||||
if bp.ImageManager != nil {
|
if bp.ImageManager != nil {
|
||||||
// set image to expire not long after the length of the song
|
// set image to expire not long after the length of the song
|
||||||
@@ -97,7 +109,7 @@ func (bp *BottomPanel) onSongChange(song *subsonic.Child, _ *subsonic.Child) {
|
|||||||
imgTTLSec := song.Duration + 30
|
imgTTLSec := song.Duration + 30
|
||||||
im, _ = bp.ImageManager.GetCoverThumbnailWithTTL(song.CoverArt, time.Duration(imgTTLSec)*time.Second)
|
im, _ = bp.ImageManager.GetCoverThumbnailWithTTL(song.CoverArt, time.Duration(imgTTLSec)*time.Second)
|
||||||
}
|
}
|
||||||
bp.NowPlaying.Update(song.Title, song.Artist, song.Album, im)
|
bp.NowPlaying.Update(song.Title, song.Artist, song.ArtistID != "", song.Album, im)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -67,7 +67,7 @@ func NewMainWindow(fyneApp fyne.App, appName, appVersion string, app *backend.Ap
|
|||||||
m.Controller.ReloadFunc = m.BrowsingPane.Reload
|
m.Controller.ReloadFunc = m.BrowsingPane.Reload
|
||||||
m.Controller.CurPageFunc = m.BrowsingPane.CurPage
|
m.Controller.CurPageFunc = m.BrowsingPane.CurPage
|
||||||
|
|
||||||
m.BottomPanel = NewBottomPanel(app.Player, m.Router.NavigateTo)
|
m.BottomPanel = NewBottomPanel(app.Player, m.Controller)
|
||||||
m.BottomPanel.SetPlaybackManager(app.PlaybackManager)
|
m.BottomPanel.SetPlaybackManager(app.PlaybackManager)
|
||||||
m.BottomPanel.ImageManager = app.ImageManager
|
m.BottomPanel.ImageManager = app.ImageManager
|
||||||
m.container = container.NewBorder(nil, m.BottomPanel, nil, nil, m.BrowsingPane)
|
m.container = container.NewBorder(nil, m.BottomPanel, nil, nil, m.BrowsingPane)
|
||||||
|
|||||||
@@ -18,7 +18,9 @@ type NowPlayingCard struct {
|
|||||||
trackName *widget.Label
|
trackName *widget.Label
|
||||||
artistName *CustomHyperlink
|
artistName *CustomHyperlink
|
||||||
albumName *CustomHyperlink
|
albumName *CustomHyperlink
|
||||||
cover *canvas.Image
|
cover *TappableImage
|
||||||
|
|
||||||
|
OnShowCoverImage func()
|
||||||
|
|
||||||
c fyne.CanvasObject
|
c fyne.CanvasObject
|
||||||
}
|
}
|
||||||
@@ -28,9 +30,9 @@ func NewNowPlayingCard() *NowPlayingCard {
|
|||||||
trackName: widget.NewLabel(""),
|
trackName: widget.NewLabel(""),
|
||||||
artistName: NewCustomHyperlink(),
|
artistName: NewCustomHyperlink(),
|
||||||
albumName: NewCustomHyperlink(),
|
albumName: NewCustomHyperlink(),
|
||||||
cover: &canvas.Image{},
|
|
||||||
}
|
}
|
||||||
n.ExtendBaseWidget(n)
|
n.ExtendBaseWidget(n)
|
||||||
|
n.cover = NewTappableImage(n.onShowCoverImage)
|
||||||
n.artistName.Hidden = true
|
n.artistName.Hidden = true
|
||||||
n.albumName.Hidden = true
|
n.albumName.Hidden = true
|
||||||
n.trackName.Wrapping = fyne.TextTruncate
|
n.trackName.Wrapping = fyne.TextTruncate
|
||||||
@@ -46,17 +48,24 @@ func NewNowPlayingCard() *NowPlayingCard {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (n *NowPlayingCard) onShowCoverImage() {
|
||||||
|
if n.OnShowCoverImage != nil {
|
||||||
|
n.OnShowCoverImage()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (n *NowPlayingCard) CreateRenderer() fyne.WidgetRenderer {
|
func (n *NowPlayingCard) CreateRenderer() fyne.WidgetRenderer {
|
||||||
return widget.NewSimpleRenderer(n.c)
|
return widget.NewSimpleRenderer(n.c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *NowPlayingCard) Update(track, artist, album string, cover image.Image) {
|
func (n *NowPlayingCard) Update(track, artist string, artistNavigable bool, album string, cover image.Image) {
|
||||||
n.trackName.Text = track
|
n.trackName.Text = track
|
||||||
n.artistName.SetText(artist)
|
n.artistName.SetText(artist)
|
||||||
n.artistName.Hidden = artist == ""
|
n.artistName.Hidden = artist == ""
|
||||||
|
n.artistName.Disabled = !artistNavigable
|
||||||
n.albumName.SetText(album)
|
n.albumName.SetText(album)
|
||||||
n.albumName.Hidden = album == ""
|
n.albumName.Hidden = album == ""
|
||||||
n.cover.Image = cover
|
n.cover.Image.Image = cover
|
||||||
n.c.Refresh()
|
n.c.Refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user