activity counter #2
@ -18,7 +18,7 @@ class ActivityAction {
|
|||||||
List<List<Map<String, dynamic>>> items() {
|
List<List<Map<String, dynamic>>> items() {
|
||||||
List<List<Map<String, dynamic>>> sets = [];
|
List<List<Map<String, dynamic>>> sets = [];
|
||||||
Reps reps = activityActionSet.reps;
|
Reps reps = activityActionSet.reps;
|
||||||
int totalActions = 1;
|
int totalActions = 0;
|
||||||
|
|
||||||
for (int i = 0; i < activityActionSet.total; i++) {
|
for (int i = 0; i < activityActionSet.total; i++) {
|
||||||
List<Map<String, dynamic>> actions = [];
|
List<Map<String, dynamic>> actions = [];
|
||||||
@ -38,7 +38,7 @@ class ActivityAction {
|
|||||||
'actionID': totalActions++,
|
'actionID': totalActions++,
|
||||||
'name': 'Rest',
|
'name': 'Rest',
|
||||||
'type': 'seconds',
|
'type': 'seconds',
|
||||||
'amount': reps.amounts[i],
|
'amount': reps.rest! ~/ 1000,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,6 +60,13 @@ class ActivityAction {
|
|||||||
|
|
||||||
sets.add(actions);
|
sets.add(actions);
|
||||||
|
|
||||||
|
// sets.add([{
|
||||||
|
// 'actionID': totalActions++,
|
||||||
|
// 'name': 'Rest',
|
||||||
|
// 'type': 'seconds',
|
||||||
|
// 'amount': activityActionSet.rest ~/ 1000,
|
||||||
|
// }]);
|
||||||
|
|
||||||
// for (int j = 0; i < activityActionSet.reps.amounts; j++) {}
|
// for (int j = 0; i < activityActionSet.reps.amounts; j++) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,10 +30,6 @@ class ActivityTimerModel with ChangeNotifier {
|
|||||||
setActionCount();
|
setActionCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _isActive() {
|
|
||||||
return (_periodicTimer != null && _periodicTimer!.isActive) ? true : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isCurrentItem(int setNum, int actionNum) {
|
bool isCurrentItem(int setNum, int actionNum) {
|
||||||
if (setNum == _currentSetNum && actionNum == _currentActionNum) {
|
if (setNum == _currentSetNum && actionNum == _currentActionNum) {
|
||||||
return true;
|
return true;
|
||||||
@ -44,7 +40,7 @@ class ActivityTimerModel with ChangeNotifier {
|
|||||||
|
|
||||||
int totalActions() {
|
int totalActions() {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for(int i = 0; i < _sets.length; i++) {
|
for (int i = 0; i < _sets.length; i++) {
|
||||||
count = count + _sets[i].length as int;
|
count = count + _sets[i].length as int;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,12 +48,14 @@ class ActivityTimerModel with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setActionCount() {
|
void setActionCount() {
|
||||||
_actionCounter = _sets[_currentSetNum][_currentActionNum]['amount'];
|
_actionCounter = currentAction['amount'];
|
||||||
}
|
}
|
||||||
|
|
||||||
void start() {
|
void start() {
|
||||||
_periodicTimer = Timer.periodic(const Duration(seconds: 1), (Timer timer) {
|
_periodicTimer = Timer.periodic(const Duration(seconds: 1), (Timer timer) {
|
||||||
switch(currentAction['type']) {
|
switch (currentAction['type']) {
|
||||||
|
// we don't want to count down
|
||||||
|
// if its repititions
|
||||||
case 'repititions':
|
case 'repititions':
|
||||||
break;
|
break;
|
||||||
case 'seconds':
|
case 'seconds':
|
||||||
@ -65,6 +63,7 @@ class ActivityTimerModel with ChangeNotifier {
|
|||||||
_actionCounter--;
|
_actionCounter--;
|
||||||
} else {
|
} else {
|
||||||
nextAction(_currentActionNum + 1);
|
nextAction(_currentActionNum + 1);
|
||||||
|
setActionCount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,113 +77,22 @@ class ActivityTimerModel with ChangeNotifier {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
void nextAction(int nextActionID) {
|
void nextAction(int nextActionIndex) {
|
||||||
|
if (currentSet.length > nextActionIndex) {
|
||||||
|
setAction(_currentSetNum, nextActionIndex, 'automatic');
|
||||||
|
} else if (_sets.length > _currentSetNum + 1) {
|
||||||
|
// if the item isn't in the set
|
||||||
|
// increment the set and reset action index
|
||||||
|
setAction(_currentSetNum + 1, 0, 'automatic');
|
||||||
|
} else {
|
||||||
|
// if we're done all the sets
|
||||||
|
// cancel timer and reset activity
|
||||||
|
_periodicTimer!.cancel();
|
||||||
|
setup(_activity!);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(int, int) _findAction(int actionID) {
|
bool _isActive() {
|
||||||
return (1, 2);
|
return (_periodicTimer != null && _periodicTimer!.isActive) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// void nextAction(String type) {
|
|
||||||
// setAction(_currentActionNum + 1, _getSet(), type);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// int _actionCounter = 0;
|
|
||||||
// int _currentAction = 0;
|
|
||||||
// ActivityModel? _activity;
|
|
||||||
// Timer? _periodicTimer;
|
|
||||||
// List<String> _actionMap = [];
|
|
||||||
|
|
||||||
// int get actionCount => _actionCounter;
|
|
||||||
// int get currentAction => _currentAction;
|
|
||||||
// ActivityModel? get activity => _activity;
|
|
||||||
// Timer? get periodicTimer => _periodicTimer;
|
|
||||||
// String get actionType => _actionMap[_currentAction];
|
|
||||||
// String get setType => _activity != null
|
|
||||||
// ? _activity!.actions[0].activityActionSet.reps.type
|
|
||||||
// : 'n/a';
|
|
||||||
// String? get repType => actionState();
|
|
||||||
// List get sets => _activity!.actions[0].items();
|
|
||||||
|
|
||||||
// void setup(ActivityModel activity) {
|
|
||||||
// // if there isn't an activity yet
|
|
||||||
// // or we're coming from another activity
|
|
||||||
// // setup new timer
|
|
||||||
// if (_activity == null || activity.id != _activity?.id) {
|
|
||||||
// _periodicTimer?.cancel();
|
|
||||||
// _activity = activity;
|
|
||||||
// _currentAction = 0;
|
|
||||||
// _actionMap = [];
|
|
||||||
// // for now we just do alternating rest/sets
|
|
||||||
// // in the future, we'll make this more modifiable
|
|
||||||
// int totalActions = activity.actions[0].activityActionSet.total;
|
|
||||||
// // log(activity.actions[0].activityActionSet.type);
|
|
||||||
// // if (activity.actions[0].activityActionSet.type == 'alternating') {
|
|
||||||
// // totalActions = totalActions * 4;
|
|
||||||
// // log('were in $totalActions');
|
|
||||||
// // }
|
|
||||||
|
|
||||||
// for (int i = 0; i < totalActions; i++) {
|
|
||||||
// _actionMap.addAll(['Set', 'Rest']);
|
|
||||||
// }
|
|
||||||
// getValue();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// String actionState() {
|
|
||||||
// if (actionType == 'Set') {
|
|
||||||
// return setType == 'seconds' ? 'Seconds' : 'Repititions';
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return 'Seconds';
|
|
||||||
// }
|
|
||||||
|
|
||||||
// void getValue() {
|
|
||||||
// if (_actionMap[_currentAction] == "Rest") {
|
|
||||||
// _actionCounter = _activity!.actions[0].activityActionSet.rest ~/ 1000;
|
|
||||||
// } else {
|
|
||||||
// _actionCounter = _activity!.actions[0].activityActionSet.reps.amounts[0];
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// void pause() {
|
|
||||||
// _periodicTimer?.cancel();
|
|
||||||
// notifyListeners();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// void setAction(int actionNum, String type) {
|
|
||||||
// // always pause if we're manually taversing
|
|
||||||
// if (type == 'manual' && setType == 'seconds') {
|
|
||||||
// pause();
|
|
||||||
// }
|
|
||||||
// _currentAction = actionNum;
|
|
||||||
// getValue();
|
|
||||||
// notifyListeners();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// void nextAction(String type) {
|
|
||||||
// _currentAction + 1 >= _actionMap.length
|
|
||||||
// ? pause()
|
|
||||||
// : setAction(_currentAction + 1, type);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// bool isActive() {
|
|
||||||
// return (_periodicTimer != null && _periodicTimer!.isActive) ? true : false;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// void start() {
|
|
||||||
// if (_activity != null) {
|
|
||||||
// _periodicTimer?.cancel();
|
|
||||||
// _periodicTimer =
|
|
||||||
// Timer.periodic(const Duration(seconds: 1), (Timer timer) {
|
|
||||||
// if (_actionCounter <= 0) {
|
|
||||||
// nextAction('automatic');
|
|
||||||
// } else if (actionState() != 'Repititions') {
|
|
||||||
// _actionCounter--;
|
|
||||||
// }
|
|
||||||
// notifyListeners();
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ class ActivityActionViewState extends State<ActivityActionView> {
|
|||||||
? Theme.of(context).colorScheme.primaryContainer
|
? Theme.of(context).colorScheme.primaryContainer
|
||||||
: Theme.of(context).colorScheme.onPrimary,
|
: Theme.of(context).colorScheme.onPrimary,
|
||||||
child:
|
child:
|
||||||
Text(textAlign: TextAlign.center, 'Set ${setNum + 1} ')),
|
Text(textAlign: TextAlign.center, '${setNum + 1}.${actionNum + 1} ')),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Ink(
|
child: Ink(
|
||||||
padding: const EdgeInsets.all(15),
|
padding: const EdgeInsets.all(15),
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:sendtrain/classes/activity_action.dart';
|
import 'package:sendtrain/classes/activity_action.dart';
|
||||||
import 'package:sendtrain/classes/media.dart';
|
import 'package:sendtrain/classes/media.dart';
|
||||||
@ -58,11 +59,11 @@ class _ActivityViewState extends State<ActivityView> {
|
|||||||
child: Card(
|
child: Card(
|
||||||
clipBehavior: Clip.antiAlias,
|
clipBehavior: Clip.antiAlias,
|
||||||
shape: const RoundedRectangleBorder(
|
shape: const RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.only(topLeft: Radius.circular(10), topRight: Radius.circular(10)),
|
borderRadius: BorderRadius.only(
|
||||||
|
topLeft: Radius.circular(10),
|
||||||
|
topRight: Radius.circular(10)),
|
||||||
),
|
),
|
||||||
color: Theme.of(context).colorScheme.onPrimary,
|
color: Theme.of(context).colorScheme.onPrimary,
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 0, right: 0),
|
|
||||||
child: Row(children: [
|
child: Row(children: [
|
||||||
// LinearProgressIndicator(
|
// LinearProgressIndicator(
|
||||||
// value: 0.5,
|
// value: 0.5,
|
||||||
@ -70,25 +71,6 @@ class _ActivityViewState extends State<ActivityView> {
|
|||||||
// color: Theme.of(context).colorScheme.error,
|
// color: Theme.of(context).colorScheme.error,
|
||||||
// semanticsLabel: 'Linear progress indicator',
|
// semanticsLabel: 'Linear progress indicator',
|
||||||
// ),
|
// ),
|
||||||
// Expanded(
|
|
||||||
// flex: 1,
|
|
||||||
// child: Flex(direction: Axis.horizontal, children: [
|
|
||||||
// Consumer<ActivityTimerModel>(builder: (context, atm, child) {
|
|
||||||
// return IconButton(
|
|
||||||
// iconSize: 30,
|
|
||||||
// icon: atm.isActive()
|
|
||||||
// ? const Icon(Icons.pause_rounded)
|
|
||||||
// : const Icon(Icons.play_arrow_rounded),
|
|
||||||
// onPressed: () =>
|
|
||||||
// {atm.isActive() ? atm.pause : atm.start()});
|
|
||||||
// }),
|
|
||||||
// // IconButton(
|
|
||||||
// // // iconSize: 36,
|
|
||||||
// // icon: const Icon(Icons.skip_next_rounded),
|
|
||||||
// // onPressed: () {
|
|
||||||
// // atm.nextAction('manual');
|
|
||||||
// // })
|
|
||||||
// ])),
|
|
||||||
Ink(
|
Ink(
|
||||||
width: 70,
|
width: 70,
|
||||||
color: Theme.of(context).colorScheme.primaryContainer,
|
color: Theme.of(context).colorScheme.primaryContainer,
|
||||||
@ -105,81 +87,33 @@ class _ActivityViewState extends State<ActivityView> {
|
|||||||
},
|
},
|
||||||
)),
|
)),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 2,
|
flex: 1,
|
||||||
|
child: Stack(alignment: Alignment.center, children: [
|
||||||
|
Container(
|
||||||
|
alignment: Alignment.center,
|
||||||
child: Consumer<ActivityTimerModel>(
|
child: Consumer<ActivityTimerModel>(
|
||||||
builder: (context, atm, child) {
|
builder: (context, atm, child) {
|
||||||
return Text(
|
return Text(
|
||||||
style: const TextStyle(fontSize: 20),
|
style: const TextStyle(fontSize: 20),
|
||||||
textAlign: TextAlign.right,
|
textAlign: TextAlign.center,
|
||||||
'${atm.actionCount} ${atm.currentAction['type']}');
|
'${atm.actionCount} ${atm.currentAction['type']}');
|
||||||
},
|
},
|
||||||
)),
|
),
|
||||||
Expanded(
|
),
|
||||||
flex: 1,
|
Container(
|
||||||
child: Padding(
|
alignment: Alignment.centerRight,
|
||||||
padding: const EdgeInsets.only(right: 15),
|
padding: EdgeInsets.only(right: 10),
|
||||||
child: Consumer<ActivityTimerModel>(
|
child: Consumer<ActivityTimerModel>(
|
||||||
builder: (context, atm, child) {
|
builder: (context, atm, child) {
|
||||||
return Text(
|
return Text(
|
||||||
style: const TextStyle(fontSize: 15),
|
style: const TextStyle(fontSize: 15),
|
||||||
textAlign: TextAlign.right,
|
textAlign: TextAlign.right,
|
||||||
'${atm.currentAction['actionID']} | ${atm.totalActions()}');
|
'${atm.currentAction['actionID'] + 1} | ${atm.totalActions()}');
|
||||||
// 'Set: ${atm.currentSet + 1}/${atm.totalSets}\nRep: ${atm.currentRep + 1}/${atm.totalReps}');
|
// 'Set: ${atm.currentSet + 1}/${atm.totalSets}\nRep: ${atm.currentRep + 1}/${atm.totalReps}');
|
||||||
}))),
|
})),
|
||||||
])))),
|
])),
|
||||||
|
]))),
|
||||||
ActivityActionView(action: activity.actions[0]),
|
ActivityActionView(action: activity.actions[0]),
|
||||||
// Container(
|
|
||||||
// height: MediaQuery.sizeOf(context).height * .07,
|
|
||||||
// color: Theme.of(context).colorScheme.primaryContainer,
|
|
||||||
// child: Row(children: [
|
|
||||||
// // LinearProgressIndicator(
|
|
||||||
// // value: 0.5,
|
|
||||||
// // minHeight: 100,
|
|
||||||
// // color: Theme.of(context).colorScheme.error,
|
|
||||||
// // semanticsLabel: 'Linear progress indicator',
|
|
||||||
// // ),
|
|
||||||
// Expanded(
|
|
||||||
// flex: 1,
|
|
||||||
// child: Flex(direction: Axis.horizontal, children: [
|
|
||||||
// Consumer<ActivityTimerModel>(builder: (context, atm, child) {
|
|
||||||
// return IconButton(
|
|
||||||
// iconSize: 30,
|
|
||||||
// icon: atm.isActive()
|
|
||||||
// ? const Icon(Icons.pause_rounded)
|
|
||||||
// : const Icon(Icons.play_arrow_rounded),
|
|
||||||
// onPressed: () =>
|
|
||||||
// {atm.isActive() ? atm.pause() : atm.start()});
|
|
||||||
// }),
|
|
||||||
// IconButton(
|
|
||||||
// iconSize: 36,
|
|
||||||
// icon: const Icon(Icons.skip_next_rounded),
|
|
||||||
// onPressed: () {
|
|
||||||
// atm.nextAction('manual');
|
|
||||||
// })
|
|
||||||
// ])),
|
|
||||||
// Expanded(
|
|
||||||
// flex: 1,
|
|
||||||
// child: Consumer<ActivityTimerModel>(
|
|
||||||
// builder: (context, atm, child) {
|
|
||||||
// return Text(
|
|
||||||
// style: const TextStyle(fontSize: 20),
|
|
||||||
// textAlign: TextAlign.center,
|
|
||||||
// '${atm.actionCount} ${atm.actionState()}');
|
|
||||||
// },
|
|
||||||
// )),
|
|
||||||
// Expanded(
|
|
||||||
// flex: 1,
|
|
||||||
// child: Padding(
|
|
||||||
// padding: const EdgeInsets.only(right: 15),
|
|
||||||
// child: Consumer<ActivityTimerModel>(
|
|
||||||
// builder: (context, atm, child) {
|
|
||||||
// return Text(
|
|
||||||
// style: const TextStyle(fontSize: 20),
|
|
||||||
// textAlign: TextAlign.right,
|
|
||||||
// '${atm.currentAction + 1}: ${atm.actionType}');
|
|
||||||
// // 'Set: ${atm.currentSet + 1}/${atm.totalSets}\nRep: ${atm.currentRep + 1}/${atm.totalReps}');
|
|
||||||
// }))),
|
|
||||||
// ]))
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,13 +131,13 @@ class SessionCard extends StatelessWidget {
|
|||||||
activityActionSet: Set(
|
activityActionSet: Set(
|
||||||
type: 'alternating',
|
type: 'alternating',
|
||||||
total: 5,
|
total: 5,
|
||||||
rest: 300000,
|
rest: 5000,
|
||||||
reps: Reps(
|
reps: Reps(
|
||||||
type: 'seconds',
|
type: 'seconds',
|
||||||
tempo: [0],
|
tempo: [0],
|
||||||
amounts: [60, 60, 60, 60, 60],
|
amounts: [5, 5, 5, 5, 5],
|
||||||
weights: [80, 80, 80, 80, 80],
|
weights: [80, 80, 80, 80, 80],
|
||||||
rest: 0))),
|
rest: 5000))),
|
||||||
],
|
],
|
||||||
resources: ['https://www.youtube.com/watch?v=dyAvbUvY_PU']),
|
resources: ['https://www.youtube.com/watch?v=dyAvbUvY_PU']),
|
||||||
],
|
],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user