feat(favoritos): replace stacked group panels with chip-filtered reorderable list
Replaces the stacked per-group panel layout with a single
chip-filtered flat list. Chips read "{name} · {count}" (new ARB keys
favoriteGroupsChipLabel/favoritesFilterAllLabel), one per group plus
an "All" chip. Rows drag-reorder via a leading handle
(ReorderableDragStartListener, buildDefaultDragHandles: false) using
the modern onReorderItem callback rather than the now-@Deprecated
onReorder (Flutter 3.44 marks it obsolete).
EstadoRadio additions: listaFavoritosManual (a new memoized getter
returning the stored order untouched by the global ordenListas
setting - listaFavoritos itself always re-sorts by
name/quality on every read, which would silently discard any
drag-to-reorder), reordenarFavorito (thin wrapper over the
already-existing ServicioFavoritos.reordenar, previously unused
outside its own service test), and ordenarFavoritos (applies an
existing OrdenEmisoras criterion via ordenarEmisoras() and persists
the result as the new manual order, so the swap_vert sort action's
result also survives a restart). listaFavoritos itself is untouched,
so Android Auto's tree and the future Escuchar grid (WU5) are
unaffected by Favoritos' own manual order.
Group management: an "Manage lists" action chip pushes the existing
PantallaAjustesGruposFavoritos screen (Settings' own screen, reused
rather than duplicated) - a second entry point to the same screen.
Custom-station CTA: a new dashed-bordered card opens the add-station
form directly; that form was renamed from private _FormularioEmisora
to public FormularioEmisoraPersonalizada in
pantalla_ajustes_emisoras_personalizadas.dart so both screens share
one implementation. New ARB keys: favoriteGroupsManage,
customStationsAddCta.
Tests: pantalla_favoritos_plural_test.dart (the file tasks.md named)
never imported PantallaFavoritos - it only covers stationCount's ARB
plural formatting, unrelated to this screen. Left it untouched and
added test/pantallas/pantalla_favoritos_test.dart instead: 3
state-layer tests for the new EstadoRadio surface plus 6 widget
scenarios (empty-state CTA, chip filter, drag-reorder persistence,
sort action, group management + chip reactivity, custom-station
CTA). 604 -> 614 tests (2 skipped, unchanged). flutter analyze
unchanged at 1 pre-existing info.
Recorded in tasks.md with the test-file correction and the
design decisions this WU had to make on its own (no ADR covers
Favoritos' manual-order persistence).
This commit is contained in:
@@ -284,19 +284,61 @@ both kept it below forecast). Same "move-only diff" justification as WU3a.
|
||||
**Depends on**: WU1
|
||||
**Spec refs**: `favorites-organization` — Chip-Filtered Flat List, Drag-to-Reorder Within the Active Filter, Sort
|
||||
Action Using Existing Criteria, Group Management Reachable from Favoritos, Custom-Station CTA Preserved
|
||||
**Verify**: `flutter test test/pantallas/pantalla_favoritos_plural_test.dart && flutter analyze && dart format --set-exit-if-changed $(git diff --name-only --diff-filter=ACM HEAD -- '*.dart')`
|
||||
**Modified tests**: `test/pantallas/pantalla_favoritos_plural_test.dart` (+ new reorder scenario)
|
||||
**Verify**: `flutter test test/pantallas/pantalla_favoritos_test.dart test/pantallas/pantalla_favoritos_plural_test.dart test/pantallas/ajustes/pantalla_ajustes_emisoras_personalizadas_test.dart && flutter analyze && dart format --set-exit-if-changed $(git diff --cached --name-only --diff-filter=ACM HEAD -- '*.dart')`
|
||||
**New tests**: `test/pantallas/pantalla_favoritos_test.dart` (see 4.1's note — this WU's actual new test file, not
|
||||
`pantalla_favoritos_plural_test.dart`).
|
||||
**Modified tests**: `test/pantallas/ajustes/pantalla_ajustes_emisoras_personalizadas_test.dart` (comment only, no
|
||||
scenario change — see 4.4's note).
|
||||
|
||||
- [ ] 4.1 RED — update the test file: chip filter narrows the list ("Todas · N" + one chip per group); drag-to-reorder
|
||||
persists across a simulated restart; `swap_vert` applies `OrdenEmisoras`; create-group action reachable;
|
||||
custom-station CTA reachable.
|
||||
- [ ] 4.2 GREEN — replace `_GrupoFavoritosPanel` / `_FavoritoItem` with a horizontally-scrollable chip row + a single
|
||||
`ReorderableListView` filtered by the active chip.
|
||||
- [ ] 4.3 GREEN — wire persistence for the new order and the `swap_vert` action to `OrdenEmisoras`.
|
||||
- [ ] 4.4 GREEN — surface the create-group action; keep the dashed custom-station CTA.
|
||||
- [ ] 4.5 REFACTOR — extract the chip row / reorderable row into private widgets if the file grows unwieldy; confirm
|
||||
push-chrome is **not** applied here (Favoritos keeps its tab bar — the one exemption).
|
||||
- [ ] 4.6 Verify — reorder-persists scenario green after simulated restart; sort scenario green.
|
||||
- [x] 4.1 RED — **corrected at apply time**: `pantalla_favoritos_plural_test.dart` (the file this task originally
|
||||
named) never imports `PantallaFavoritos` — it only exercises `stationCount`'s ARB plural formatting via
|
||||
`AppLocalizations` directly, with no widget-level coverage of this screen at all. Left it untouched (still a
|
||||
valid, unrelated regression guard) and created **`test/pantallas/pantalla_favoritos_test.dart`** instead, with:
|
||||
3 state-layer tests for the new `EstadoRadio` surface (`listaFavoritosManual`, `reordenarFavorito`,
|
||||
`ordenarFavoritos` — see 4.3's note) plus 6 widget-level scenarios (empty-state CTA, chip filter narrows the
|
||||
list, drag-reorder persists across a simulated restart, `swap_vert` sort, create-group action + new-group-chip
|
||||
reactivity, custom-station CTA).
|
||||
- [x] 4.2 GREEN — replaced `_GrupoFavoritosPanel` with `_FilaChipsGrupos` (horizontally-scrollable
|
||||
`ChoiceChip` row, "{name} · {count}" label, new ARB keys `favoriteGroupsChipLabel`/`favoritesFilterAllLabel`)
|
||||
and a `ReorderableListView` (`header`/`footer` hold the screen header, chip row, sort action and the CTA;
|
||||
`buildDefaultDragHandles: false` + `ReorderableDragStartListener` per row, matching the spec's "via a drag
|
||||
handle" wording rather than whole-row long-press). Used the modern `onReorderItem` callback, not the
|
||||
now-`@Deprecated` `onReorder` (Flutter 3.44 marks it obsolete — using it would have added a new
|
||||
`deprecated_member_use` warning above the 1-issue baseline).
|
||||
- [x] 4.3 GREEN — **design decision, not specified by any ADR (WU4 has none)**: `EstadoRadio.listaFavoritos` already
|
||||
unconditionally re-sorts by the GLOBAL `ordenListas` setting on every read, which would silently discard any
|
||||
drag-to-reorder the instant anything reloads favorites. Added `listaFavoritosManual` (a new memoized getter
|
||||
returning the stored `orden`-column sequence, untouched by `ordenListas`) instead of changing `listaFavoritos`
|
||||
itself — `navegacion_auto.dart`'s Android Auto tree and the future Escuchar grid (WU5) both read
|
||||
`listaFavoritos` and are correctly unaffected by Favoritos' own manual order. Added `reordenarFavorito(uuid,
|
||||
nuevoIndice)` (thin wrapper over the ALREADY-EXISTING `ServicioFavoritos.reordenar` + `FakeServicioFavoritos`
|
||||
test double — both pre-dated this WU, unused until now) and `ordenarFavoritos(criterio)` (applies
|
||||
`OrdenEmisoras` via the existing `ordenarEmisoras()` function, then PERSISTS the result as the new manual order
|
||||
via the same `reordenar` primitive in a loop — chosen so the sort action's result also survives a restart,
|
||||
consistent with the drag-reorder persistence contract, even though the spec's own sort scenario only asserts
|
||||
the immediate re-render).
|
||||
- [x] 4.4 GREEN — create-group action: an `ActionChip` ("Manage lists", new ARB key `favoriteGroupsManage`) at the
|
||||
end of the chip row pushes the EXISTING `PantallaAjustesGruposFavoritos` (Settings' screen, reused rather than
|
||||
duplicated) — satisfies "Group Management Reachable... in addition to its existing entry point in Settings" as
|
||||
a second entry point to the SAME screen. Custom-station CTA: a new dashed-bordered card (`_DashedBorderPainter`,
|
||||
a small self-contained `CustomPainter` — no dashed-border package was available or added) opens the add-station
|
||||
form directly. That form (`_FormularioEmisora`) was **renamed to public `FormularioEmisoraPersonalizada`** in
|
||||
`pantalla_ajustes_emisoras_personalizadas.dart` so both screens share the one form instead of duplicating it;
|
||||
its one existing test file only referenced the old name in a comment, updated, no scenario changed. New ARB key
|
||||
`customStationsAddCta` ("Add custom station" / "Añadir emisora personalizada", matching the spec's quoted
|
||||
Spanish text exactly).
|
||||
- [x] 4.5 REFACTOR — extracted `_FilaChipsGrupos`, `_FilaFavorito` (the reorderable row, now carrying a leading drag
|
||||
handle plus the pre-existing assign/remove actions), `_CtaEmisoraPersonalizada`, `_DashedBorderPainter` as
|
||||
private widgets. Confirmed `PantallaFavoritos` still constructs zero `Scaffold` (`pluri_push_scaffold_test.dart`
|
||||
"The 5 root screens build zero Scaffold when mounted bare" still passes for it) — push-chrome is not applied
|
||||
here, Favoritos keeps its tab bar.
|
||||
- [x] 4.6 Verify — scoped suite green: 9/9 new + 2/2 `pantalla_favoritos_plural_test.dart` + 2/2
|
||||
`pantalla_ajustes_emisoras_personalizadas_test.dart`. Reorder-persists scenario green (verified via a simulated
|
||||
restart — `cargarFavoritos()` re-fetch from the fake service reflects the new order). Sort scenario green (both
|
||||
state persistence and the visual re-render order). Full suite: 614/614 green (2 skipped, unchanged), up from
|
||||
605. `flutter analyze`: 1 issue, identical to baseline (3 new warnings + 1 new info surfaced during REFACTOR —
|
||||
unused import, 3 unused optional painter parameters, missing `super.key` on the newly-public form widget — all
|
||||
fixed before this count).
|
||||
|
||||
## WU5 — Escuchar restructure
|
||||
|
||||
|
||||
Reference in New Issue
Block a user