import 'dart:async'; import 'package:flutter/material.dart'; import 'package:physigo/exercises/exercises_validation/models/exercise.dart'; import 'package:physigo/exercises/exercises_validation/widgets/pose_detector.dart'; class ExerciseIndicator extends StatelessWidget { const ExerciseIndicator({ Key? key, required this.repCounter, required this.stepExerciseController, required this.exercise, }) : super(key: key); final Stream repCounter; final Exercise exercise; final StreamController stepExerciseController; @override Widget build(BuildContext context) { return Column( children: [ StreamBuilder( stream: stepExerciseController.stream, builder: (context, snapshot) { Color color; if (!snapshot.hasData) { color = Colors.black; } else { switch (snapshot.data!) { case StepExercise.notInPlace: color = Colors.black; break; case StepExercise.ready: color = Colors.green; break; case StepExercise.start: color = Colors.blue; break; case StepExercise.end: color = Colors.yellow; break; } } return Container( height: 100, width: 100, color: color, ); }, ), StreamBuilder( stream: repCounter, builder: (context, snapshot) { var repCounter = 0; if (snapshot.hasData) { repCounter = snapshot.data!; } return Column( children: [ Text( "Reps: ${repCounter % exercise.repetitions}/${exercise.repetitions}", style: const TextStyle(fontSize: 40), ), Text( "Sets: ${repCounter ~/ exercise.repetitions}/${exercise.sets}", style: const TextStyle(fontSize: 40), ), const SizedBox(height: 10), ElevatedButton( onPressed: () => Navigator.pop(context), style: ElevatedButton.styleFrom( padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 32), ), child: const Text("BACK", style: TextStyle( fontSize: 20, fontWeight: FontWeight.bold, letterSpacing: 1.3, )), ) ], ); }, ), ], ); } }