From d42696df616878de7d41d89d42362721c5334469 Mon Sep 17 00:00:00 2001 From: Joshua Burman Date: Sat, 30 Nov 2024 12:37:38 -0500 Subject: [PATCH] show rep and set counts --- lib/screens/activities_screen.dart | 4 ++-- lib/widgets/activity_view.dart | 34 ++++++++++++++++++++++++------ lib/widgets/session_card.dart | 12 +++++------ 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/lib/screens/activities_screen.dart b/lib/screens/activities_screen.dart index 2beb613..1e73c57 100644 --- a/lib/screens/activities_screen.dart +++ b/lib/screens/activities_screen.dart @@ -29,13 +29,13 @@ class _ActivitiesScreenState extends State { activityActionSet: Set( type: 'drop_set', total: 3, - rest: 3000, + rest: 300000, reps: Reps( type: 'count', tempo: [2, 3, 5], amounts: [5, 3, 2], weights: [50, 70, 80], - rest: 200))), + rest: 20000))), )); @override diff --git a/lib/widgets/activity_view.dart b/lib/widgets/activity_view.dart index 28f4f7a..e03f18b 100644 --- a/lib/widgets/activity_view.dart +++ b/lib/widgets/activity_view.dart @@ -19,14 +19,34 @@ class ActivityView extends StatefulWidget { class _ActivityViewState extends State { Timer? _periodicTimer; int _tickCount = 0; - int currentSet = 0; - int currentRep = 0; + int _currentSet = 1; + int _currentRep = 1; + String _currentState = 'Rep'; void _startPeriodicTimer() { + _tickCount = widget.activity.actions[0].activityActionSet.rest ~/ 10000; const oneSecond = Duration(seconds: 1); _periodicTimer = Timer.periodic(oneSecond, (Timer timer) { setState(() { - _tickCount++; + if (_tickCount == 0) { + if (_currentSet == + widget.activity.actions[0].activityActionSet.total) { + timer.cancel(); + } + + if (_currentRep == + widget.activity.actions[0].activityActionSet.reps + .amounts[_currentSet]) { + _currentSet++; + _currentRep = 1; + _tickCount = + widget.activity.actions[0].activityActionSet.rest ~/ 10000; + } else { + _currentRep++; + } + } else { + _tickCount--; + } }); }); } @@ -94,14 +114,14 @@ class _ActivityViewState extends State { textAlign: TextAlign.center, '$_tickCount'), ), - const Expanded( + Expanded( flex: 1, child: Padding( - padding: EdgeInsets.only(right: 10), + padding: const EdgeInsets.only(right: 10), child: Text( - style: TextStyle(fontSize: 15), + style: const TextStyle(fontSize: 15), textAlign: TextAlign.right, - 'Set: 1/3 \nRep: 1/5'))), + 'Set: $_currentSet/3 \nRep: $_currentRep/5'))), ]))); return Column( crossAxisAlignment: CrossAxisAlignment.start, children: content); diff --git a/lib/widgets/session_card.dart b/lib/widgets/session_card.dart index ba2eb46..70cdff3 100644 --- a/lib/widgets/session_card.dart +++ b/lib/widgets/session_card.dart @@ -57,13 +57,13 @@ class SessionCard extends StatelessWidget { activityActionSet: Set( type: 'drop_set', total: 3, - rest: 3000, + rest: 300000, reps: Reps( type: 'count', tempo: [2, 3, 5], amounts: [5, 3, 2], weights: [50, 70, 80], - rest: 200))), + rest: 20000))), ], resources: ['https://www.youtube.com/watch?v=bLz0xp1PEm4']), ActivityModel( @@ -94,13 +94,13 @@ class SessionCard extends StatelessWidget { activityActionSet: Set( type: 'drop_set', total: 3, - rest: 3000, + rest: 300000, reps: Reps( type: 'count', tempo: [2, 3, 5], amounts: [5, 3, 2], weights: [50, 70, 80], - rest: 200))), + rest: 20000))), ], resources: ['https://www.youtube.com/watch?v=dyAvbUvY_PU']), ActivityModel( @@ -131,13 +131,13 @@ class SessionCard extends StatelessWidget { activityActionSet: Set( type: 'drop_set', total: 3, - rest: 3000, + rest: 300000, reps: Reps( type: 'count', tempo: [2, 3, 5], amounts: [5, 3, 2], weights: [50, 70, 80], - rest: 200))), + rest: 20000))), ], resources: ['https://www.youtube.com/watch?v=dyAvbUvY_PU']), ],