fix(alarm): localize pre-notice countdown and fix snooze dismiss
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user