fix(alarm): localize pre-notice countdown and fix snooze dismiss
Build & Deploy PluriWave / Análisis de código (push) Successful in 39s
Build & Deploy PluriWave / Build APK + AAB release (push) Successful in 2m33s

Replace hardcoded Spanish pre-notice text with computed remaining
minutes using l10n template passed via MethodChannel. Fix snooze
dismiss in dead-app state with canPop guard and SystemNavigator.pop
fallback.
This commit is contained in:
2026-06-28 11:55:15 +02:00
parent 58922de6fc
commit 4ffd73d136
8 changed files with 510 additions and 13 deletions
@@ -170,6 +170,19 @@ class ServicioAlarmasAndroid implements PuertoAlarmasAndroid {
_l10n = l10n;
}
/// Builds a pre-notice template string with a literal `{minutes}` placeholder
/// for Kotlin to replace at broadcast-receiver fire time.
///
/// Strategy: call [preNoticeCountdown] with a unique sentinel integer and
/// replace the sentinel's string representation with `{minutes}`.
static String _preNoticeTemplate(AppLocalizations l10n) {
const sentinel = 42424242;
return l10n.preNoticeCountdown(sentinel).replaceFirst(
sentinel.toString(),
'{minutes}',
);
}
@override
Stream<EventoAlarmaAndroid> get eventosAlarma => _eventosController.stream;
@@ -189,6 +202,7 @@ class ServicioAlarmasAndroid implements PuertoAlarmasAndroid {
final programada = await _channel.invokeMethod<bool>('scheduleAlarm', {
'id': alarma.id,
'title': localizedAlarmName(_textos, alarma.nombre),
'preNoticeTemplate': _preNoticeTemplate(_textos),
'triggerAtMillis': proxima.millisecondsSinceEpoch,
'preNoticeAtMillis':
alarma.snoozeHasta == null