feat(paises): add country browser and extract shared radio transport

Extracts ServicioRadio's transport loop (server discovery, host rotation,
bounded retries, User-Agent, timeout, status check, json.decode, sticky-host
bookkeeping) out of `_get` into a new `_getJson(path, params) ->
Future<List<dynamic>>` helper, moved as one block with no logic edits. `_get`
is reimplemented on top, still owning every station-specific concern:
`lastcheckok: '1'`, `Emisora.fromApi` + the empty-uuid/url filter, and the
`_compararCalidad` quality sort. `_getJson` is deliberately sort-agnostic and
filter-agnostic so a non-station endpoint can reuse the resilience behaviour
without inheriting station-only semantics.

Non-negotiable ordering followed per design ADR-4: new
test/servicios/servicio_radio_transporte_test.dart characterises all 8
existing station calls (7 via `_get` plus `registrarClick`, which builds its
own URI) against the UNMODIFIED `_get` first - green by construction -
pinning path, lastcheckok=1, hidebroken=true, a non-empty User-Agent, exact
order/reverse/limit/offset, and the exact returned UUID sequence from a
fixture with deliberately shuffled bitrate/clickcount/votes. That last
assertion is what makes the extraction safe: a sort that silently sank into
transport would pass every other check. Re-running the same file after the
extraction is byte-identical green. test/servicios/servicio_radio_test.dart
is untouched by this work unit - its passing unmodified is itself a signal
that transport wasn't disturbed.

The 6 pre-existing `order: bitrate` occurrences (obtenerPopulares,
buscarPorNombre, buscarPorPais, buscarPorIdioma, buscarPorTag, buscar) are
untouched - a deliberate server-side quality bias deciding which stations
return within `limit`, unrelated to and never to be confused with the
user-facing "Ordenar" control, which stays entirely client-side via the
existing OrdenEmisoras (Engram reference/radio-browser-sort-order).

Behaviour delta, accepted per ADR-4, not a regression: moving
`_servidorActual` bookkeeping into `_getJson` means a successful
`/json/countries` call now warms the sticky host for subsequent station
calls too - one shared warm mirror per instance, desirable, not per-call-type
state.

Adds the Paises browser over the verified `/json/countries` contract (Engram
reference/radio-browser-countries-endpoint): new lib/modelos/pais_radio.dart
(`PaisRadio.fromApi` parses `stationcount` via `int.tryParse` since the API
returns it as a JSON string, not an int - an `as int` cast would throw),
`obtenerPaises()` sends neither `lastcheckok` nor `order` (the screen sorts
client-side by name; the API's raw byte order isn't proper collation for any
locale this app ships), and inherits `hidebroken=true` from the unchanged
`_uri` (desirable here too, since the endpoint's own default is false).
`EstadoBusqueda` gains `paises`/`cargandoPaises`/`cargarPaises()` with an
in-memory cache guard so re-entering the screen never refetches.

New PantallaPaises (lib/pantallas/pantalla_paises.dart): a "Tus idiomas"
shortlist (one representative country per the app's 13 supported locales,
matched against the fetched list - the proposal/spec name this section but
don't specify its derivation) above the full alphabetical list, each entry
showing its parsed station count. Reachable from Buscar's discovery landing
state via a new entry row, added now rather than left dangling per this
file's own forward-reference comment (and the WU15/WU15b lesson: a
fully-tested but unreachable screen is a real defect, not a follow-up).

New ARB keys (en/es only, matching this change's established precedent):
countriesScreenTitle, countriesYourLanguagesTitle, countriesAllTitle,
radioCountriesError.

Tests: 631 -> 649 (2 skipped, unchanged). flutter analyze unchanged at 1
pre-existing info. grep confirms `countrycodes` appears nowhere in lib/.
This commit is contained in:
2026-07-29 09:36:31 +02:00
parent 9bd828139f
commit c6f16c81b5
27 changed files with 1087 additions and 46 deletions
+4
View File
@@ -309,6 +309,10 @@
"searchNoResultsSubtitle": "Try removing filters or typing another name to find an active station.",
"searchResultsCount": "{count, plural, =1{1 result} other{{count} results}}",
"searchClearFiltersAction": "{count, plural, =1{Clear filter} other{Clear {count} filters}}",
"countriesScreenTitle": "Countries",
"countriesYourLanguagesTitle": "Your languages",
"countriesAllTitle": "All countries",
"radioCountriesError": "We couldn't load the countries.",
"countrySpain": "Spain",
"countryUsa": "USA",
"countryMexico": "Mexico",
+4
View File
@@ -309,6 +309,10 @@
"searchNoResultsSubtitle": "Probá quitar filtros o escribir otro nombre para encontrar una señal activa.",
"searchResultsCount": "{count, plural, =1{1 resultado} other{{count} resultados}}",
"searchClearFiltersAction": "{count, plural, =1{Quitar el filtro} other{Quitar los {count} filtros}}",
"countriesScreenTitle": "Países",
"countriesYourLanguagesTitle": "Tus idiomas",
"countriesAllTitle": "Todos los países",
"radioCountriesError": "No pudimos cargar los países.",
"countrySpain": "España",
"countryUsa": "EE. UU.",
"countryMexico": "México",
+24
View File
@@ -1150,6 +1150,30 @@ abstract class AppLocalizations {
/// **'{count, plural, =1{Quitar el filtro} other{Quitar los {count} filtros}}'**
String searchClearFiltersAction(num count);
/// No description provided for @countriesScreenTitle.
///
/// In es, this message translates to:
/// **'Países'**
String get countriesScreenTitle;
/// No description provided for @countriesYourLanguagesTitle.
///
/// In es, this message translates to:
/// **'Tus idiomas'**
String get countriesYourLanguagesTitle;
/// No description provided for @countriesAllTitle.
///
/// In es, this message translates to:
/// **'Todos los países'**
String get countriesAllTitle;
/// No description provided for @radioCountriesError.
///
/// In es, this message translates to:
/// **'No pudimos cargar los países.'**
String get radioCountriesError;
/// No description provided for @countrySpain.
///
/// In es, this message translates to:
+12
View File
@@ -611,6 +611,18 @@ class AppLocalizationsAr extends AppLocalizations {
return '$_temp0';
}
@override
String get countriesScreenTitle => 'Países';
@override
String get countriesYourLanguagesTitle => 'Tus idiomas';
@override
String get countriesAllTitle => 'Todos los países';
@override
String get radioCountriesError => 'No pudimos cargar los países.';
@override
String get countrySpain => 'إسبانيا';
+12
View File
@@ -615,6 +615,18 @@ class AppLocalizationsBn extends AppLocalizations {
return '$_temp0';
}
@override
String get countriesScreenTitle => 'Países';
@override
String get countriesYourLanguagesTitle => 'Tus idiomas';
@override
String get countriesAllTitle => 'Todos los países';
@override
String get radioCountriesError => 'No pudimos cargar los países.';
@override
String get countrySpain => 'স্পেন';
+12
View File
@@ -618,6 +618,18 @@ class AppLocalizationsDe extends AppLocalizations {
return '$_temp0';
}
@override
String get countriesScreenTitle => 'Países';
@override
String get countriesYourLanguagesTitle => 'Tus idiomas';
@override
String get countriesAllTitle => 'Todos los países';
@override
String get radioCountriesError => 'No pudimos cargar los países.';
@override
String get countrySpain => 'Spanien';
+12
View File
@@ -612,6 +612,18 @@ class AppLocalizationsEn extends AppLocalizations {
return '$_temp0';
}
@override
String get countriesScreenTitle => 'Countries';
@override
String get countriesYourLanguagesTitle => 'Your languages';
@override
String get countriesAllTitle => 'All countries';
@override
String get radioCountriesError => 'We couldn\'t load the countries.';
@override
String get countrySpain => 'Spain';
+12
View File
@@ -616,6 +616,18 @@ class AppLocalizationsEs extends AppLocalizations {
return '$_temp0';
}
@override
String get countriesScreenTitle => 'Países';
@override
String get countriesYourLanguagesTitle => 'Tus idiomas';
@override
String get countriesAllTitle => 'Todos los países';
@override
String get radioCountriesError => 'No pudimos cargar los países.';
@override
String get countrySpain => 'España';
+12
View File
@@ -620,6 +620,18 @@ class AppLocalizationsFr extends AppLocalizations {
return '$_temp0';
}
@override
String get countriesScreenTitle => 'Países';
@override
String get countriesYourLanguagesTitle => 'Tus idiomas';
@override
String get countriesAllTitle => 'Todos los países';
@override
String get radioCountriesError => 'No pudimos cargar los países.';
@override
String get countrySpain => 'Espagne';
+12
View File
@@ -613,6 +613,18 @@ class AppLocalizationsHi extends AppLocalizations {
return '$_temp0';
}
@override
String get countriesScreenTitle => 'Países';
@override
String get countriesYourLanguagesTitle => 'Tus idiomas';
@override
String get countriesAllTitle => 'Todos los países';
@override
String get radioCountriesError => 'No pudimos cargar los países.';
@override
String get countrySpain => 'स्पेन';
+12
View File
@@ -614,6 +614,18 @@ class AppLocalizationsId extends AppLocalizations {
return '$_temp0';
}
@override
String get countriesScreenTitle => 'Países';
@override
String get countriesYourLanguagesTitle => 'Tus idiomas';
@override
String get countriesAllTitle => 'Todos los países';
@override
String get radioCountriesError => 'No pudimos cargar los países.';
@override
String get countrySpain => 'Spanyol';
+12
View File
@@ -616,6 +616,18 @@ class AppLocalizationsIt extends AppLocalizations {
return '$_temp0';
}
@override
String get countriesScreenTitle => 'Países';
@override
String get countriesYourLanguagesTitle => 'Tus idiomas';
@override
String get countriesAllTitle => 'Todos los países';
@override
String get radioCountriesError => 'No pudimos cargar los países.';
@override
String get countrySpain => 'Spagna';
+12
View File
@@ -593,6 +593,18 @@ class AppLocalizationsJa extends AppLocalizations {
return '$_temp0';
}
@override
String get countriesScreenTitle => 'Países';
@override
String get countriesYourLanguagesTitle => 'Tus idiomas';
@override
String get countriesAllTitle => 'Todos los países';
@override
String get radioCountriesError => 'No pudimos cargar los países.';
@override
String get countrySpain => 'スペイン';
+12
View File
@@ -615,6 +615,18 @@ class AppLocalizationsPt extends AppLocalizations {
return '$_temp0';
}
@override
String get countriesScreenTitle => 'Países';
@override
String get countriesYourLanguagesTitle => 'Tus idiomas';
@override
String get countriesAllTitle => 'Todos los países';
@override
String get radioCountriesError => 'No pudimos cargar los países.';
@override
String get countrySpain => 'Espanha';
+12
View File
@@ -616,6 +616,18 @@ class AppLocalizationsRu extends AppLocalizations {
return '$_temp0';
}
@override
String get countriesScreenTitle => 'Países';
@override
String get countriesYourLanguagesTitle => 'Tus idiomas';
@override
String get countriesAllTitle => 'Todos los países';
@override
String get radioCountriesError => 'No pudimos cargar los países.';
@override
String get countrySpain => 'Испания';
+12
View File
@@ -591,6 +591,18 @@ class AppLocalizationsZh extends AppLocalizations {
return '$_temp0';
}
@override
String get countriesScreenTitle => 'Países';
@override
String get countriesYourLanguagesTitle => 'Tus idiomas';
@override
String get countriesAllTitle => 'Todos los países';
@override
String get radioCountriesError => 'No pudimos cargar los países.';
@override
String get countrySpain => '西班牙';