feat(buscar): add discovery landing state, filter pills, counter, and sort
This commit is contained in:
@@ -458,6 +458,7 @@ class EstadoRadio extends ChangeNotifier {
|
||||
_ordenListas = switch (raw) {
|
||||
'nombre' => OrdenEmisoras.nombre,
|
||||
'calidad' => OrdenEmisoras.calidad,
|
||||
'popularidad' => OrdenEmisoras.popularidad,
|
||||
_ => OrdenEmisoras.calidad,
|
||||
};
|
||||
}
|
||||
@@ -874,6 +875,7 @@ class EstadoRadio extends ChangeNotifier {
|
||||
_ordenListas = switch (ordenRaw) {
|
||||
'nombre' => OrdenEmisoras.nombre,
|
||||
'calidad' => OrdenEmisoras.calidad,
|
||||
'popularidad' => OrdenEmisoras.popularidad,
|
||||
_ => OrdenEmisoras.calidad,
|
||||
};
|
||||
await prefs.setString(_keyOrdenListas, _ordenListas.name);
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import '../modelos/emisora.dart';
|
||||
|
||||
/// User-selectable ordering for every station list in the app.
|
||||
enum OrdenEmisoras { nombre, calidad }
|
||||
///
|
||||
/// WU6 adds [popularidad] to the Buscar "Ordenar" control (design ADR-4),
|
||||
/// backed by fields the model already carries (`votes`, `clickcount`) —
|
||||
/// no new API surface, no server-side `order` parameter.
|
||||
enum OrdenEmisoras { nombre, calidad, popularidad }
|
||||
|
||||
/// Returns a sorted COPY of [emisoras] according to [orden].
|
||||
List<Emisora> ordenarEmisoras(List<Emisora> emisoras, OrdenEmisoras orden) {
|
||||
@@ -17,6 +21,12 @@ List<Emisora> ordenarEmisoras(List<Emisora> emisoras, OrdenEmisoras orden) {
|
||||
if (porBitrate != 0) return porBitrate;
|
||||
return 0;
|
||||
});
|
||||
case OrdenEmisoras.popularidad:
|
||||
ordenadas.sort((a, b) {
|
||||
final porVotos = b.votes.compareTo(a.votes);
|
||||
if (porVotos != 0) return porVotos;
|
||||
return b.clickcount.compareTo(a.clickcount);
|
||||
});
|
||||
}
|
||||
return ordenadas;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user