feat(ui): floating pulse hint for booster targeting
Replaces the plain bottom SnackBar with a BoosterHint pill that floats in the empty space above the board: season-accent coloured, a breathing glow that pulses only while armed (idle otherwise — no wasted ticker), slides/ fades in, shows the booster icon + prompt, and cancels on tap. 3 widget tests; full suite 234 green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import 'package:block_seasons/game/models/booster.dart';
|
||||
import 'package:block_seasons/l10n/gen/app_localizations.dart';
|
||||
import 'package:block_seasons/ui/widgets/booster_hint.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
Widget wrap(Widget child) => MaterialApp(
|
||||
locale: const Locale('en'),
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
home: Scaffold(body: Center(child: child)),
|
||||
);
|
||||
|
||||
testWidgets('shows the cell hint for hammer and cancels on tap',
|
||||
(tester) async {
|
||||
var cancelled = false;
|
||||
await tester.pumpWidget(wrap(BoosterHint(
|
||||
arming: BoosterType.hammer,
|
||||
accent: const Color(0xFF5B7FFF),
|
||||
onCancel: () => cancelled = true,
|
||||
)));
|
||||
await tester.pump(const Duration(milliseconds: 250)); // settle entrance
|
||||
|
||||
expect(find.text('Tap a cell'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byType(BoosterHint));
|
||||
expect(cancelled, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('shows the line hint for the line bomb', (tester) async {
|
||||
await tester.pumpWidget(wrap(BoosterHint(
|
||||
arming: BoosterType.lineBomb,
|
||||
accent: const Color(0xFF5B7FFF),
|
||||
onCancel: () {},
|
||||
)));
|
||||
await tester.pump(const Duration(milliseconds: 250));
|
||||
|
||||
expect(find.text('Tap a row or column'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('ignores taps when nothing is armed', (tester) async {
|
||||
var cancelled = false;
|
||||
await tester.pumpWidget(wrap(BoosterHint(
|
||||
arming: null,
|
||||
accent: const Color(0xFF5B7FFF),
|
||||
onCancel: () => cancelled = true,
|
||||
)));
|
||||
await tester.pump(const Duration(milliseconds: 250));
|
||||
|
||||
await tester.tap(find.byType(BoosterHint), warnIfMissed: false);
|
||||
expect(cancelled, isFalse);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user