feat(ui): rewarded-ad grant for an empty booster

Tapping an empty booster opens the get-one dialog; confirming watches a
rewarded ad and, on earn, grants +1 of that booster and logs booster_granted
(source: ad). Covered by a widget test using an uninitialized AdService whose
showRewarded() resolves true.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-18 12:41:27 +09:00
parent 1ba30028b5
commit b8bfa00196
2 changed files with 44 additions and 6 deletions
+10 -3
View File
@@ -206,11 +206,10 @@ class _GameScreenState extends ConsumerState<GameScreen>
);
}
/// An empty booster offers to get one. The rewarded-ad grant is wired in
/// Task 15.
/// Task 15: an empty booster offers a rewarded ad; on reward, grant +1.
Future<void> _offerBoosterAd(BoosterType type) async {
final l10n = AppLocalizations.of(context)!;
await showDialog<bool>(
final confirmed = await showDialog<bool>(
context: context,
builder: (context) => AlertDialog(
content: Text(l10n.boosterGetWithAd),
@@ -226,6 +225,14 @@ class _GameScreenState extends ConsumerState<GameScreen>
],
),
);
if (confirmed != true) return;
final earned = await ref.read(adServiceProvider).showRewarded();
if (earned) {
await ref.read(boosterInventoryProvider.notifier).grant(type, 1);
ref
.read(analyticsProvider)
.boosterGranted(type: type.name, count: 1, source: 'ad');
}
}
@override