feat(eq): restyle equalizer screen and add custom presets

Restyle the Ecualizador settings screen to the new visual language while
keeping the equalizer at 5 bands (spike-resolved, Engram id 2498 - band
count is device-reported via just_audio's AndroidEqualizer, not app-chosen;
the approved mockup's 7 sliders would silently no-op on typical hardware).

- Restyle EcualizadorWidget in place: strip its internal title + preset
  chip row (the pushed screen's header now carries the title), add a
  habilitado parameter that greys/disables every slider when EQ is off.
  Widen PresetsEcualizadorWidget additively (personalizados param) so
  custom presets can join the chip row without a second implementation.
- Add servicio_presets_personalizados.dart (new file, own SharedPreferences
  key eq_custom_presets_v1) for custom EQ preset persistence - kept out of
  servicio_ecualizador.dart, which has an empty-git-diff success criterion
  for this change. preset_ecualizador.dart is unchanged: a custom preset is
  just a PresetEcualizador with a user-supplied name.
- Extend EstadoEcualizador with presetsPersonalizados,
  guardarPresetPersonalizado (validates non-empty name),
  eliminarPresetPersonalizado. The load is a new explicit
  cargarPresetsPersonalizados(), deliberately NOT folded into
  cargarPersistido(): that method is exercised ~30 times by
  estado_ecualizador_test.dart (protected, must stay unmodified) via Fakes
  only, with no SharedPreferences awareness in that file.
- Build out the Ecualizador screen body: base-vs-per-station explainer
  banner, a "Salida activa" row surfaced on the main screen (previously
  Advanced-only), an "Emisoras con ajuste propio" drill-down sourced from
  the existing presetsPorEmisora map, and a "Guardar como preset" action.

New coverage lives in new files rather than touching the three protected
EQ test files: ecualizador_widget_test.dart (component-level, did not
exist before this commit), servicio_presets_personalizados_test.dart, and
estado_ecualizador_presets_personalizados_test.dart. servicio_ecualizador.dart,
servicio_audio.dart and the three protected EQ test files keep an empty
git diff. Full suite: 713/713 green (2 skipped, unchanged), up from 682.

size:exception - realized 1,954 changed lines (25 files, plus this docs
update) against the 400-550 forecast: lib/ + ARB alone is ~650 lines, near
the top of the forecast band by itself since this WU also had to build out
a screen body WU3a only stubbed; the rest is 4 test files (675 lines) and
11 new ARB keys regenerating 13 lib/l10n/gen files (~546 lines) - the same
pattern every prior work unit in this branch has hit. Not splittable: WU14
reuses this unit's editor component by exact runtime type and cannot begin
until this lands as a whole.
This commit is contained in:
2026-07-29 12:53:12 +02:00
parent e1732af222
commit c9fe0ad651
26 changed files with 1857 additions and 97 deletions
+84 -67
View File
@@ -9,10 +9,16 @@ class EcualizadorWidget extends StatefulWidget {
final PresetEcualizador preset;
final void Function(PresetEcualizador) onCambio;
/// Design ADR-5: greys and disables every slider when the equalizer
/// itself is off, instead of leaving fully-interactive controls that
/// silently do nothing.
final bool habilitado;
const EcualizadorWidget({
super.key,
required this.preset,
required this.onCambio,
this.habilitado = true,
});
@override
@@ -50,91 +56,92 @@ class _EcualizadorWidgetState extends State<EcualizadorWidget> {
final tokens = context.pluriTokens;
final l10n = AppLocalizations.of(context);
// Design ADR-5: the title + preset Chip row that used to live here is
// gone — the pushed screen's own 56px header carries the title now, and
// the preset chip ROW (a different, still-reusable widget,
// [PresetsEcualizadorWidget] below) is rendered by the caller alongside
// this widget instead of being duplicated inside it.
return PluriGlassSurface(
borderRadius: BorderRadius.circular(tokens.radiusLg),
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Row(
children: [
Text(
l10n.equalizerTitle,
style: theme.textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.w700,
),
),
const Spacer(),
Chip(
label: Text(
_nombrePreset(l10n, widget.preset.nombre),
style: theme.textTheme.labelMedium,
),
backgroundColor: theme.colorScheme.secondaryContainer
.withValues(alpha: 0.75),
),
],
),
const SizedBox(height: 14),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
for (int i = 0; i < 5; i++)
Expanded(
child: Card(
color: theme.colorScheme.surfaceContainerHighest.withValues(
alpha: 0.35,
for (int i = 0; i < 5; i++)
Expanded(
child: AnimatedOpacity(
duration: const Duration(milliseconds: 150),
opacity: widget.habilitado ? 1.0 : 0.4,
child: Card(
color: tokens.listSurface.withValues(alpha: 0.6),
margin: const EdgeInsets.symmetric(horizontal: 4),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(tokens.radiusSm),
),
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 10,
horizontal: 4,
),
margin: const EdgeInsets.symmetric(horizontal: 4),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(14),
),
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 8,
horizontal: 4,
),
child: Column(
children: [
SizedBox(
height: 152,
child: Semantics(
slider: true,
label: l10n.equalizerBandLabel(_etiquetas[i]),
value: l10n.equalizerBandValue(
_bandas[i].toStringAsFixed(1),
),
child: RotatedBox(
quarterTurns: 3,
child: Column(
children: [
SizedBox(
height: 152,
child: Semantics(
slider: true,
enabled: widget.habilitado,
label: l10n.equalizerBandLabel(_etiquetas[i]),
value: l10n.equalizerBandValue(
_bandas[i].toStringAsFixed(1),
),
child: RotatedBox(
quarterTurns: 3,
child: SliderTheme(
data: SliderTheme.of(context).copyWith(
trackHeight: 5,
activeTrackColor: tokens.liveGreen,
thumbColor: tokens.liveGreen,
inactiveTrackColor:
theme.colorScheme.surfaceContainerHighest,
overlayColor: tokens.liveGreen.withValues(
alpha: 0.15,
),
),
child: Slider(
value: _bandas[i],
min: -12.0,
max: 12.0,
divisions: 24,
onChanged: (v) => _actualizarBanda(i, v),
onChanged:
widget.habilitado
? (v) => _actualizarBanda(i, v)
: null,
),
),
),
),
Text(
'${_bandas[i].toStringAsFixed(1)}dB',
style: theme.textTheme.labelSmall,
),
Text(
'${_bandas[i].toStringAsFixed(1)}dB',
style: theme.textTheme.labelSmall?.copyWith(
color: tokens.liveGreen,
fontWeight: FontWeight.w700,
),
Text(
_etiquetas[i],
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
textAlign: TextAlign.center,
),
Text(
_etiquetas[i],
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
],
),
textAlign: TextAlign.center,
),
],
),
),
),
],
),
),
),
],
),
);
@@ -158,21 +165,31 @@ class PresetsEcualizadorWidget extends StatelessWidget {
final PresetEcualizador presetActual;
final void Function(PresetEcualizador) onSeleccionar;
/// User-saved custom presets (WU13, `eq-custom-presets` spec), appended
/// after the 6 fixed ones. Additive-only parameter — defaults to empty so
/// this stays the same widget, not a new one (design ADR-5: "stays
/// as-is" means no restyle, not that it can never gain new data to show).
/// `_nombrePreset`'s default case already falls through to the raw name,
/// so a custom preset's chip label needs no special-casing here.
final List<PresetEcualizador> personalizados;
const PresetsEcualizadorWidget({
super.key,
required this.presetActual,
required this.onSeleccionar,
this.personalizados = const [],
});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final l10n = AppLocalizations.of(context);
final todos = [...PresetEcualizador.presets, ...personalizados];
return Wrap(
spacing: 8,
runSpacing: 6,
children:
PresetEcualizador.presets.map((p) {
todos.map((p) {
final selected = p.nombre == presetActual.nombre;
return ChoiceChip(
label: Text(_nombrePreset(l10n, p.nombre)),