weekly_challenge_page.dart 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import 'package:flutter/material.dart';
  2. import 'package:physigo/Services/AuthService.dart';
  3. import 'package:physigo/challenge/services/challenge_service.dart';
  4. import 'package:physigo/challenge/widgets/challenge_exercises.dart';
  5. import 'package:physigo/navigation/navigation_page.dart';
  6. class WeeklyChallengePage extends StatelessWidget {
  7. const WeeklyChallengePage({Key? key}) : super(key: key);
  8. Future<dynamic> get weeklyPlaceFuture => AuthenticationServices.user!.weeklyPlace.get();
  9. @override
  10. Widget build(BuildContext context) {
  11. return FutureBuilder<dynamic>(
  12. future: weeklyPlaceFuture,
  13. builder: (context, snapshot) {
  14. if (snapshot.connectionState == ConnectionState.waiting) {
  15. return const Center(child: CircularProgressIndicator());
  16. }
  17. final weeklyPlace = snapshot.data.data();
  18. final weeklyPlaceName = weeklyPlace["name"];
  19. final weeklyPlaceLocation = weeklyPlace["location"]["geopoint"];
  20. return Scaffold(
  21. body: Padding(
  22. padding: const EdgeInsets.all(16.0),
  23. child: Column(
  24. mainAxisAlignment: MainAxisAlignment.center,
  25. children: [
  26. const Center(
  27. child: Text(
  28. "Weekly Challenge",
  29. textAlign: TextAlign.center,
  30. style: TextStyle(
  31. fontSize: 28,
  32. fontWeight: FontWeight.bold,
  33. letterSpacing: 1.8,
  34. // color: Colors.white,
  35. ),
  36. ),
  37. ),
  38. const SizedBox(height: 12),
  39. Center(
  40. child: Text(
  41. "Location: $weeklyPlaceName",
  42. textAlign: TextAlign.center,
  43. maxLines: 2,
  44. overflow: TextOverflow.ellipsis,
  45. style: const TextStyle(fontSize: 18),
  46. ),
  47. ),
  48. const SizedBox(height: 48),
  49. const ChallengeExercises(getChallenge: ChallengeService.getWeeklyChallenge),
  50. const SizedBox(height: 48),
  51. ElevatedButton(
  52. style: ElevatedButton.styleFrom(primary: Colors.teal),
  53. onPressed: () => Navigator.push(
  54. context,
  55. MaterialPageRoute(
  56. builder: (_) => NavigationPage(destination: weeklyPlaceLocation),
  57. ),
  58. ),
  59. child: Padding(
  60. padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
  61. child: Row(
  62. mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  63. children: const [
  64. Flexible(child: Text("Show me the way", style: TextStyle(fontSize: 24), maxLines: 2)),
  65. Icon(Icons.map, size: 32),
  66. ],
  67. ),
  68. ),
  69. ),
  70. ],
  71. ),
  72. ),
  73. );
  74. });
  75. }
  76. }