home_page.dart 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import 'package:flutter/material.dart';
  2. import 'package:physigo/Services/AuthService.dart';
  3. import 'package:physigo/challenge/daily_challenge_page.dart';
  4. import 'package:physigo/challenge/weekly_challenge_page.dart';
  5. class HomePage extends StatelessWidget {
  6. const HomePage({Key? key}) : super(key: key);
  7. String get name => AuthenticationServices.user!.name;
  8. num get totalPoint => AuthenticationServices.user!.totalPoints;
  9. @override
  10. Widget build(BuildContext context) {
  11. return Padding(
  12. padding: const EdgeInsets.all(16.0),
  13. child: Column(
  14. mainAxisAlignment: MainAxisAlignment.center,
  15. children: [
  16. Text(
  17. "Welcome back $name!",
  18. textAlign: TextAlign.center,
  19. style: const TextStyle(
  20. fontSize: 28,
  21. fontWeight: FontWeight.bold,
  22. ),
  23. ),
  24. const SizedBox(height: 36),
  25. Column(
  26. children: const [
  27. Align(
  28. alignment: Alignment.bottomLeft,
  29. child: Text(
  30. "Here are your challenges:",
  31. style: TextStyle(fontSize: 24),
  32. ),
  33. ),
  34. SizedBox(height: 24),
  35. ChallengeTile(
  36. challengeType: "Daily",
  37. challengePage: DailyChallengePage(),
  38. ),
  39. ChallengeTile(
  40. challengeType: "Weekly",
  41. challengePage: WeeklyChallengePage(),
  42. ),
  43. ],
  44. ),
  45. ],
  46. ),
  47. );
  48. }
  49. }
  50. class ChallengeTile extends StatelessWidget {
  51. final Widget challengePage;
  52. const ChallengeTile({
  53. required this.challengePage,
  54. required this.challengeType,
  55. Key? key,
  56. }) : super(key: key);
  57. final String challengeType;
  58. @override
  59. Widget build(BuildContext context) {
  60. return SizedBox(
  61. width: MediaQuery.of(context).size.width * 0.6,
  62. child: Card(
  63. elevation: 3,
  64. color: Colors.blueGrey,
  65. child: ListTile(
  66. title: Text(
  67. challengeType.toUpperCase(),
  68. textAlign: TextAlign.center,
  69. style: const TextStyle(
  70. fontSize: 18,
  71. fontWeight: FontWeight.bold,
  72. letterSpacing: 1.8,
  73. color: Colors.white,
  74. ),
  75. ),
  76. trailing: const Icon(Icons.arrow_forward, color: Colors.white),
  77. onTap: () {
  78. Navigator.push(context, MaterialPageRoute(builder: (_) => challengePage));
  79. },
  80. ),
  81. ),
  82. );
  83. }
  84. }