fix(ajustes): show each settings row's current value

The prototype puts a trailing current-value string on nearly every
settings row (t4 lines 512-539, 625 -- "3 guardados", "Alfabetico",
"Espanol", "7 . 84 MB"). FilaAjuste only accepted icon/titulo/onTap,
so every row was value-blind.

Add an optional `valor` slot to FilaAjuste (13px, rgba(242,247,250,.55),
rendered before the chevron). Wire 8 of the 12 built rows to state
already available at the settings root: equalizer on/off, sleep-timer
active, favourite-group count, preferred station name, custom-station
count, sort order, recordings count-and-size (FutureBuilder over
EstadoGrabacion.listarGrabaciones), and the current language (hoisted
pantalla_ajustes_idioma.dart's native-name list to module level so the
root can read it without duplicating it). Salida de audio, Musica
local, Backup and Info's version are left without a value -- each
lacks a low-risk, deterministically-testable data source (see the
apply-progress note for the reason per row).

Reading EstadoRadio for these values through a root `context.watch`
would rebuild the whole settings list -- including the Grabaciones
FutureBuilder's disk read -- on every unrelated audio notification;
this follows the codebase's existing S4-R5 convention of narrow
`context.select` per field instead.

Ajustes' own PluriRootHeader/PluriScreenHeader edit (S2 in this same
pass) landed in this commit too, since both touched the same header
block in pantalla_ajustes.dart at the same time.

S8, Tier 1 visual-fidelity pass (audit id 2521).
This commit is contained in:
2026-07-29 21:26:48 +02:00
parent f5a211492a
commit e0164f68b5
5 changed files with 421 additions and 64 deletions
@@ -28,32 +28,60 @@ class PantallaAjustesIdioma extends StatelessWidget {
}
}
/// S8 (Tier 1 visual fidelity): the "system" pseudo-code, the native-name
/// list and the locale<->code mapping used to be private to this file's
/// `_CuerpoIdioma`. Hoisted to module level (unchanged values/logic) so
/// `pantalla_ajustes.dart`'s Idioma row can show the CURRENT language's
/// native name as its trailing value (t4's own example, line 526:
/// "Español") without duplicating this list.
const codigoIdiomaSistema = 'system';
const idiomasDisponibles = [
IdiomaDisponible(Locale('en'), 'English'),
IdiomaDisponible(Locale('es'), 'Español'),
IdiomaDisponible(Locale('zh'), '中文'),
IdiomaDisponible(Locale('hi'), 'हिन्दी'),
IdiomaDisponible(Locale('ar'), 'العربية'),
IdiomaDisponible(Locale('pt'), 'Português'),
IdiomaDisponible(Locale('fr'), 'Français'),
IdiomaDisponible(Locale('ru'), 'Русский'),
IdiomaDisponible(Locale('de'), 'Deutsch'),
IdiomaDisponible(Locale('ja'), '日本語'),
IdiomaDisponible(Locale('id'), 'Bahasa Indonesia'),
IdiomaDisponible(Locale('bn'), 'বাংলা'),
IdiomaDisponible(Locale('it'), 'Italiano'),
];
String codigoLocaleIdioma(Locale locale) {
final countryCode = locale.countryCode;
if (countryCode == null || countryCode.isEmpty) {
return locale.languageCode;
}
return '${locale.languageCode}_$countryCode';
}
/// The current language's own native name (e.g. "Español"), or the
/// localized "system default" label when [locale] is null.
String nombreIdiomaActual(Locale? locale, AppLocalizations l10n) {
if (locale == null) return l10n.languageSystemDefault;
final codigo = codigoLocaleIdioma(locale);
final idioma = idiomasDisponibles.firstWhere(
(item) => codigoLocaleIdioma(item.locale) == codigo,
orElse: () => idiomasDisponibles.first,
);
return idioma.nombreNativo;
}
class _CuerpoIdioma extends StatelessWidget {
const _CuerpoIdioma();
static const _codigoSistema = 'system';
static const _idiomas = [
_IdiomaDisponible(Locale('en'), 'English'),
_IdiomaDisponible(Locale('es'), 'Español'),
_IdiomaDisponible(Locale('zh'), '中文'),
_IdiomaDisponible(Locale('hi'), 'हिन्दी'),
_IdiomaDisponible(Locale('ar'), 'العربية'),
_IdiomaDisponible(Locale('pt'), 'Português'),
_IdiomaDisponible(Locale('fr'), 'Français'),
_IdiomaDisponible(Locale('ru'), 'Русский'),
_IdiomaDisponible(Locale('de'), 'Deutsch'),
_IdiomaDisponible(Locale('ja'), '日本語'),
_IdiomaDisponible(Locale('id'), 'Bahasa Indonesia'),
_IdiomaDisponible(Locale('bn'), 'বাংলা'),
_IdiomaDisponible(Locale('it'), 'Italiano'),
];
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context);
final estadoIdioma = context.watch<EstadoIdioma>();
final locale = estadoIdioma.localeSeleccionado;
final valorActual = locale == null ? _codigoSistema : _codigoLocale(locale);
final valorActual =
locale == null ? codigoIdiomaSistema : codigoLocaleIdioma(locale);
return PluriGlassSurface(
child: Column(
@@ -73,18 +101,18 @@ class _CuerpoIdioma extends StatelessWidget {
),
items: [
DropdownMenuItem(
value: _codigoSistema,
value: codigoIdiomaSistema,
child: Text(l10n.languageSystemDefault),
),
for (final idioma in _idiomas)
for (final idioma in idiomasDisponibles)
DropdownMenuItem(
value: _codigoLocale(idioma.locale),
value: codigoLocaleIdioma(idioma.locale),
child: Text(idioma.nombreNativo),
),
],
onChanged: (codigo) async {
if (codigo == null) return;
if (codigo == _codigoSistema) {
if (codigo == codigoIdiomaSistema) {
await context.read<EstadoIdioma>().seleccionarSistema();
if (!context.mounted) return;
ScaffoldMessenger.of(context).showSnackBar(
@@ -93,9 +121,9 @@ class _CuerpoIdioma extends StatelessWidget {
return;
}
final idioma = _idiomas.firstWhere(
(item) => _codigoLocale(item.locale) == codigo,
orElse: () => _idiomas.first,
final idioma = idiomasDisponibles.firstWhere(
(item) => codigoLocaleIdioma(item.locale) == codigo,
orElse: () => idiomasDisponibles.first,
);
await context.read<EstadoIdioma>().seleccionarLocale(
idioma.locale,
@@ -113,18 +141,10 @@ class _CuerpoIdioma extends StatelessWidget {
),
);
}
static String _codigoLocale(Locale locale) {
final countryCode = locale.countryCode;
if (countryCode == null || countryCode.isEmpty) {
return locale.languageCode;
}
return '${locale.languageCode}_$countryCode';
}
}
class _IdiomaDisponible {
const _IdiomaDisponible(this.locale, this.nombreNativo);
class IdiomaDisponible {
const IdiomaDisponible(this.locale, this.nombreNativo);
final Locale locale;
final String nombreNativo;
+35 -5
View File
@@ -17,7 +17,12 @@ class GrupoAjustes extends StatelessWidget {
/// already in its display form — this style never applies `toUpperCase()`.
final String titulo;
final List<FilaAjuste> filas;
/// S8 (Tier 1 visual fidelity): `Widget`, not `List<FilaAjuste>` — a few
/// rows source their current-value text asynchronously (e.g. recordings
/// count, app version) and wrap their own `FilaAjuste` in a
/// `FutureBuilder`. `GrupoAjustes` only iterates and inserts dividers; it
/// never reaches into `FilaAjuste`-specific state.
final List<Widget> filas;
@override
Widget build(BuildContext context) {
@@ -38,29 +43,54 @@ class GrupoAjustes extends StatelessWidget {
}
}
/// A single Settings navigation row: icon, title, and a trailing chevron.
/// Tapping it is the row's only behaviour — it carries no switches, sliders
/// or text fields, which is what "zero inline controls" means at the root.
/// A single Settings navigation row: icon, title, an optional trailing
/// current-value string, and a trailing chevron. Tapping it is the row's
/// only behaviour — it carries no switches, sliders or text fields, which
/// is what "zero inline controls" means at the root.
class FilaAjuste extends StatelessWidget {
const FilaAjuste({
super.key,
required this.icon,
required this.titulo,
required this.onTap,
this.valor,
});
final IconData icon;
final String titulo;
final VoidCallback onTap;
/// S8 (Tier 1 visual fidelity): the prototype puts a trailing current
/// value on nearly every row (t4 lines 512-539, 625 — e.g. "3 guardados",
/// "Alfabético", "Español"), 13px `rgba(242,247,250,.55)`. Null means
/// "no current value to show" — the row renders exactly as before.
final String? valor;
@override
Widget build(BuildContext context) {
final type = context.pluriType;
final valorActual = valor;
return ListTile(
contentPadding: EdgeInsets.zero,
leading: Icon(icon),
title: Text(titulo, style: type.cardTitle),
trailing: const Icon(Icons.chevron_right_rounded),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (valorActual != null) ...[
Text(
valorActual,
// bodyStrong is already 13/w600, matching the prototype's row
// value spec exactly — only the colour needs overriding.
style: type.bodyStrong.copyWith(
color: const Color(0xFFF2F7FA).withValues(alpha: 0.55),
),
),
const SizedBox(width: 6),
],
const Icon(Icons.chevron_right_rounded),
],
),
onTap: onTap,
);
}