@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
55import 'package:flutter/services.dart' ;
66import 'package:flutter_svg/flutter_svg.dart' ;
77import 'package:geolocator/geolocator.dart' ;
8+ import 'package:postbox_game/streak_service.dart' ;
89import 'package:postbox_game/theme.dart' ;
910
1011enum ClaimStage { initial, searching, results, empty, claimed }
@@ -80,6 +81,7 @@ class ClaimState extends State<Claim> with SingleTickerProviderStateMixin {
8081 FirebaseFunctions .instance.httpsCallable ('nearbyPostboxes' );
8182 final HttpsCallable _claimCallable =
8283 FirebaseFunctions .instance.httpsCallable ('startScoring' );
84+ final StreakService _streakService = StreakService ();
8385
8486 Future <Position > _getPosition () async {
8587 bool serviceEnabled = await Geolocator .isLocationServiceEnabled ();
@@ -148,6 +150,7 @@ class ClaimState extends State<Claim> with SingleTickerProviderStateMixin {
148150 currentStage = ClaimStage .claimed;
149151 });
150152 _successController.forward (from: 0 );
153+ await _streakService.updateStreakAfterClaim ();
151154 } on FirebaseFunctionsException catch (e) {
152155 debugPrint ('Claim error: ${e .code } ${e .message }' );
153156 _showErrorSnackBar (e.message ?? 'Could not claim postbox.' );
@@ -196,6 +199,39 @@ class ClaimState extends State<Claim> with SingleTickerProviderStateMixin {
196199 child: Column (
197200 mainAxisAlignment: MainAxisAlignment .center,
198201 children: [
202+ StreamBuilder <int ?>(
203+ stream: _streakService.streakStream (),
204+ builder: (context, snapshot) {
205+ final streak = snapshot.data;
206+ if (streak == null || streak == 0 ) return const SizedBox .shrink ();
207+ return Padding (
208+ padding: const EdgeInsets .only (bottom: AppSpacing .md),
209+ child: Container (
210+ padding: const EdgeInsets .symmetric (
211+ horizontal: AppSpacing .md, vertical: AppSpacing .sm),
212+ decoration: BoxDecoration (
213+ color: postalRed.withValues (alpha: 0.08 ),
214+ borderRadius: BorderRadius .circular (20 ),
215+ border: Border .all (color: postalRed.withValues (alpha: 0.25 )),
216+ ),
217+ child: Row (
218+ mainAxisSize: MainAxisSize .min,
219+ children: [
220+ const Text ('🔥' , style: TextStyle (fontSize: 18 )),
221+ const SizedBox (width: AppSpacing .xs),
222+ Text (
223+ '$streak -day streak' ,
224+ style: Theme .of (context).textTheme.labelLarge? .copyWith (
225+ color: postalRed,
226+ fontWeight: FontWeight .w600,
227+ ),
228+ ),
229+ ],
230+ ),
231+ ),
232+ );
233+ },
234+ ),
199235 SvgPicture .asset (
200236 'assets/postbox.svg' ,
201237 height: 100 ,
0 commit comments