feat(ui): design token discipline, accessibility and i18n pass

- Replace all hardcoded Color literals outside lib/tema with theme tokens (new static brand palette in PluriWaveTokens); media notification uses the brand color instead of the Material default purple
- Favorite button on station cards grows to a 48dp target and becomes an independent semantics node for screen readers (Semantics container fix)
- All flutter_animate call sites route through the PluriAnimate reduced-motion gate (zero direct .animate() left)
- Locale-aware short dates via intl DateFormat (new lib/l10n/formato_fechas.dart) replacing the hardcoded DD/MM/YYYY; proper plural messages for the favorites counter; example stream URL as a localized key - all 13 locales
- Rounded shimmer placeholders matching card radii; shimmer loading state in search instead of a bare spinner; rounded icon variants unified in settings; bottom-sheet conventions on the custom station form
- Fix latent debug crash: vacation editor read AppLocalizations in initState
- 11 new tests (121 total green), flutter analyze clean
This commit is contained in:
2026-06-11 23:42:16 +02:00
parent 52855e75c2
commit 202bef3539
49 changed files with 1108 additions and 175 deletions
@@ -0,0 +1,27 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:intl/date_symbol_data_local.dart';
import 'package:intl/intl.dart';
import 'package:pluriwave/l10n/formato_fechas.dart';
/// S5-R4: short dates must follow the active locale, not a hardcoded
/// DD/MM/YYYY pattern.
void main() {
test('en-US usa el orden mes/día, no el formato fijo DD/MM/YYYY', () {
final fecha = DateTime(2026, 6, 11);
final resultado = fechaCortaLocalizada('en-US', fecha);
expect(resultado, DateFormat.yMd('en-US').format(fecha));
expect(resultado, isNot('11/06/2026'));
expect(resultado, '6/11/2026');
});
test('es usa el orden día/mes', () async {
await initializeDateFormatting('es');
final fecha = DateTime(2026, 6, 11);
expect(
fechaCortaLocalizada('es', fecha),
DateFormat.yMd('es').format(fecha),
);
});
}
@@ -0,0 +1,41 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pluriwave/estado/estado_busqueda.dart';
import 'package:pluriwave/l10n/gen/app_localizations.dart';
import 'package:pluriwave/pantallas/pantalla_buscar.dart';
import 'package:pluriwave/widgets/tarjeta_emisora.dart';
import 'package:provider/provider.dart';
import '../helpers/fakes.dart';
/// S5-R6: the search loading state uses shimmer placeholders, not a bare
/// spinner, to stay consistent with the rest of the app.
class _BusquedaCargando extends EstadoBusqueda {
_BusquedaCargando() : super(radio: FakeServicioRadio());
@override
bool get cargando => true;
}
void main() {
testWidgets('PantallaBuscar muestra shimmer mientras carga', (tester) async {
final busqueda = _BusquedaCargando();
addTearDown(busqueda.dispose);
await tester.pumpWidget(
ListenableProvider<EstadoBusqueda>.value(
value: busqueda,
child: MaterialApp(
locale: const Locale('es'),
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: const Scaffold(body: PantallaBuscar()),
),
),
);
await tester.pump();
expect(find.byType(TarjetaEmisoraShimmer), findsWidgets);
expect(find.byType(CircularProgressIndicator), findsNothing);
});
}
@@ -0,0 +1,20 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pluriwave/l10n/gen/app_localizations.dart';
/// S5-R5: bare counters must use proper ARB plural messages.
void main() {
test('stationCount cambia entre singular y plural (en)', () async {
final l10n = await AppLocalizations.delegate.load(const Locale('en'));
expect(l10n.stationCount(1), '1 station');
expect(l10n.stationCount(5), '5 stations');
});
test('stationCount cambia entre singular y plural (es)', () async {
final l10n = await AppLocalizations.delegate.load(const Locale('es'));
expect(l10n.stationCount(1), isNot(l10n.stationCount(5)));
expect(l10n.stationCount(5), contains('5'));
});
}
+16
View File
@@ -0,0 +1,16 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pluriwave/main.dart';
import 'package:pluriwave/tema/pluriwave_tokens.dart';
/// S5-R8: the audio notification accent is the PluriWave brand color,
/// not the M3 default purple.
void main() {
test('AudioServiceConfig usa el color de marca', () {
expect(configuracionAudioService.notificationColor, PluriWaveTokens.brand);
expect(
configuracionAudioService.notificationColor,
isNot(const Color(0xFF6750A4)),
);
});
}
+78
View File
@@ -0,0 +1,78 @@
import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pluriwave/tema/pluri_animate.dart';
/// S5-R3: the central reduced-motion gate. When the OS reports
/// disableAnimations, the helpers must return the child UNANIMATED
/// (no [Animate] wrapper at all).
void main() {
Widget host({required bool reducedMotion, required WidgetBuilder builder}) {
return MediaQuery(
data: MediaQueryData(disableAnimations: reducedMotion),
child: Directionality(
textDirection: TextDirection.ltr,
child: Builder(builder: builder),
),
);
}
testWidgets('pluriFadeIn anima en modo normal', (tester) async {
await tester.pumpWidget(
host(
reducedMotion: false,
builder: (context) => const Text('hola').pluriFadeIn(context),
),
);
expect(find.byType(Animate), findsOneWidget);
await tester.pumpAndSettle();
});
testWidgets('pluriFadeIn devuelve el hijo intacto con reduced motion', (
tester,
) async {
await tester.pumpWidget(
host(
reducedMotion: true,
builder: (context) => const Text('hola').pluriFadeIn(context),
),
);
expect(find.byType(Animate), findsNothing);
expect(find.text('hola'), findsOneWidget);
});
testWidgets('pluriFadeSlideIn respeta el gate de reduced motion', (
tester,
) async {
await tester.pumpWidget(
host(
reducedMotion: true,
builder:
(context) =>
const Text('hola').pluriFadeSlideIn(context, beginY: 0.2),
),
);
expect(find.byType(Animate), findsNothing);
await tester.pumpWidget(
host(
reducedMotion: false,
builder:
(context) =>
const Text('hola').pluriFadeSlideIn(context, beginY: 0.2),
),
);
expect(find.byType(Animate), findsOneWidget);
await tester.pumpAndSettle();
});
testWidgets('pluriScaleIn respeta el gate de reduced motion', (tester) async {
await tester.pumpWidget(
host(
reducedMotion: true,
builder: (context) => const Text('hola').pluriScaleIn(context),
),
);
expect(find.byType(Animate), findsNothing);
});
}
@@ -0,0 +1,75 @@
import 'dart:ui' show Tristate;
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pluriwave/estado/estado_radio.dart';
import 'package:pluriwave/l10n/gen/app_localizations.dart';
import 'package:pluriwave/widgets/tarjeta_emisora.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../helpers/fakes.dart';
/// S5-R2: the mini favorite button in the full card must be accessible
/// (semantic button with label + toggled state) and reach a 48dp target.
void main() {
setUp(() {
SharedPreferences.setMockInitialValues({});
});
testWidgets('el favorito mini es accesible y mide al menos 48x48 dp', (
tester,
) async {
final semantics = tester.ensureSemantics();
final estado = EstadoRadio(
audio: FakeServicioAudio(),
favoritos: FakeServicioFavoritos(),
radio: FakeServicioRadio(),
servicioEcualizador: FakeServicioEcualizador(),
iniciarAutomaticamente: false,
);
addTearDown(estado.dispose);
await tester.pumpWidget(
ChangeNotifierProvider<EstadoRadio>.value(
value: estado,
child: MaterialApp(
locale: const Locale('es'),
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: Scaffold(
body: Center(
child: SizedBox(
width: 220,
height: 300,
// Full (non-compact) card: it renders the MINI favorite.
child: TarjetaEmisora(
emisora: emisoraDemo(uuid: 'a11y-1', nombre: 'A11y FM'),
),
),
),
),
),
),
);
await tester.pump();
final l10n = await AppLocalizations.delegate.load(const Locale('es'));
// Semantic node: button + label (favorite is OFF, so the "add" label).
final boton = find.bySemanticsLabel(l10n.favoritesAddTooltip);
expect(boton, findsOneWidget);
final nodo = tester.getSemantics(boton);
final flags = nodo.flagsCollection;
expect(flags.isButton, isTrue);
// Toggled state present (favorite OFF) — tristate: not null, not true.
expect(flags.isToggled, Tristate.isFalse);
// Touch target: at least 48x48 dp (S5-R2-A).
final size = tester.getSize(boton);
expect(size.width, greaterThanOrEqualTo(48));
expect(size.height, greaterThanOrEqualTo(48));
semantics.dispose();
});
}