add more to track info dialog
This commit is contained in:
@@ -3,10 +3,12 @@ package dialogs
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/layout"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"github.com/dweymouth/supersonic/backend/mediaprovider"
|
||||
"github.com/dweymouth/supersonic/ui/util"
|
||||
@@ -19,6 +21,8 @@ type TrackInfoDialog struct {
|
||||
OnDismiss func()
|
||||
OnNavigateToArtist func(artistID string)
|
||||
OnNavigateToAlbum func(albumID string)
|
||||
OnNavigateToGenre func(genre string)
|
||||
OnCopyFilePath func()
|
||||
|
||||
track *mediaprovider.Track
|
||||
}
|
||||
@@ -53,8 +57,31 @@ func (t *TrackInfoDialog) CreateRenderer() fyne.WidgetRenderer {
|
||||
}
|
||||
c.Add(album)
|
||||
|
||||
if len(t.track.Genres) > 0 {
|
||||
c.Add(newFormText("Genres", true))
|
||||
genres := widgets.NewMultiHyperlink()
|
||||
genres.BuildSegments(t.track.Genres, t.track.Genres)
|
||||
genres.OnTapped = func(g string) {
|
||||
if t.OnNavigateToGenre != nil {
|
||||
t.OnNavigateToGenre(g)
|
||||
}
|
||||
}
|
||||
c.Add(genres)
|
||||
}
|
||||
|
||||
addFormRow(c, "Duration", util.SecondsToTimeString(float64(t.track.Duration)))
|
||||
addFormRow(c, "File path", t.track.FilePath)
|
||||
|
||||
copyBtn := widgets.NewIconButton(theme.ContentCopyIcon(), func() {
|
||||
if t.OnCopyFilePath != nil {
|
||||
t.OnCopyFilePath()
|
||||
}
|
||||
})
|
||||
copyBtn.IconSize = widgets.IconButtonSizeSmaller
|
||||
btnCtr := container.New(layout.NewCustomPaddedLayout(8, 0, 10, 0),
|
||||
container.NewVBox(copyBtn, layout.NewSpacer()))
|
||||
c.Add(container.NewHBox(btnCtr, newFormText("File path", true)))
|
||||
c.Add(newFormText(t.track.FilePath, false))
|
||||
|
||||
addFormRow(c, "Comment", t.track.Comment)
|
||||
addFormRow(c, "Year", strconv.Itoa(t.track.Year))
|
||||
addFormRow(c, "Track number", strconv.Itoa(t.track.TrackNumber))
|
||||
@@ -69,6 +96,10 @@ func (t *TrackInfoDialog) CreateRenderer() fyne.WidgetRenderer {
|
||||
addFormRow(c, "File size", util.BytesToSizeString(t.track.Size))
|
||||
addFormRow(c, "Play count", strconv.Itoa(t.track.PlayCount))
|
||||
|
||||
if !t.track.LastPlayed.IsZero() {
|
||||
addFormRow(c, "Last played", t.track.LastPlayed.Format(time.RFC1123))
|
||||
}
|
||||
|
||||
if t.track.ReplayGain.TrackPeak > 0 {
|
||||
addFormRow(c, "Track gain", fmt.Sprintf("%0.2f dB", t.track.ReplayGain.TrackGain))
|
||||
addFormRow(c, "Track peak", fmt.Sprintf("%0.6f", t.track.ReplayGain.TrackPeak))
|
||||
@@ -94,12 +125,16 @@ func (t *TrackInfoDialog) CreateRenderer() fyne.WidgetRenderer {
|
||||
container.NewHBox(layout.NewSpacer(), dismissBtn),
|
||||
),
|
||||
/*left/right*/ nil, nil,
|
||||
/*center*/ container.NewScroll(c),
|
||||
/*center*/ container.New(layout.NewCustomPaddedLayout(10, 10, 15, 15),
|
||||
container.NewScroll(c)),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
func addFormRow(c *fyne.Container, left, right string) {
|
||||
if right == "" {
|
||||
return
|
||||
}
|
||||
c.Add(newFormText(left, true))
|
||||
c.Add(newFormText(right, false))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user