cpd_2022_zi/lib/widgets/workout_timer_widget.dart

32 lines
998 B
Dart

import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:smoke_cess_app/providers/workout_provider.dart';
import 'package:smoke_cess_app/widgets/timer_widget.dart';
import '../providers/timer_provider.dart';
class WorkoutTimerWidget extends StatelessWidget {
const WorkoutTimerWidget({super.key});
@override
Widget build(BuildContext context) {
TimerProvider timerProvider = context.watch<TimerProvider>();
WorkoutProvider workoutProvider = context.watch<WorkoutProvider>();
if (timerProvider.elapsedSeconds ==
workoutProvider.currentPhaseDuration.inSeconds) {
print('Timer abgelaufen');
workoutProvider.nextPhase();
timerProvider.startTimer(workoutProvider.currentPhaseDuration);
}
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(workoutProvider.currentPhase),
TimerWidget(duration: workoutProvider.currentPhaseDuration)
],
);
}
}