exercises_page.dart 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. import 'package:flutter/material.dart';
  2. import 'package:physigo/exercises/exercises_validation/models/arm_raises.dart';
  3. import 'package:physigo/exercises/exercises_validation/models/exercise.dart';
  4. import 'package:physigo/exercises/exercises_validation/models/leg_curl.dart';
  5. import 'package:physigo/exercises/exercises_validation/models/leg_raises.dart';
  6. import 'package:physigo/exercises/exercises_validation/models/squat.dart';
  7. import 'package:physigo/walking/walking_page.dart';
  8. import 'exercises_validation/exercise_validation_page.dart';
  9. import 'exercises_validation/models/push_up.dart';
  10. class ExercisesPage extends StatelessWidget {
  11. const ExercisesPage({Key? key}) : super(key: key);
  12. @override
  13. Widget build(BuildContext context) {
  14. return Scaffold(
  15. body: Padding(
  16. padding: const EdgeInsets.all(16.0),
  17. child: Column(
  18. mainAxisAlignment: MainAxisAlignment.center,
  19. children: [
  20. const Center(
  21. child: Text(
  22. "Exercises",
  23. textAlign: TextAlign.center,
  24. style: TextStyle(
  25. fontSize: 28,
  26. fontWeight: FontWeight.bold,
  27. // color: Colors.white,
  28. ),
  29. ),
  30. ),
  31. const SizedBox(height: 24),
  32. const TextField(
  33. decoration: InputDecoration(
  34. border: OutlineInputBorder(),
  35. hintText: "Search exercise...",
  36. ),
  37. ),
  38. const SizedBox(height: 24),
  39. Row(
  40. mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  41. children: [
  42. FilterChip(
  43. label: const Text("Easy", style: TextStyle(color: Colors.white, fontSize: 18)),
  44. selected: true,
  45. backgroundColor: Colors.lightGreen,
  46. selectedColor: Colors.lightGreen,
  47. checkmarkColor: Colors.white,
  48. onSelected: (_) {},
  49. ),
  50. FilterChip(
  51. label: const Text("Normal", style: TextStyle(color: Colors.white, fontSize: 18)),
  52. selected: true,
  53. backgroundColor: Colors.amber,
  54. selectedColor: Colors.amber,
  55. checkmarkColor: Colors.white,
  56. onSelected: (_) {},
  57. ),
  58. FilterChip(
  59. label: const Text("Hard", style: TextStyle(color: Colors.white, fontSize: 18)),
  60. selected: true,
  61. backgroundColor: Colors.red,
  62. selectedColor: Colors.red,
  63. checkmarkColor: Colors.white,
  64. onSelected: (_) {},
  65. ),
  66. ],
  67. ),
  68. const SizedBox(height: 48),
  69. const WalkExerciseTile(),
  70. ExerciseTile(exerciseName: "leg curl", exercise: legCurl, difficulty: 0),
  71. ExerciseTile(exerciseName: "leg raises", exercise: legRaises, difficulty: 0),
  72. ExerciseTile(exerciseName: "knee raises", exercise: pushUp, difficulty: 1),
  73. ExerciseTile(exerciseName: "arm raises", exercise: armRaises, difficulty: 1),
  74. ExerciseTile(exerciseName: "squat", exercise: squat, difficulty: 2),
  75. ],
  76. ),
  77. ),
  78. );
  79. }
  80. }
  81. class ExerciseTile extends StatelessWidget {
  82. final String exerciseName;
  83. final Exercise exercise;
  84. final int difficulty;
  85. const ExerciseTile({
  86. required this.exerciseName,
  87. required this.exercise,
  88. required this.difficulty,
  89. Key? key,
  90. }) : super(key: key);
  91. Color get cardColor {
  92. if (difficulty == 0) return Colors.lightGreen;
  93. if (difficulty == 1) return Colors.amber;
  94. if (difficulty == 2) return Colors.red;
  95. return Colors.blueGrey;
  96. }
  97. @override
  98. Widget build(BuildContext context) {
  99. return Center(
  100. child: Card(
  101. color: cardColor,
  102. elevation: 3,
  103. child: ListTile(
  104. iconColor: Colors.white,
  105. textColor: Colors.white,
  106. title: Text(
  107. exerciseName.toUpperCase(),
  108. textAlign: TextAlign.center,
  109. style: const TextStyle(
  110. fontSize: 18,
  111. fontWeight: FontWeight.bold,
  112. letterSpacing: 1.8,
  113. ),
  114. ),
  115. trailing: const Icon(Icons.arrow_forward),
  116. onTap: () {
  117. Navigator.push(
  118. context,
  119. MaterialPageRoute(
  120. builder: (_) => ExerciseValidationPage(exercise: exercise),
  121. ),
  122. );
  123. },
  124. ),
  125. ),
  126. );
  127. }
  128. }
  129. class WalkExerciseTile extends StatelessWidget {
  130. const WalkExerciseTile({
  131. Key? key,
  132. }) : super(key: key);
  133. @override
  134. Widget build(BuildContext context) {
  135. return Center(
  136. child: Card(
  137. color: Colors.lightGreen,
  138. elevation: 3,
  139. child: ListTile(
  140. iconColor: Colors.white,
  141. textColor: Colors.white,
  142. title: Text(
  143. "walk".toUpperCase(),
  144. textAlign: TextAlign.center,
  145. style: const TextStyle(
  146. fontSize: 18,
  147. fontWeight: FontWeight.bold,
  148. letterSpacing: 1.8,
  149. ),
  150. ),
  151. trailing: const Icon(Icons.arrow_forward),
  152. onTap: () {
  153. Navigator.push(
  154. context,
  155. MaterialPageRoute(
  156. builder: (_) => WalkingPage(),
  157. ),
  158. );
  159. },
  160. ),
  161. ),
  162. );
  163. }
  164. }