Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/l10n/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"alarmChangeTheTime": "Uhrzeit ändern",
"alarmTestTheBuzz": "Vibration testen",
"alarmCancelTheAlarm": "Wecker löschen",
"alarmBuzzingTheBand": "Band vibriert…",
"alarmBuzzingTheBand": "Vibration ans Band gesendet",
"alarmCancelled": "Wecker gelöscht",
"alarmSentToBand": "Wecker ans Band gesendet",
"alarmInThePast": "Dieser Zeitpunkt liegt in der Vergangenheit – der Wecker hat bereits geklingelt oder wurde verpasst",
Expand Down
4 changes: 2 additions & 2 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,9 @@
"@alarmCancelTheAlarm": {
"description": "Button: cancel the alarm."
},
"alarmBuzzingTheBand": "Buzzing the band",
"alarmBuzzingTheBand": "Buzz sent to the band",
"@alarmBuzzingTheBand": {
"description": "Snackbar: testing the buzz."
"description": "Snackbar: the test buzz command reached the band. The app gets no signal when the buzz ends, so this must not claim the band is still buzzing."
},
"alarmCancelled": "Alarm cancelled",
"@alarmCancelled": {
Expand Down
2 changes: 1 addition & 1 deletion lib/l10n/app_es.arb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"alarmChangeTheTime": "Cambiar la hora",
"alarmTestTheBuzz": "Probar la vibración",
"alarmCancelTheAlarm": "Cancelar la alarma",
"alarmBuzzingTheBand": "Vibrando la banda",
"alarmBuzzingTheBand": "Vibración enviada a la banda",
"alarmCancelled": "Alarma cancelada",
"alarmSentToBand": "Alarma enviada a la banda",
"alarmInThePast": "En el pasado: ya sonó o se pasó",
Expand Down
2 changes: 1 addition & 1 deletion lib/l10n/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"alarmChangeTheTime": "Changer l’heure",
"alarmTestTheBuzz": "Tester la vibration",
"alarmCancelTheAlarm": "Annuler l’alarme",
"alarmBuzzingTheBand": "Vibration du bracelet",
"alarmBuzzingTheBand": "Vibration envoyée au bracelet",
"alarmCancelled": "Alarme annulée",
"alarmSentToBand": "Alarme envoyée au bracelet",
"alarmInThePast": "Dans le passé — elle s’est déjà déclenchée ou a été manquée",
Expand Down
2 changes: 1 addition & 1 deletion lib/l10n/app_ru.arb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"alarmChangeTheTime": "Изменить время",
"alarmTestTheBuzz": "Проверить вибрацию",
"alarmCancelTheAlarm": "Отменить будильник",
"alarmBuzzingTheBand": "Браслет вибрирует",
"alarmBuzzingTheBand": "Вибрация отправлена на браслет",
"alarmCancelled": "Будильник отменён",
"alarmSentToBand": "Будильник отправлен на браслет",
"alarmInThePast": "Время прошло — будильник уже сработал или был пропущен",
Expand Down
14 changes: 11 additions & 3 deletions lib/ui2/profile/alarm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ class AlarmScreenView extends StatelessWidget {
color: C.blue,
soft: true,
onTap: () => _run(
c, onTest, l?.alarmBuzzingTheBand ?? 'Buzzing the band')),
c, onTest, l?.alarmBuzzingTheBand ?? 'Buzz sent to the band')),
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Resolved
const SizedBox(height: S.x3),
],
if (at != null || anyDayEnabled)
Expand Down Expand Up @@ -444,8 +444,16 @@ class AlarmScreenView extends StatelessWidget {
}
}

static void _say(BuildContext c, String msg) =>
ScaffoldMessenger.of(c).showSnackBar(SnackBar(content: Text(msg)));
/// Replaces what this screen said before, shown or still queued, instead of
/// stacking behind it: repeat taps would otherwise queue one 4-second
/// snackbar each and keep an old result on screen long after it stopped
/// being true. Only while this screen is on top — a result that lands after
/// the user moved on must not wipe another screen's message.
static void _say(BuildContext c, String msg) {
final messenger = ScaffoldMessenger.of(c);
if (ModalRoute.of(c)?.isCurrent ?? true) messenger.clearSnackBars();
messenger.showSnackBar(SnackBar(content: Text(msg)));
}

static String _hhmm(DateTime d) => _hhmmOf(d.hour, d.minute);

Expand Down
67 changes: 67 additions & 0 deletions test/ui2_alarm_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,71 @@ void main() {
expect(find.text('Fired or missed'), findsOneWidget);
});
});
group('the test buzz', () {
setUp(() => ClockFormatController.seed(ClockFormat.h24));
tearDown(ClockFormatController.debugReset);

// The app gets no signal when the strap stops buzzing, so the confirmation
// may only say the command was sent, and repeat taps must not queue one
// 4-second snackbar each and keep "buzzing" on screen long after the band
// has stopped.
testWidgets('says the buzz was sent, once, however often it is tapped',
(t) async {
final now = DateTime(2026, 8, 22, 9);
await t.pumpWidget(MaterialApp(
home: AlarmScreenView(
armedAt: DateTime(2026, 8, 23, 6, 30),
state: AlarmArmState.confirmed,
connected: true,
now: now,
onTest: () async {})));
final button = find.text('Test the buzz');
await t.ensureVisible(button);
for (var i = 0; i < 3; i++) {
await t.tap(button);
await t.pump();
}
await t.pump(const Duration(milliseconds: 750));
expect(find.text('Buzz sent to the band'), findsOneWidget);
expect(find.textContaining('Buzzing'), findsNothing);
// One snackbar's lifetime later nothing is left waiting in the queue.
await t.pump(const Duration(seconds: 5));
await t.pump(const Duration(seconds: 1));
expect(find.text('Buzz sent to the band'), findsNothing);
});

testWidgets('a result that lands while the last one is leaving replaces it',
(t) async {
// Tap, let the message show, tap again (its exit starts), and tap a
// third time mid-exit: only the latest may follow, not a queue of two.
await t.pumpWidget(MaterialApp(
home: AlarmScreenView(
armedAt: DateTime(2026, 8, 23, 6, 30),
state: AlarmArmState.confirmed,
connected: true,
now: DateTime(2026, 8, 22, 9),
onTest: () async {})));
final button = find.text('Test the buzz');
await t.ensureVisible(button);
Future<void> step(int ms) async {
for (var i = 0; i < ms ~/ 50; i++) {
await t.pump(const Duration(milliseconds: 50));
}
}

await t.tap(button);
await step(1000);
await t.tap(button);
await step(50);
await t.tap(button);
await step(1000);
// The latest message is up, alone.
expect(find.byType(SnackBar), findsOneWidget);
expect(find.text('Buzz sent to the band'), findsOneWidget);
// One message's enter, 4 s on screen and exit, with a second of slack;
// a second queued message would still be showing here.
await step(6000);
expect(find.text('Buzz sent to the band'), findsNothing);
});
});
}