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

View File

@ -24,73 +24,136 @@ class ActivityActionViewState extends State<ActivityActionView> {
return Expanded(
child: ListView.builder(
padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
padding: const EdgeInsets.fromLTRB(10, 0, 20, 0),
itemCount: widget.action.activityActionSet.total,
itemBuilder: (BuildContext context, int index) {
String title = widget.action.title;
Set actionSet = widget.action.activityActionSet;
Reps setReps = actionSet.reps;
int setRest = actionSet.rest ~/ 1000;
List<Card> contents = [];
int currentAction = actionCount;
List<GestureDetector> content = [];
contents.add(Card(
elevation: 0.5,
shadowColor: Theme.of(context).colorScheme.shadow,
color: currentAction == atm.currentAction
? Theme.of(context).colorScheme.secondaryContainer
: Theme.of(context).colorScheme.onSecondary,
clipBehavior: Clip.antiAlias,
child: GestureDetector(
onTap: () {
setState(() {
atm.setAction(currentAction, 'manual');
});
},
child: Row(children: [
Consumer<ActivityTimerModel>(builder: (context, atm, child) {
return Ink(
actionCount = actionCount + 2;
content.addAll([
GestureDetector(
onTap: () {
setState(() {
atm.setAction(currentAction, 'manual');
});
},
child: Row(children: [
Consumer<ActivityTimerModel>(builder: (context, atm, child) {
return Ink(
width: 100,
padding: const EdgeInsets.all(15),
color: currentAction == atm.currentAction
? Theme.of(context).colorScheme.primaryContainer
: Theme.of(context).colorScheme.onPrimary,
child: Text('Set ${index + 1} '));
}),
Expanded(
child: Ink(
padding: const EdgeInsets.all(15),
color: currentAction == atm.currentAction
? Theme.of(context).colorScheme.onPrimary
: Theme.of(context).colorScheme.primaryContainer,
child: Text('Set: ${index + 1} '));
}),
Expanded(
child: Text(
textAlign: TextAlign.center,
'$title: ${setReps.amounts[index]} reps'))
]))));
actionCount++;
contents.add(Card(
color: currentAction + 1 == atm.currentAction
? Theme.of(context).colorScheme.secondaryContainer
: Theme.of(context).colorScheme.onSecondary,
clipBehavior: Clip.antiAlias,
child: GestureDetector(
onTap: () {
setState(() {
atm.setAction(currentAction + 1, 'manual');
});
},
child: Row(children: [
Consumer<ActivityTimerModel>(builder: (context, atm, child) {
return Ink(
? Theme.of(context).colorScheme.surfaceBright
: Theme.of(context).colorScheme.surfaceContainerLow,
child: Text(
textAlign: TextAlign.center,
'$title: ${setReps.amounts[index]} ${atm.setType}')))
])),
GestureDetector(
onTap: () {
setState(() {
atm.setAction(currentAction + 1, 'manual');
});
},
child: Row(children: [
Consumer<ActivityTimerModel>(builder: (context, atm, child) {
return Ink(
width: 100,
padding: const EdgeInsets.all(15),
color: currentAction + 1 == atm.currentAction
? Theme.of(context).colorScheme.primaryContainer
: Theme.of(context).colorScheme.onPrimary,
child: Text('Rest ${index + 1}'));
}),
Expanded(
child: Ink(
padding: const EdgeInsets.all(15),
color: currentAction + 1 == atm.currentAction
? Theme.of(context).colorScheme.onPrimary
: Theme.of(context).colorScheme.primaryContainer,
child: Text('Set: ${index + 1} '));
}),
Expanded(
child: Text(
textAlign: TextAlign.center,
'Rest: $setRest seconds'))
]))));
actionCount++;
? Theme.of(context).colorScheme.surfaceBright
: Theme.of(context).colorScheme.surfaceContainerLow,
child: Text(
textAlign: TextAlign.center,
'Rest: $setRest seconds')))
])),
]);
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>(
builder: (context, atm, child) {
return Text(
style: const TextStyle(fontSize: 25),
style: const TextStyle(fontSize: 20),
textAlign: TextAlign.center,
'${atm.tickCount}');
'${atm.tickCount} ${atm.actionState()}');
},
)),
Expanded(
flex: 1,
child: Padding(
padding: const EdgeInsets.only(right: 10),
padding: const EdgeInsets.only(right: 15),
child: Consumer<ActivityTimerModel>(
builder: (context, atm, child) {
return Text(
style: const TextStyle(fontSize: 20),
textAlign: TextAlign.right,
"${atm.actionType}");
'${atm.currentAction + 1}: ${atm.actionType}');
// 'Set: ${atm.currentSet + 1}/${atm.totalSets}\nRep: ${atm.currentRep + 1}/${atm.totalReps}');
}))),
]))

View File

@ -59,10 +59,10 @@ class SessionCard extends StatelessWidget {
total: 3,
rest: 300000,
reps: Reps(
type: 'count',
tempo: [2, 3, 5],
amounts: [5, 3, 2],
weights: [50, 70, 80],
type: 'repititions',
tempo: [0],
amounts: [1, 1, 1],
weights: [0],
rest: 20000))),
],
resources: ['https://www.youtube.com/watch?v=bLz0xp1PEm4']),
@ -96,46 +96,46 @@ class SessionCard extends StatelessWidget {
total: 10,
rest: 300000,
reps: Reps(
type: 'count',
tempo: [],
type: 'repititions',
tempo: [0],
amounts: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
weights: [],
weights: [0],
rest: 0))),
],
resources: ['https://www.youtube.com/watch?v=dyAvbUvY_PU']),
ActivityModel(
id: 3,
title: 'Weighted Pull Ups',
type: 'fundamental',
title: 'Long Block Pulls',
type: 'Hypertrophy',
categories: ['Strength', 'Power'],
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: [
ActivityAction(
id: 1,
title: 'Pull Ups',
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.',
title: 'Long Pulls',
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(
id: 1,
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',
description: 'Weighted Pullups'),
description: 'Block pull example'),
Media(
id: 1,
reference: '7TLG1mHQHgw',
reference: 'sZVAEy9UmoY',
type: 'youtube',
description: 'How to do weighted pullups')
description: 'Principals of Grip gains, and related protocols')
],
activityActionSet: Set(
type: 'drop_set',
type: 'alternating',
total: 5,
rest: 300000,
reps: Reps(
type: 'count',
tempo: [],
amounts: [3, 5, 5, 3, 6],
type: 'seconds',
tempo: [0],
amounts: [60, 60, 60, 60, 60],
weights: [80, 80, 80, 80, 80],
rest: 0))),
],