| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- 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<int> repCounter;
- final Exercise exercise;
- final StreamController<StepExercise> stepExerciseController;
- @override
- Widget build(BuildContext context) {
- return Column(
- children: [
- StreamBuilder<StepExercise>(
- 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<int>(
- 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,
- )),
- )
- ],
- );
- },
- ),
- ],
- );
- }
- }
|