progress indicator
This commit is contained in:
@ -10,6 +10,7 @@ class ActivityTimerModel with ChangeNotifier {
|
||||
int _currentActionNum = 0;
|
||||
int _currentSetNum = 0;
|
||||
Timer? _periodicTimer;
|
||||
double _progress = 0;
|
||||
|
||||
int get actionCount => _actionCounter;
|
||||
int get currentActionNum => _currentActionNum;
|
||||
@ -20,7 +21,7 @@ class ActivityTimerModel with ChangeNotifier {
|
||||
List get sets => _sets;
|
||||
Timer? get periodicTimer => _periodicTimer;
|
||||
bool get isActive => _isActive();
|
||||
void get pause => _periodicTimer!.cancel();
|
||||
double get progress => _progress;
|
||||
|
||||
void setup(ActivityModel activity) {
|
||||
_activity = activity;
|
||||
@ -51,6 +52,11 @@ class ActivityTimerModel with ChangeNotifier {
|
||||
_actionCounter = currentAction['amount'];
|
||||
}
|
||||
|
||||
void pause() {
|
||||
_periodicTimer!.cancel();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void start() {
|
||||
_periodicTimer = Timer.periodic(const Duration(seconds: 1), (Timer timer) {
|
||||
switch (currentAction['type']) {
|
||||
@ -65,12 +71,18 @@ class ActivityTimerModel with ChangeNotifier {
|
||||
nextAction(_currentActionNum + 1);
|
||||
setActionCount();
|
||||
}
|
||||
updateProgress();
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
});
|
||||
}
|
||||
|
||||
void updateProgress() {
|
||||
_progress = (currentAction['actionID'] + (1.0 - _actionCounter / currentAction['amount'])) / totalActions();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setAction(int setNum, int actionNum, String type) {
|
||||
_currentActionNum = actionNum;
|
||||
_currentSetNum = setNum;
|
||||
|
Reference in New Issue
Block a user