import 'package:flutter/material.dart'; import 'package:physigo/Services/AuthService.dart'; import 'package:physigo/challenge/services/challenge_service.dart'; import 'package:physigo/challenge/widgets/challenge_exercises.dart'; import 'package:physigo/navigation/navigation_page.dart'; class WeeklyChallengePage extends StatelessWidget { const WeeklyChallengePage({Key? key}) : super(key: key); Future get weeklyPlaceFuture => AuthenticationServices.user!.weeklyPlace.get(); @override Widget build(BuildContext context) { return FutureBuilder( future: weeklyPlaceFuture, builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return const Center(child: CircularProgressIndicator()); } final weeklyPlace = snapshot.data.data(); final weeklyPlaceName = weeklyPlace["name"]; final weeklyPlaceLocation = weeklyPlace["location"]["geopoint"]; return Scaffold( body: Padding( padding: const EdgeInsets.all(16.0), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ const Center( child: Text( "Weekly Challenge", textAlign: TextAlign.center, style: TextStyle( fontSize: 28, fontWeight: FontWeight.bold, letterSpacing: 1.8, // color: Colors.white, ), ), ), const SizedBox(height: 12), Center( child: Text( "Location: $weeklyPlaceName", textAlign: TextAlign.center, maxLines: 2, overflow: TextOverflow.ellipsis, style: const TextStyle(fontSize: 18), ), ), const SizedBox(height: 48), const ChallengeExercises(getChallenge: ChallengeService.getWeeklyChallenge), const SizedBox(height: 48), ElevatedButton( style: ElevatedButton.styleFrom(primary: Colors.teal), onPressed: () => Navigator.push( context, MaterialPageRoute( builder: (_) => NavigationPage(destination: weeklyPlaceLocation), ), ), child: Padding( padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: const [ Flexible(child: Text("Show me the way", style: TextStyle(fontSize: 24), maxLines: 2)), Icon(Icons.map, size: 32), ], ), ), ), ], ), ), ); }); } }