added dash for local db, ui prep work
This commit is contained in:
@ -13,6 +13,7 @@ class ActivityTimerModel with ChangeNotifier {
|
||||
Timer? _periodicTimer;
|
||||
double _progress = 0;
|
||||
ItemScrollController? _isc;
|
||||
int _totalTime = 0;
|
||||
|
||||
int get actionCount => _actionCounter;
|
||||
int get currentActionNum => _currentActionNum;
|
||||
@ -24,6 +25,7 @@ class ActivityTimerModel with ChangeNotifier {
|
||||
Timer? get periodicTimer => _periodicTimer;
|
||||
bool get isActive => _isActive();
|
||||
double get progress => _progress;
|
||||
int get totalTime => _totalTime;
|
||||
|
||||
void setup(ActivityModel activity) {
|
||||
if (_activity == null || activity.id != _activity?.id) {
|
||||
@ -35,11 +37,26 @@ class ActivityTimerModel with ChangeNotifier {
|
||||
_currentActionNum = 0;
|
||||
_currentSetNum = 0;
|
||||
setActionCount();
|
||||
getTotalTime();
|
||||
}
|
||||
|
||||
moveToIndex(_currentSetNum);
|
||||
}
|
||||
|
||||
void getTotalTime() {
|
||||
int time = 0;
|
||||
for(int setIndex = 0; _sets.length > setIndex; setIndex++) {
|
||||
for (int actionIndex = 0; _sets[setIndex].length > actionIndex; actionIndex++) {
|
||||
var action = _sets[setIndex][actionIndex];
|
||||
if (action['type'] == 'seconds') {
|
||||
time = time + action['amount'] as int;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_totalTime = time;
|
||||
}
|
||||
|
||||
void reset() {
|
||||
_progress = 0;
|
||||
_currentActionNum = 0;
|
||||
@ -89,6 +106,7 @@ class ActivityTimerModel with ChangeNotifier {
|
||||
case 'seconds':
|
||||
if (_actionCounter > 0) {
|
||||
_actionCounter--;
|
||||
_totalTime--;
|
||||
} else {
|
||||
nextAction(_currentActionNum + 1);
|
||||
setActionCount();
|
||||
@ -110,8 +128,8 @@ class ActivityTimerModel with ChangeNotifier {
|
||||
void setAction(int setNum, int actionNum, String type) {
|
||||
_currentActionNum = actionNum;
|
||||
_currentSetNum = setNum;
|
||||
moveToIndex(_currentSetNum);
|
||||
notifyListeners();
|
||||
moveToIndex(_currentSetNum);
|
||||
}
|
||||
|
||||
void nextAction(int nextActionIndex) {
|
||||
|
Reference in New Issue
Block a user