show phase colors in circularprogressindi
parent
da7c820dbd
commit
556daa9e90
|
@ -25,6 +25,7 @@ class WorkoutProvider extends ChangeNotifier {
|
|||
|
||||
WorkoutProvider(this.timerProvider);
|
||||
|
||||
//TODO: outsource all Maps to JSON File!
|
||||
final List<String> _workoutPhases = [
|
||||
'Warm-Up',
|
||||
'High Intensity',
|
||||
|
@ -48,6 +49,12 @@ class WorkoutProvider extends ChangeNotifier {
|
|||
'Low Intensity': AssetSource('workout.mp3'),
|
||||
'Cool-down': AssetSource('cool_down.mp3')
|
||||
};
|
||||
final Map<String, Color> _phaseColors = {
|
||||
'Warm-Up': Colors.green,
|
||||
'High Intensity': Colors.red,
|
||||
'Low Intensity': Colors.orange,
|
||||
'Cool-down': Colors.blue
|
||||
};
|
||||
int _workoutPhaseIndex = 0;
|
||||
|
||||
String get currentPhase => _workoutPhases[_workoutPhaseIndex];
|
||||
|
@ -55,6 +62,7 @@ class WorkoutProvider extends ChangeNotifier {
|
|||
_phasesDuration[currentPhase] ?? const Duration(seconds: 0);
|
||||
bool get isPhaseComplete =>
|
||||
timerProvider.elapsedSeconds - currentPhaseDuration.inSeconds == 0;
|
||||
Color get currentPhaseColor => _phaseColors[currentPhase] ?? Colors.blue;
|
||||
|
||||
void nextPhase() {
|
||||
_audioPlayer.stop();
|
||||
|
|
|
@ -33,6 +33,7 @@ class WorkoutTimerWidget extends StatelessWidget {
|
|||
height: 100,
|
||||
width: 100,
|
||||
child: CircularProgressIndicator(
|
||||
color: workoutProvider.currentPhaseColor,
|
||||
value: (workoutProvider.currentPhaseDuration.inSeconds
|
||||
.toDouble() -
|
||||
timerProvider.elapsedSeconds) /
|
||||
|
|
Loading…
Reference in New Issue