113 lines
3.9 KiB
Dart
113 lines
3.9 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;
|
|
// ActivityTimerModel activityTimerModel;
|
|
// get incrementActivity => ActivityActionViewState().incrementActivity();
|
|
|
|
@override
|
|
State<ActivityActionView> createState() => ActivityActionViewState();
|
|
// void incrementActivity() => _ActivityActionViewState().incrementActivity();
|
|
}
|
|
|
|
class ActivityActionViewState extends State<ActivityActionView> {
|
|
int _index = 0;
|
|
int _currentAction = 0;
|
|
// int _actionCount = 0;
|
|
// int _currentState = "Active"
|
|
|
|
// void incrementActivity(int actionNum) {
|
|
// setState(() {
|
|
// atm.setAction(actionNum);
|
|
// });
|
|
// }
|
|
|
|
// void setActivity(int currentAction) {
|
|
// setState(() {
|
|
// widget.atm.setAction(currentAction);
|
|
// });
|
|
// }
|
|
|
|
@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, 10, 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;
|
|
|
|
contents.add(Card(
|
|
elevation: 0.5,
|
|
// surfaceTintColor: actionCount == _index ? Colors.white : ,
|
|
clipBehavior: Clip.antiAlias,
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
log('we tappn');
|
|
setState(() {
|
|
atm.setAction(currentAction, index, "rep");
|
|
});
|
|
},
|
|
child: Row(children: [
|
|
Consumer<ActivityTimerModel>(builder: (context, atm, child) {
|
|
return Ink(
|
|
padding: const EdgeInsets.all(15),
|
|
color: currentAction == atm.currentAction
|
|
? const Color.fromARGB(255, 49, 154, 52)
|
|
: const Color(0xff3A5FB6),
|
|
child: Text('Set: ${index + 1} '));
|
|
}),
|
|
Expanded(
|
|
child: Text(
|
|
textAlign: TextAlign.center,
|
|
'$title: ${setReps.amounts[index]} reps'))
|
|
]))));
|
|
actionCount++;
|
|
|
|
contents.add(Card(
|
|
clipBehavior: Clip.antiAlias,
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
setState(() {
|
|
atm.setAction(currentAction + 1, index, "rest");
|
|
});
|
|
},
|
|
child: Row(children: [
|
|
Consumer<ActivityTimerModel>(builder: (context, atm, child) {
|
|
return Ink(
|
|
padding: const EdgeInsets.all(15),
|
|
color: currentAction + 1 == atm.currentAction
|
|
? const Color.fromARGB(255, 49, 154, 52)
|
|
: const Color(0xff3A5FB6),
|
|
child: Text('Set: ${index + 1} '));
|
|
}),
|
|
Expanded(
|
|
child: Text(
|
|
textAlign: TextAlign.center,
|
|
'Rest: $setRest seconds'))
|
|
]))));
|
|
actionCount++;
|
|
|
|
return Column(children: contents);
|
|
},
|
|
));
|
|
}
|
|
}
|