98 lines
3.7 KiB
Dart
98 lines
3.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, 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,
|
|
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(
|
|
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(
|
|
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++;
|
|
|
|
return Column(children: contents);
|
|
},
|
|
));
|
|
}
|
|
}
|