161 lines
6.7 KiB
Dart
161 lines
6.7 KiB
Dart
import 'dart:async';
|
|
import 'dart:developer';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:sendtrain/classes/activity_action.dart';
|
|
import 'package:sendtrain/models/activity_timer_model.dart';
|
|
import 'package:sendtrain/widgets/action_card.dart';
|
|
|
|
class ActivityActionView extends StatefulWidget {
|
|
ActivityActionView({super.key, required this.action});
|
|
ActivityAction action;
|
|
|
|
@override
|
|
State<ActivityActionView> createState() => ActivityActionViewState();
|
|
}
|
|
|
|
class ActivityActionViewState extends State<ActivityActionView> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
int actionCount = 0;
|
|
ActivityTimerModel atm =
|
|
Provider.of<ActivityTimerModel>(context, listen: true);
|
|
|
|
return Expanded(
|
|
child: ListView.builder(
|
|
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;
|
|
int currentAction = actionCount;
|
|
List<GestureDetector> content = [];
|
|
|
|
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.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.surfaceBright
|
|
: Theme.of(context).colorScheme.surfaceContainerLow,
|
|
child: Text(
|
|
textAlign: TextAlign.center,
|
|
'Rest: $setRest seconds')))
|
|
])),
|
|
]);
|
|
|
|
// 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);
|
|
},
|
|
));
|
|
}
|
|
}
|