translate sort order strings

This commit is contained in:
Drew Weymouth
2024-07-21 16:23:47 -07:00
parent 53f29e08c4
commit 4afedda04e
11 changed files with 123 additions and 111 deletions
+12 -8
View File
@@ -8,6 +8,7 @@ import (
"fyne.io/fyne/v2/widget"
"github.com/dweymouth/supersonic/backend"
"github.com/dweymouth/supersonic/backend/mediaprovider"
"github.com/dweymouth/supersonic/sharedutil"
"github.com/dweymouth/supersonic/ui/controller"
myTheme "github.com/dweymouth/supersonic/ui/theme"
"github.com/dweymouth/supersonic/ui/util"
@@ -50,22 +51,25 @@ func (a *albumsPageAdapter) PlaceholderResource() fyne.Resource { return myTheme
func (a *albumsPageAdapter) Route() controller.Route { return controller.AlbumsRoute() }
func (a *albumsPageAdapter) SortOrders() ([]string, string) {
func (a *albumsPageAdapter) SortOrders() ([]string, int) {
orders := a.mp.AlbumSortOrders()
sortOrder := a.cfg.SortOrder
if !slices.Contains(orders, sortOrder) {
sortOrder = string(orders[0])
sortOrder := slices.Index(orders, a.cfg.SortOrder)
if sortOrder < 0 {
sortOrder = 0
}
return orders, sortOrder
translatedOrders := sharedutil.MapSlice(orders, func(s string) string { return lang.L(s) })
return translatedOrders, sortOrder
}
func (a *albumsPageAdapter) SaveSortOrder(order string) {
a.cfg.SortOrder = order
func (a *albumsPageAdapter) SaveSortOrder(orderIdx int) {
a.cfg.SortOrder = a.mp.AlbumSortOrders()[orderIdx]
}
func (a *albumsPageAdapter) ActionButton() *widget.Button { return nil }
func (a *albumsPageAdapter) Iter(sortOrder string, filter mediaprovider.AlbumFilter) widgets.GridViewIterator {
func (a *albumsPageAdapter) Iter(sortOrderIdx int, filter mediaprovider.AlbumFilter) widgets.GridViewIterator {
sortOrder := a.mp.AlbumSortOrders()[sortOrderIdx]
return widgets.NewGridViewAlbumIterator(a.mp.IterateAlbums(sortOrder, filter))
}