cpd_2022_zi/lib/providers/workout_provider.dart

34 lines
926 B
Dart
Raw Normal View History

import 'package:flutter/material.dart';
class WorkoutProvider extends ChangeNotifier {
final List<String> _workoutPhases = [
'Warm-Up',
'High Intensity',
'Low Intensity',
'High Intensity',
'Low Intensity',
'High Intensity',
'Low Intensity',
'High Intensity',
'Cool-down'
];
final Map<String, Duration> _phasesDuration = {
'Warm-Up': const Duration(seconds: 5),
'High Intensity': const Duration(seconds: 4),
'Low Intensity': const Duration(seconds: 3),
'Cool-down': const Duration(seconds: 5)
};
int _workoutPhaseIndex = 0;
String get currentPhase => _workoutPhases[_workoutPhaseIndex];
Duration get currentPhaseDuration =>
_phasesDuration[currentPhase] ?? const Duration(seconds: 0);
void nextPhase() {
_workoutPhaseIndex < _workoutPhases.length
? _workoutPhaseIndex += 1
: _workoutPhaseIndex = 0;
//notifyListeners();
}
}