allow for reps and times

This commit is contained in:
Joshua Burman 2024-12-06 01:28:43 -05:00
parent 5bae1aa416
commit 56b25a6963
4 changed files with 166 additions and 84 deletions

View File

@ -15,6 +15,10 @@ class ActivityTimerModel with ChangeNotifier {
ActivityModel? get activity => _activity; ActivityModel? get activity => _activity;
Timer? get periodicTimer => _periodicTimer; Timer? get periodicTimer => _periodicTimer;
String get actionType => _actionMap[_currentAction]; String get actionType => _actionMap[_currentAction];
String get setType => _activity != null
? _activity!.actions[0].activityActionSet.reps.type
: 'n/a';
String? get repType => actionState();
void setup(ActivityModel activity) { void setup(ActivityModel activity) {
// if there isn't an activity yet // if there isn't an activity yet
@ -27,20 +31,33 @@ class ActivityTimerModel with ChangeNotifier {
_actionMap = []; _actionMap = [];
// for now we just do alternating rest/sets // for now we just do alternating rest/sets
// in the future, we'll make this more modifiable // in the future, we'll make this more modifiable
for (int i = 0; i < activity.actions[0].activityActionSet.total; i++) { int totalActions = activity.actions[0].activityActionSet.total;
_actionMap.addAll(['Set', 'Rest']); // 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(); getValue();
} }
} }
String actionState() {
if (actionType == 'Set') {
return setType == 'seconds' ? 'Seconds' : 'Repititions';
}
return 'Seconds';
}
void getValue() { void getValue() {
if (_actionMap[_currentAction] == "Rest") { if (_actionMap[_currentAction] == "Rest") {
_tickCount = _activity!.actions[0].activityActionSet.rest ~/ 1000; _tickCount = _activity!.actions[0].activityActionSet.rest ~/ 1000;
} else { } else {
_tickCount = _activity!.actions[0].activityActionSet.reps.rest ~/ 1000; _tickCount = _activity!.actions[0].activityActionSet.reps.amounts[0];
} }
} }
@ -51,7 +68,9 @@ class ActivityTimerModel with ChangeNotifier {
void setAction(int actionNum, String type) { void setAction(int actionNum, String type) {
// always pause if we're manually taversing // always pause if we're manually taversing
if (type == 'manual') { pause(); } if (type == 'manual' && setType == 'seconds') {
pause();
}
_currentAction = actionNum; _currentAction = actionNum;
getValue(); getValue();
notifyListeners(); notifyListeners();
@ -74,7 +93,7 @@ class ActivityTimerModel with ChangeNotifier {
Timer.periodic(const Duration(seconds: 1), (Timer timer) { Timer.periodic(const Duration(seconds: 1), (Timer timer) {
if (_tickCount <= 0) { if (_tickCount <= 0) {
nextAction('automatic'); nextAction('automatic');
} else { } else if (actionState() != 'Repititions') {
_tickCount--; _tickCount--;
} }
notifyListeners(); notifyListeners();

View File

@ -24,73 +24,136 @@ class ActivityActionViewState extends State<ActivityActionView> {
return Expanded( return Expanded(
child: ListView.builder( child: ListView.builder(
padding: const EdgeInsets.fromLTRB(10, 0, 10, 0), padding: const EdgeInsets.fromLTRB(10, 0, 20, 0),
itemCount: widget.action.activityActionSet.total, itemCount: widget.action.activityActionSet.total,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
String title = widget.action.title; String title = widget.action.title;
Set actionSet = widget.action.activityActionSet; Set actionSet = widget.action.activityActionSet;
Reps setReps = actionSet.reps; Reps setReps = actionSet.reps;
int setRest = actionSet.rest ~/ 1000; int setRest = actionSet.rest ~/ 1000;
List<Card> contents = [];
int currentAction = actionCount; int currentAction = actionCount;
List<GestureDetector> content = [];
contents.add(Card( actionCount = actionCount + 2;
elevation: 0.5, content.addAll([
shadowColor: Theme.of(context).colorScheme.shadow, GestureDetector(
color: currentAction == atm.currentAction onTap: () {
? Theme.of(context).colorScheme.secondaryContainer setState(() {
: Theme.of(context).colorScheme.onSecondary, atm.setAction(currentAction, 'manual');
clipBehavior: Clip.antiAlias, });
child: GestureDetector( },
onTap: () { child: Row(children: [
setState(() { Consumer<ActivityTimerModel>(builder: (context, atm, child) {
atm.setAction(currentAction, 'manual'); return Ink(
}); width: 100,
}, padding: const EdgeInsets.all(15),
child: Row(children: [ color: currentAction == atm.currentAction
Consumer<ActivityTimerModel>(builder: (context, atm, child) { ? Theme.of(context).colorScheme.primaryContainer
return Ink( : Theme.of(context).colorScheme.onPrimary,
child: Text('Set ${index + 1} '));
}),
Expanded(
child: Ink(
padding: const EdgeInsets.all(15), padding: const EdgeInsets.all(15),
color: currentAction == atm.currentAction color: currentAction == atm.currentAction
? Theme.of(context).colorScheme.onPrimary ? Theme.of(context).colorScheme.surfaceBright
: Theme.of(context).colorScheme.primaryContainer, : Theme.of(context).colorScheme.surfaceContainerLow,
child: Text('Set: ${index + 1} ')); child: Text(
}), textAlign: TextAlign.center,
Expanded( '$title: ${setReps.amounts[index]} ${atm.setType}')))
child: Text( ])),
textAlign: TextAlign.center, GestureDetector(
'$title: ${setReps.amounts[index]} reps')) onTap: () {
])))); setState(() {
actionCount++; atm.setAction(currentAction + 1, 'manual');
});
contents.add(Card( },
color: currentAction + 1 == atm.currentAction child: Row(children: [
? Theme.of(context).colorScheme.secondaryContainer Consumer<ActivityTimerModel>(builder: (context, atm, child) {
: Theme.of(context).colorScheme.onSecondary, return Ink(
clipBehavior: Clip.antiAlias, width: 100,
child: GestureDetector( padding: const EdgeInsets.all(15),
onTap: () { color: currentAction + 1 == atm.currentAction
setState(() { ? Theme.of(context).colorScheme.primaryContainer
atm.setAction(currentAction + 1, 'manual'); : Theme.of(context).colorScheme.onPrimary,
}); child: Text('Rest ${index + 1}'));
}, }),
child: Row(children: [ Expanded(
Consumer<ActivityTimerModel>(builder: (context, atm, child) { child: Ink(
return Ink(
padding: const EdgeInsets.all(15), padding: const EdgeInsets.all(15),
color: currentAction + 1 == atm.currentAction color: currentAction + 1 == atm.currentAction
? Theme.of(context).colorScheme.onPrimary ? Theme.of(context).colorScheme.surfaceBright
: Theme.of(context).colorScheme.primaryContainer, : Theme.of(context).colorScheme.surfaceContainerLow,
child: Text('Set: ${index + 1} ')); child: Text(
}), textAlign: TextAlign.center,
Expanded( 'Rest: $setRest seconds')))
child: Text( ])),
textAlign: TextAlign.center, ]);
'Rest: $setRest seconds'))
]))));
actionCount++;
return Column(children: contents); // if (actionSet.type == 'alternating') {
// actionCount = actionCount + 2;
// content.addAll([
// GestureDetector(
// onTap: () {
// setState(() {
// atm.setAction(currentAction + 2, 'manual');
// });
// },
// child: Row(children: [
// Consumer<ActivityTimerModel>(builder: (context, atm, child) {
// return Ink(
// padding: const EdgeInsets.all(15),
// color: currentAction + 2 == atm.currentAction
// ? Theme.of(context).colorScheme.onPrimary
// : Theme.of(context).colorScheme.primaryContainer,
// child: Text('Set: ${index + 1} '));
// }),
// Expanded(
// child: Ink(
// padding: const EdgeInsets.all(15),
// color: currentAction + 2 == atm.currentAction
// ? Theme.of(context).colorScheme.onSecondary
// : Theme.of(context)
// .colorScheme
// .surfaceContainerLow,
// child: Text(
// textAlign: TextAlign.center,
// '$title: ${setReps.amounts[index]} ${atm.setType}')))
// ])),
// GestureDetector(
// onTap: () {
// setState(() {
// atm.setAction(currentAction + 3, 'manual');
// });
// },
// child: Row(children: [
// Consumer<ActivityTimerModel>(builder: (context, atm, child) {
// return Ink(
// padding: const EdgeInsets.all(15),
// color: currentAction + 3 == atm.currentAction
// ? Theme.of(context).colorScheme.onPrimary
// : Theme.of(context).colorScheme.primaryContainer,
// child: Text('Set: ${index + 1} '));
// }),
// Expanded(
// child: Ink(
// padding: const EdgeInsets.all(15),
// color: currentAction + 3 == atm.currentAction
// ? Theme.of(context).colorScheme.onSecondary
// : Theme.of(context)
// .colorScheme
// .surfaceContainerLow,
// child: Text(
// textAlign: TextAlign.center,
// 'Rest: $setRest seconds')))
// ])),
// ]);
// }
return Card(
clipBehavior: Clip.antiAlias, child: Column(children: content));
// return Column(children: contents);
}, },
)); ));
} }

View File

@ -88,21 +88,21 @@ class _ActivityViewState extends State<ActivityView> {
child: Consumer<ActivityTimerModel>( child: Consumer<ActivityTimerModel>(
builder: (context, atm, child) { builder: (context, atm, child) {
return Text( return Text(
style: const TextStyle(fontSize: 25), style: const TextStyle(fontSize: 20),
textAlign: TextAlign.center, textAlign: TextAlign.center,
'${atm.tickCount}'); '${atm.tickCount} ${atm.actionState()}');
}, },
)), )),
Expanded( Expanded(
flex: 1, flex: 1,
child: Padding( child: Padding(
padding: const EdgeInsets.only(right: 10), padding: const EdgeInsets.only(right: 15),
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.right,
"${atm.actionType}"); '${atm.currentAction + 1}: ${atm.actionType}');
// 'Set: ${atm.currentSet + 1}/${atm.totalSets}\nRep: ${atm.currentRep + 1}/${atm.totalReps}'); // 'Set: ${atm.currentSet + 1}/${atm.totalSets}\nRep: ${atm.currentRep + 1}/${atm.totalReps}');
}))), }))),
])) ]))

View File

@ -59,10 +59,10 @@ class SessionCard extends StatelessWidget {
total: 3, total: 3,
rest: 300000, rest: 300000,
reps: Reps( reps: Reps(
type: 'count', type: 'repititions',
tempo: [2, 3, 5], tempo: [0],
amounts: [5, 3, 2], amounts: [1, 1, 1],
weights: [50, 70, 80], weights: [0],
rest: 20000))), rest: 20000))),
], ],
resources: ['https://www.youtube.com/watch?v=bLz0xp1PEm4']), resources: ['https://www.youtube.com/watch?v=bLz0xp1PEm4']),
@ -96,46 +96,46 @@ class SessionCard extends StatelessWidget {
total: 10, total: 10,
rest: 300000, rest: 300000,
reps: Reps( reps: Reps(
type: 'count', type: 'repititions',
tempo: [], tempo: [0],
amounts: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], amounts: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
weights: [], weights: [0],
rest: 0))), rest: 0))),
], ],
resources: ['https://www.youtube.com/watch?v=dyAvbUvY_PU']), resources: ['https://www.youtube.com/watch?v=dyAvbUvY_PU']),
ActivityModel( ActivityModel(
id: 3, id: 3,
title: 'Weighted Pull Ups', title: 'Long Block Pulls',
type: 'fundamental', type: 'Hypertrophy',
categories: ['Strength', 'Power'], categories: ['Strength', 'Power'],
description: description:
"Weight pullups to increase strength and maximal pulling force.", "Block pull on a edge of a specific size and time to induce a hypotrophic effect on the formarms.",
actions: [ actions: [
ActivityAction( ActivityAction(
id: 1, id: 1,
title: 'Pull Ups', title: 'Long Pulls',
description: 'Select your desired weight to add, and pull up. Be sure to fully drop into extension at start, and make sure chin is above bar for a complete rep. Do not kip during the movement.', description: 'Select your desired weight to pull, add it to the block. You should aim for an effort level of 8-9 when reaching the end of the set time, going to failure will result in significantly extended recovery time.',
media: [ media: [
Media( Media(
id: 1, id: 1,
reference: reference:
'https://trainingforclimbing.com/wp-content/uploads/2016/03/hypergravity_pull-up-compress3-966x1024.jpg', 'https://trailandcrag.com/sites/default/files/inline-images/05-min_3.jpg',
type: 'image', type: 'image',
description: 'Weighted Pullups'), description: 'Block pull example'),
Media( Media(
id: 1, id: 1,
reference: '7TLG1mHQHgw', reference: 'sZVAEy9UmoY',
type: 'youtube', type: 'youtube',
description: 'How to do weighted pullups') description: 'Principals of Grip gains, and related protocols')
], ],
activityActionSet: Set( activityActionSet: Set(
type: 'drop_set', type: 'alternating',
total: 5, total: 5,
rest: 300000, rest: 300000,
reps: Reps( reps: Reps(
type: 'count', type: 'seconds',
tempo: [], tempo: [0],
amounts: [3, 5, 5, 3, 6], amounts: [60, 60, 60, 60, 60],
weights: [80, 80, 80, 80, 80], weights: [80, 80, 80, 80, 80],
rest: 0))), rest: 0))),
], ],