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