From bca7180064b25b8fea8099b9e2ee74454726c94a Mon Sep 17 00:00:00 2001 From: a-mabe Date: Sun, 11 Feb 2024 19:52:12 -0500 Subject: [PATCH 01/26] Implement full workout Full workout includes Get ready, warm-up, work/rest, break between iterations, and cooldown --- ios/Podfile | 2 +- ios/Podfile.lock | 18 +- .../constants/set_timings_constants.dart | 92 ++ .../{data => constants}/sound_name_map.dart | 0 .../{data => constants}/sounds.dart | 0 lib/create_workout/create_timer.dart | 9 +- lib/create_workout/create_workout.dart | 7 +- .../helper_widgets/create_form.dart | 43 +- .../expansion_additional_config_tile.dart | 74 ++ .../helper_widgets/list_time_tile.dart | 36 + .../helper_widgets/number_input.dart | 116 +- .../helper_widgets/sound_dropdown.dart | 2 +- .../helper_widgets/time_input_trailing.dart | 103 ++ .../helper_widgets/time_list_item.dart | 46 + lib/create_workout/select_timer.dart | 2 +- lib/create_workout/set_sounds.dart | 2 +- lib/create_workout/set_timings.dart | 1046 +++++++++++++---- .../utils/set_timings_utils.dart | 15 + lib/database/database_manager.dart | 67 +- lib/helper_widgets/timer_list_tile.dart | 4 +- lib/main.dart | 4 +- lib/start_workout/view_workout.dart | 12 +- lib/start_workout/workout.dart | 45 +- .../functions.dart | 121 +- lib/workout_data_type/workout_type.dart | 116 +- pubspec.lock | 32 +- pubspec.yaml | 3 +- 27 files changed, 1524 insertions(+), 493 deletions(-) create mode 100644 lib/create_workout/constants/set_timings_constants.dart rename lib/create_workout/{data => constants}/sound_name_map.dart (100%) rename lib/create_workout/{data => constants}/sounds.dart (100%) create mode 100644 lib/create_workout/helper_widgets/expansion_additional_config_tile.dart create mode 100644 lib/create_workout/helper_widgets/list_time_tile.dart create mode 100644 lib/create_workout/helper_widgets/time_input_trailing.dart create mode 100644 lib/create_workout/helper_widgets/time_list_item.dart create mode 100644 lib/create_workout/utils/set_timings_utils.dart rename lib/{helper_functions => utils}/functions.dart (60%) diff --git a/ios/Podfile b/ios/Podfile index 2f77e3a0..2e938751 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -# platform :ios, '11.0' +platform :ios, '12.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 0ef23812..4b5088f4 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -12,9 +12,6 @@ PODS: - Flutter - flutter_local_notifications (0.0.1): - Flutter - - FMDB (2.7.5): - - FMDB/standard (= 2.7.5) - - FMDB/standard (2.7.5) - just_audio (0.0.1): - Flutter - path_provider_foundation (0.0.1): @@ -27,7 +24,7 @@ PODS: - Flutter - sqflite (0.0.3): - Flutter - - FMDB (>= 2.7.5) + - FlutterMacOS - wakelock (0.0.1): - Flutter @@ -43,13 +40,9 @@ DEPENDENCIES: - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`) - soundpool (from `.symlinks/plugins/soundpool/ios`) - - sqflite (from `.symlinks/plugins/sqflite/ios`) + - sqflite (from `.symlinks/plugins/sqflite/darwin`) - wakelock (from `.symlinks/plugins/wakelock/ios`) -SPEC REPOS: - trunk: - - FMDB - EXTERNAL SOURCES: audio_session: :path: ".symlinks/plugins/audio_session/ios" @@ -74,7 +67,7 @@ EXTERNAL SOURCES: soundpool: :path: ".symlinks/plugins/soundpool/ios" sqflite: - :path: ".symlinks/plugins/sqflite/ios" + :path: ".symlinks/plugins/sqflite/darwin" wakelock: :path: ".symlinks/plugins/wakelock/ios" @@ -86,14 +79,13 @@ SPEC CHECKSUMS: flutter_background_service_ios: e30e0d3ee69e4cee66272d0c78eacd48c2e94aac flutter_fgbg: 31c0d1140a131daea2d342121808f6aa0dcd879d flutter_local_notifications: 0c0b1ae97e741e1521e4c1629a459d04b9aec743 - FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a just_audio: baa7252489dbcf47a4c7cc9ca663e9661c99aafa path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695 soundpool: c7f4422ca206e77f8900ed3c4ee6a6ff5a0e38a9 - sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a + sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec wakelock: d0fc7c864128eac40eba1617cb5264d9c940b46f -PODFILE CHECKSUM: 94b700da46e2c82b6cf27a42198057964de975ce +PODFILE CHECKSUM: a74b8704f768957a23e2d804b55390ecc9fffc9d COCOAPODS: 1.12.1 diff --git a/lib/create_workout/constants/set_timings_constants.dart b/lib/create_workout/constants/set_timings_constants.dart new file mode 100644 index 00000000..2fe8c419 --- /dev/null +++ b/lib/create_workout/constants/set_timings_constants.dart @@ -0,0 +1,92 @@ +import 'package:flutter/material.dart'; + +const String workTitle = "Work"; +const String restTitle = "Rest"; +const String additionalConfigTitle = "Additional configuration"; +const String getReadyTitle = "Get ready"; +const String warmUpTitle = "Warm-up"; +const String coolDownTitle = "Cool down"; +const String repeatTitle = "Repeat"; +const String breakTitle = "Break"; + +const String workMinutesKey = "work-minutes"; +const String workSecondsKey = "work-seconds"; + +const String restMinutesKey = "rest-minutes"; +const String restSecondsKey = "rest-seconds"; + +const String warmupMinutesKey = "warmup-minutes"; +const String warmupSecondsKey = "warmup-seconds"; + +const String cooldownMinutesKey = "cooldown-minutes"; +const String cooldownSecondsKey = "cooldown-seconds"; + +const String iterationsKey = "iterations"; + +const String breakMinutesKey = "break-minutes"; +const String breakSecondsKey = "break-seconds"; + +const String getReadyMinutesKey = "get-ready-minutes"; +const String getReadySecondsKey = "get-ready-seconds"; + +const List timeMinutesKeys = [ + workMinutesKey, + restMinutesKey, +]; + +const List timeSecondsKeys = [ + workSecondsKey, + restSecondsKey, +]; + +const List additionalMinutesKeys = [ + getReadyMinutesKey, + warmupMinutesKey, + cooldownMinutesKey, + breakMinutesKey +]; + +const List additionalSecondsKeys = [ + getReadySecondsKey, + warmupSecondsKey, + cooldownSecondsKey, + breakSecondsKey +]; + +const List timeTitles = [workTitle, restTitle, additionalConfigTitle]; + +const List additionalTimeTitles = [ + getReadyTitle, + warmUpTitle, + coolDownTitle, + repeatTitle, + breakTitle +]; + +const List timeSubTitles = [ + "Required", + "Required", + "Warmup, auto restart, and more" +]; + +const List additionalTimeSubTitles = [ + "Optional, default 10s", + "Optional", + "Optional", + "Auto restart", + "Optional, between restarts" +]; + +const List timeLeadingIcons = [ + Icon(Icons.fitness_center), + Icon(Icons.pause), + Icon(Icons.tune) +]; + +const List additionalTimeLeadingIcons = [ + Icon(Icons.flag), + Icon(Icons.emoji_people), + Icon(Icons.ac_unit), + Icon(Icons.replay), + Icon(Icons.snooze) +]; diff --git a/lib/create_workout/data/sound_name_map.dart b/lib/create_workout/constants/sound_name_map.dart similarity index 100% rename from lib/create_workout/data/sound_name_map.dart rename to lib/create_workout/constants/sound_name_map.dart diff --git a/lib/create_workout/data/sounds.dart b/lib/create_workout/constants/sounds.dart similarity index 100% rename from lib/create_workout/data/sounds.dart rename to lib/create_workout/constants/sounds.dart diff --git a/lib/create_workout/create_timer.dart b/lib/create_workout/create_timer.dart index 47bad282..5940f635 100644 --- a/lib/create_workout/create_timer.dart +++ b/lib/create_workout/create_timer.dart @@ -23,9 +23,14 @@ class CreateTimerState extends State { workout.title, workout.numExercises, workout.exercises, - workout.exerciseTime, + workout.getReadyTime, + workout.workTime, workout.restTime, workout.halfTime, + workout.breakTime, + workout.warmupTime, + workout.cooldownTime, + workout.iterations, workout.halfwayMark, workout.workSound, workout.restSound, @@ -78,7 +83,7 @@ class CreateTimerState extends State { ), bottomSheet: SubmitButton( text: "Submit", - color: const Color.fromARGB(255,58,165,255), + color: const Color.fromARGB(255, 58, 165, 255), onTap: () { submitForm(workoutCopy); }, diff --git a/lib/create_workout/create_workout.dart b/lib/create_workout/create_workout.dart index d39fe75c..8f4d39d8 100644 --- a/lib/create_workout/create_workout.dart +++ b/lib/create_workout/create_workout.dart @@ -24,9 +24,14 @@ class CreateWorkoutState extends State { workout.title, workout.numExercises, workout.exercises, - workout.exerciseTime, + workout.getReadyTime, + workout.workTime, workout.restTime, workout.halfTime, + workout.breakTime, + workout.warmupTime, + workout.cooldownTime, + workout.iterations, workout.halfwayMark, workout.workSound, workout.restSound, diff --git a/lib/create_workout/helper_widgets/create_form.dart b/lib/create_workout/helper_widgets/create_form.dart index 8527dfa8..d2047af0 100644 --- a/lib/create_workout/helper_widgets/create_form.dart +++ b/lib/create_workout/helper_widgets/create_form.dart @@ -151,24 +151,31 @@ class CreateFormState extends State { fontSize: 30)), ), ), - NumberInput( - numberInputKey: const Key('interval-input'), - numberValue: widget.workout.numExercises, - formatter: (value) { - return value; - }, - validator: (value) { - if (value == null || value.isEmpty) { - return 'Enter intervals'; - } - return null; - }, - onSaved: (String? val) { - widget.workout.numExercises = int.parse(val!); - }, - unit: "intervals", - min: 1, - max: 999), + Align( + alignment: Alignment.center, + child: NumberInput( + widgetWidth: 140, + numberInputKey: const Key('interval-input'), + numberValue: widget.workout.numExercises == 0 + ? -1 + : widget.workout.numExercises, + formatter: (value) { + return value; + }, + validator: (value) { + if (value == null || value.isEmpty) { + return 'Enter intervals'; + } + return null; + }, + onSaved: (String? val) { + widget.workout.numExercises = int.parse(val!); + }, + onChanged: (text) {}, + unit: "intervals", + min: 1, + max: 999), + ), /// Workout/timer timer display /// diff --git a/lib/create_workout/helper_widgets/expansion_additional_config_tile.dart b/lib/create_workout/helper_widgets/expansion_additional_config_tile.dart new file mode 100644 index 00000000..00f2a2b2 --- /dev/null +++ b/lib/create_workout/helper_widgets/expansion_additional_config_tile.dart @@ -0,0 +1,74 @@ +import 'package:flutter/material.dart'; +import 'package:openhiit/create_workout/constants/set_timings_constants.dart'; + +class ExpansionRepeatTileClass extends StatefulWidget { + /// Vars + + final Widget? trailingWidget; + + const ExpansionRepeatTileClass({ + this.trailingWidget, + super.key, + }); + + @override + ExpansionRepeatTileClassState createState() => + ExpansionRepeatTileClassState(); +} + +class ExpansionRepeatTileClassState extends State { + @override + void initState() { + super.initState(); + } + + @override + void dispose() { + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return ExpansionTile( + title: Text('Additional configuration'), + subtitle: Text('Auto restart, warm-up, and more'), + leading: Icon(Icons.tune), + children: [ + ListTile( + title: Text(additionalTimeTitles[0]), + subtitle: Text(additionalTimeSubTitles[0]), + leading: Icon(Icons.flag), + trailing: widget.trailingWidget, + ), + ListTile( + title: Text(additionalTimeTitles[1]), + subtitle: Text(additionalTimeSubTitles[1]), + leading: Icon(Icons.emoji_people), + trailing: widget.trailingWidget, + ), + ListTile( + title: Text(additionalTimeTitles[2]), + subtitle: Text(additionalTimeSubTitles[2]), + leading: Icon(Icons.ac_unit), + trailing: widget.trailingWidget, + ), + ListTile( + title: Text(additionalTimeTitles[3]), + subtitle: Text(additionalTimeSubTitles[3]), + ), + ListTile( + title: Text(additionalTimeTitles[4]), + subtitle: Text(additionalTimeSubTitles[4]), + leading: Icon(Icons.replay), + trailing: widget.trailingWidget, + ), + ListTile( + title: Text(additionalTimeTitles[5]), + subtitle: Text(additionalTimeSubTitles[5]), + leading: Icon(Icons.block), + trailing: widget.trailingWidget, + ), + ], + ); + } +} diff --git a/lib/create_workout/helper_widgets/list_time_tile.dart b/lib/create_workout/helper_widgets/list_time_tile.dart new file mode 100644 index 00000000..5812c323 --- /dev/null +++ b/lib/create_workout/helper_widgets/list_time_tile.dart @@ -0,0 +1,36 @@ +import 'package:flutter/material.dart'; + +class ListTimeTileClass extends StatefulWidget { + /// Vars + + final String? title; + + final String? subtitle; + + final Widget? leadingWidget; + + final Widget? trailingWidget; + + const ListTimeTileClass({ + this.title, + this.subtitle, + this.leadingWidget, + this.trailingWidget, + super.key, + }); + + @override + ListTimeTileClassState createState() => ListTimeTileClassState(); +} + +class ListTimeTileClassState extends State { + @override + Widget build(BuildContext context) { + return ListTile( + title: Text(widget.title!), + subtitle: Text(widget.subtitle!), + leading: widget.leadingWidget ?? const Text(""), + trailing: widget.trailingWidget ?? const Text(""), + ); + } +} diff --git a/lib/create_workout/helper_widgets/number_input.dart b/lib/create_workout/helper_widgets/number_input.dart index 2889f383..6d0abe02 100644 --- a/lib/create_workout/helper_widgets/number_input.dart +++ b/lib/create_workout/helper_widgets/number_input.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:openhiit/create_workout/constants/set_timings_constants.dart'; import 'numerical_input_formatter.dart'; @@ -8,12 +9,16 @@ class NumberInput extends StatefulWidget { final int numberValue; + final double widgetWidth; + final String unit; final double min; final double max; + final String title; + final Key numberInputKey; final Function formatter; @@ -22,16 +27,22 @@ class NumberInput extends StatefulWidget { final String? Function(String?) validator; - const NumberInput( - {super.key, - required this.numberValue, - required this.formatter, - required this.onSaved, - required this.validator, - required this.unit, - required this.min, - required this.max, - required this.numberInputKey}); + final void Function(String?) onChanged; + + const NumberInput({ + super.key, + required this.numberValue, + required this.widgetWidth, + required this.formatter, + required this.onSaved, + required this.onChanged, + required this.validator, + required this.unit, + required this.min, + required this.max, + required this.numberInputKey, + this.title = "", + }); @override NumberInputState createState() => NumberInputState(); @@ -50,45 +61,50 @@ class NumberInputState extends State { @override Widget build(BuildContext context) { - return Row( - crossAxisAlignment: CrossAxisAlignment.end, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SizedBox( - width: 80, - child: TextFormField( - key: widget.numberInputKey, - initialValue: widget.numberValue == 0 - ? "" - : widget.formatter(widget.numberValue).toString(), - keyboardType: TextInputType.number, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, - NumericalRangeFormatter(min: widget.min, max: widget.max), - ], - textInputAction: TextInputAction.done, - style: const TextStyle(fontSize: 40), - textAlign: TextAlign.center, - maxLength: 3, - decoration: const InputDecoration( - hintText: "00", - errorMaxLines: 2, - border: InputBorder.none, - fillColor: Colors.white, - counterText: "", - contentPadding: EdgeInsets.zero, - ), - validator: widget.validator, - onSaved: widget.onSaved, - )), - Padding( - padding: const EdgeInsets.fromLTRB(0, 0, 0, 3), - child: Text( - widget.unit, - textAlign: TextAlign.left, - style: const TextStyle(color: Colors.grey, fontSize: 25), - )), - ], - ); + return SizedBox( + width: widget.widgetWidth, + // color: Colors.red, + child: Row( + crossAxisAlignment: CrossAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.end, + children: [ + SizedBox( + width: 55, + child: TextFormField( + key: widget.numberInputKey, + initialValue: widget.numberValue == -1 + ? "" + : widget.formatter(widget.numberValue).toString(), + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + NumericalRangeFormatter(min: widget.min, max: widget.max), + ], + textInputAction: TextInputAction.done, + style: const TextStyle(fontSize: 30), + textAlign: TextAlign.center, + maxLength: 3, + decoration: const InputDecoration( + hintText: "00", + errorStyle: TextStyle(height: 0.1, fontSize: 10), + errorMaxLines: 1, + border: InputBorder.none, + fillColor: Colors.white, + counterText: "", + contentPadding: EdgeInsets.zero, + ), + onChanged: widget.onChanged, + validator: widget.validator, + onSaved: widget.onSaved, + )), + Padding( + padding: const EdgeInsets.fromLTRB(0, 0, 0, 3), + child: Text( + widget.unit, + textAlign: TextAlign.left, + style: const TextStyle(color: Colors.grey, fontSize: 18), + )), + ], + )); } } diff --git a/lib/create_workout/helper_widgets/sound_dropdown.dart b/lib/create_workout/helper_widgets/sound_dropdown.dart index 50b6ce17..3755f808 100644 --- a/lib/create_workout/helper_widgets/sound_dropdown.dart +++ b/lib/create_workout/helper_widgets/sound_dropdown.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:soundpool/soundpool.dart'; -import '../data/sound_name_map.dart'; +import '../constants/sound_name_map.dart'; /// Possible interval states // enum IntervalStates { start, work, rest, complete } diff --git a/lib/create_workout/helper_widgets/time_input_trailing.dart b/lib/create_workout/helper_widgets/time_input_trailing.dart new file mode 100644 index 00000000..24009a4e --- /dev/null +++ b/lib/create_workout/helper_widgets/time_input_trailing.dart @@ -0,0 +1,103 @@ +import 'package:flutter/material.dart'; +import 'package:openhiit/create_workout/utils/set_timings_utils.dart'; + +import 'number_input.dart'; + +class TimeInputTrailing extends StatefulWidget { + /// Vars + + final int showMinutes; + final int timeInSeconds; + + final double widgetWidth; + + final String minutesKey; + final String secondsKey; + + final String unit; + + final String title; + + // final Function? minutesFormatter; + // final Function? secondsFormatter; + + final Function(String?)? minutesOnSaved; + final Function(String?)? secondsOnSaved; + + final String? Function(String?)? minutesValidator; + final String? Function(String?)? secondsValidator; + + final void Function(String?)? secondsOnChanged; + + const TimeInputTrailing({ + this.showMinutes = 0, + this.timeInSeconds = 0, + this.widgetWidth = 0, + this.minutesKey = "", + this.secondsKey = "", + this.unit = "", + this.title = "", + this.minutesOnSaved, + this.secondsOnSaved, + this.minutesValidator, + this.secondsValidator, + required this.secondsOnChanged, + super.key, + }); + + @override + TimeInputTrailingState createState() => TimeInputTrailingState(); +} + +class TimeInputTrailingState extends State { + @override + void initState() { + super.initState(); + } + + @override + void dispose() { + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return SizedBox( + width: widget.widgetWidth, + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Visibility( + visible: widget.showMinutes == 1, + child: NumberInput( + widgetWidth: 80, + numberValue: widget.timeInSeconds, + formatter: minutesFormatter, + onSaved: widget.minutesOnSaved!, + onChanged: (text) {}, + validator: widget.minutesValidator!, + unit: "m", + min: 0, + max: 99, + numberInputKey: Key(widget.minutesKey))), + NumberInput( + title: widget.title, + widgetWidth: widget.unit == "time(s)" ? 120 : 70, + numberValue: widget.timeInSeconds, + formatter: widget.showMinutes == 1 + ? secondsRemainderFormatter + : secondsFormatter, + onSaved: widget.secondsOnSaved!, + onChanged: widget.secondsOnChanged!, + validator: widget.secondsValidator!, + unit: widget.unit != "" ? widget.unit : "s", + min: 0, + max: widget.showMinutes == 1 + ? (widget.unit != "" ? 999 : 59) + : 999, + numberInputKey: Key(widget.secondsKey)) + ], + ), + ); + } +} diff --git a/lib/create_workout/helper_widgets/time_list_item.dart b/lib/create_workout/helper_widgets/time_list_item.dart new file mode 100644 index 00000000..957c28d1 --- /dev/null +++ b/lib/create_workout/helper_widgets/time_list_item.dart @@ -0,0 +1,46 @@ +import 'package:flutter/material.dart'; + +class TimeListItem extends StatefulWidget { + /// Vars + + final String titleText; + final String subtitleText; + final bool enabled; + final Widget? leadingWidget; + final Widget? trailingWidget; + + const TimeListItem({ + this.titleText = "", + this.subtitleText = "", + this.enabled = true, + this.leadingWidget, + this.trailingWidget, + super.key, + }); + + @override + TimeListItemState createState() => TimeListItemState(); +} + +class TimeListItemState extends State { + @override + void initState() { + super.initState(); + } + + @override + void dispose() { + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return ListTile( + title: Text(widget.titleText), + subtitle: Text(widget.subtitleText), + leading: widget.leadingWidget ?? const Text(""), + trailing: widget.trailingWidget ?? const Text(""), + enabled: widget.enabled, + ); + } +} diff --git a/lib/create_workout/select_timer.dart b/lib/create_workout/select_timer.dart index 993643dd..f12b5284 100644 --- a/lib/create_workout/select_timer.dart +++ b/lib/create_workout/select_timer.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import '../helper_functions/functions.dart'; +import '../utils/functions.dart'; import '../workout_data_type/workout_type.dart'; import './helper_widgets/timer_option_card.dart'; diff --git a/lib/create_workout/set_sounds.dart b/lib/create_workout/set_sounds.dart index 8f5ef598..8daaac30 100644 --- a/lib/create_workout/set_sounds.dart +++ b/lib/create_workout/set_sounds.dart @@ -8,7 +8,7 @@ import '../workout_data_type/workout_type.dart'; import '../database/database_manager.dart'; import './helper_widgets/sound_dropdown.dart'; import './helper_widgets/submit_button.dart'; -import './data/sounds.dart'; +import 'constants/sounds.dart'; List allSounds = soundsList + countdownSounds; diff --git a/lib/create_workout/set_timings.dart b/lib/create_workout/set_timings.dart index 074d880b..e1111a71 100644 --- a/lib/create_workout/set_timings.dart +++ b/lib/create_workout/set_timings.dart @@ -1,9 +1,15 @@ -import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; +import 'package:logger/logger.dart'; +import 'package:openhiit/create_workout/constants/set_timings_constants.dart'; +import 'package:openhiit/create_workout/helper_widgets/time_input_trailing.dart'; import '../workout_data_type/workout_type.dart'; -import './set_sounds.dart'; -import 'helper_widgets/number_input.dart'; import 'helper_widgets/submit_button.dart'; +import 'helper_widgets/time_list_item.dart'; +import 'set_sounds.dart'; + +var logger = Logger( + printer: PrettyPrinter(methodCount: 0), +); class SetTimings extends StatefulWidget { const SetTimings({super.key}); @@ -15,297 +21,819 @@ class SetTimings extends StatefulWidget { // Define a corresponding State class. // This class holds the data related to the Form. class _SetTimingsState extends State { - /// The global key for the form. - /// - final formKey = GlobalKey(); + Map timeMap = { + "Work-minutes": 0, + "Work-seconds": 0, + "Rest-minutes": 0, + "Rest-seconds": 0, + "Warm-up-minutes": 0, + "Warm-up-seconds": 0, + "Cool down-minutes": 0, + "Cool down-seconds": 0, + "Break-minutes": 0, + "Break-seconds": 0, + "Get ready-minutes": 0, + "Get ready-seconds": 0, + }; - int workMinutes = 0; - int workSeconds = 0; - int restMinutes = 0; - int restSeconds = 0; + int repeat = 0; - int calcMinutes(int seconds) { - return (seconds - (seconds % 60)) ~/ 60; - } + @override + Widget build(BuildContext context) { + Workout workout = ModalRoute.of(context)!.settings.arguments as Workout; + + final formKey = GlobalKey(); - int calcSeconds(int seconds) { - return (seconds % 60); + ValueNotifier iterationsNotifier = ValueNotifier(workout.iterations); + + return Scaffold( + appBar: AppBar( + title: const Text("New Interval Timer"), + ), + bottomSheet: SubmitButton( + text: "Submit", + color: const Color.fromARGB(255, 58, 165, 255), + onTap: () { + submitTimings(workout, formKey); + }, + ), + body: Padding( + padding: const EdgeInsets.fromLTRB(0, 0, 0, 120), + child: Form( + key: formKey, + child: ListView.builder( + itemCount: timeTitles.length, + itemBuilder: (context, index) { + return determineTile(workout, index, iterationsNotifier); + })))); } - void submitTimings(Workout workout) async { + void submitTimings(Workout workoutArg, GlobalKey formKey) { // Validate returns true if the form is valid, or false otherwise. final form = formKey.currentState!; if (form.validate()) { form.save(); - workout.exerciseTime = (workMinutes * 60) + workSeconds; - workout.restTime = (restMinutes * 60) + restSeconds; + workoutArg.workTime = (timeMap["$workTitle-minutes"]! * 60) + + timeMap["$workTitle-seconds"]!; + workoutArg.restTime = (timeMap["$restTitle-minutes"]! * 60) + + timeMap["$restTitle-seconds"]!; + workoutArg.getReadyTime = (timeMap["$getReadyTitle-minutes"]! * 60) + + timeMap["$getReadyTitle-seconds"]!; + workoutArg.warmupTime = (timeMap["$warmUpTitle-minutes"]! * 60) + + timeMap["$warmUpTitle-seconds"]!; + workoutArg.cooldownTime = (timeMap["$coolDownTitle-minutes"]! * 60) + + timeMap["$coolDownTitle-seconds"]!; + workoutArg.breakTime = (timeMap["$breakTitle-minutes"]! * 60) + + timeMap["$breakTitle-seconds"]!; + workoutArg.iterations = repeat; + + logger.i("Saving workout: ${workoutArg.toString()}"); + logger.i(repeat); Navigator.push( context, MaterialPageRoute( builder: (context) => const SetSounds(), settings: RouteSettings( - arguments: workout, + arguments: workoutArg, ), ), ); } } - Widget returnMinutesSecondsForm(Workout workout) { - return SizedBox( - height: (MediaQuery.of(context).size.height * 10) / 12, - child: SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.all(30), - child: Form( - key: formKey, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: MediaQuery.of(context).size.height / 22, - child: const AutoSizeText("Enter the work time:", - maxFontSize: 50, - minFontSize: 16, - style: TextStyle( - color: Color.fromARGB(255, 107, 107, 107), - fontSize: 30)), - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - NumberInput( - numberInputKey: const Key('work-minutes'), - numberValue: workout.exerciseTime, - formatter: (value) { - int calculation = ((workout.exerciseTime - - (workout.exerciseTime % 60)) / - 60) - .round(); - if (calculation == 0) { - return ""; - } - return calculation; - }, - validator: (value) { - if (value == null || value.isEmpty) { - return 'Enter time'; - } - return null; - }, - onSaved: (value) { - setState(() { - workMinutes = value!.contains(".") - ? int.parse( - value.substring(0, value.indexOf("."))) - : int.parse(value); - }); - }, - unit: "m", - min: 1, - max: 99), - NumberInput( - numberInputKey: const Key('work-seconds'), - numberValue: workout.exerciseTime, - formatter: (value) { - return workout.exerciseTime % 60; - }, - validator: (value) { - return null; - }, - onSaved: (value) { - if (value != "") { - setState(() => workSeconds = value!.contains(".") - ? int.parse( - value.substring(0, value.indexOf("."))) - : int.parse(value)); - } else { - setState(() => workSeconds = 0); - } - }, - unit: "s", - min: 0, - max: 59), - ], - ), - const SizedBox( - height: 30, - ), - SizedBox( - height: MediaQuery.of(context).size.height / 22, - child: const AutoSizeText("Enter the rest time:", - maxFontSize: 50, - minFontSize: 16, - style: TextStyle( - color: Color.fromARGB(255, 107, 107, 107), - fontSize: 30))), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - NumberInput( - numberInputKey: const Key('rest-minutes'), - numberValue: workout.restTime, - formatter: (value) { - int calculation = - ((workout.restTime - (workout.restTime % 60)) / - 60) - .round(); - if (calculation == 0) { - return ""; - } - return calculation; - }, - validator: (value) { - if (value == null || value.isEmpty) { - return 'Enter time'; - } - return null; - }, - onSaved: (value) => setState(() => restMinutes = value! - .contains(".") - ? int.parse(value.substring(0, value.indexOf("."))) - : int.parse(value)), - unit: "m", - min: 1, - max: 99), - NumberInput( - numberInputKey: const Key('rest-seconds'), - numberValue: workout.restTime, - formatter: (value) { - return workout.restTime % 60; - }, - validator: (value) { - return null; - }, - onSaved: (value) { - if (value != "") { - setState(() => restSeconds = value!.contains(".") - ? int.parse( - value.substring(0, value.indexOf("."))) - : int.parse(value)); - } else { - setState(() => restSeconds = 0); - } - }, - unit: "s", - min: 0, - max: 59), - ], - ), - ], - ), - ), - ))); + Widget determineTile( + Workout workoutArg, int index, ValueNotifier iterationsNotifier) { + switch (index) { + case 0: + case 1: + return returnTile( + workoutArg, + index, + determinePrefilledTime(workoutArg, timeTitles[index]), + timeTitles, + timeSubTitles, + timeLeadingIcons, + timeMinutesKeys[index], + timeSecondsKeys[index], + iterationsNotifier); + case 2: + return returnExpansionTile(workoutArg, index, iterationsNotifier); + default: + return const Text(""); + } } - Widget returnSecondsForm(Workout workout) { - return SizedBox( - height: (MediaQuery.of(context).size.height * 10) / 12, - child: SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.all(30), - child: Form( - key: formKey, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Padding( - padding: EdgeInsets.fromLTRB(0, 10, 0, 0), - child: Text("Enter the work time:", - style: TextStyle( - color: Color.fromARGB(255, 107, 107, 107), - fontSize: 18))), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - NumberInput( - numberInputKey: const Key('work-seconds'), - numberValue: workout.exerciseTime, - formatter: (value) { - return workout.exerciseTime; - }, - validator: (value) { - if (value == null || value.isEmpty) { - return 'Enter time'; - } - return null; - }, - onSaved: (value) { + Widget returnTile( + Workout workoutArg, + int index, + int time, + List titleList, + List subtitleList, + List iconList, + String minutesKey, + String secondsKey, + ValueNotifier iterationsNotifier) { + return ValueListenableBuilder( + valueListenable: iterationsNotifier, + builder: (BuildContext context, int val, Widget? child) { + return TimeListItem( + titleText: titleList[index], + subtitleText: subtitleList[index], + enabled: titleList[index] == breakTitle + ? (iterationsNotifier.value > 0 ? true : false) + : true, + leadingWidget: iconList[index], + trailingWidget: titleList[index] != additionalConfigTitle + ? Visibility( + visible: titleList[index] == breakTitle + ? (iterationsNotifier.value > 0 ? true : false) + : true, + child: TimeInputTrailing( + title: titleList[index], + unit: titleList[index] == repeatTitle ? "time(s)" : "s", + widgetWidth: workoutArg.showMinutes == 1 ? 160 : 120, + showMinutes: workoutArg.showMinutes, + timeInSeconds: time, + minutesValidator: (value) { + if ((titleList[index] == workTitle || + titleList[index] == restTitle) && + (value == null || + value.isEmpty || + int.parse(value) == 0)) { + return 'Enter time'; + } + return null; + }, + minutesOnSaved: (value) { + if (value != "") { + setState(() => + timeMap["${titleList[index]}-minutes"] = value! + .contains(".") + ? int.parse( + value.substring(0, value.indexOf("."))) + : int.parse(value)); + } else { + setState( + () => timeMap["${titleList[index]}-minutes"] = 0); + } + }, + secondsValidator: (value) { + if ((titleList[index] == workTitle || + titleList[index] == restTitle) && + (value == null || + value.isEmpty || + int.parse(value) == 0)) { + return 'Enter time'; + } + return null; + }, + secondsOnSaved: (value) { + if (titleList[index] == repeatTitle) { if (value != "") { - setState(() => workSeconds = value!.contains(".") + setState(() => repeat = value!.contains(".") ? int.parse( value.substring(0, value.indexOf("."))) : int.parse(value)); } else { - setState(() => workSeconds = 0); - } - }, - unit: "s", - min: 1, - max: 999), - ], - ), - const Padding( - padding: EdgeInsets.fromLTRB(0, 20, 0, 0), - child: Text("Enter the rest time:", - style: TextStyle( - color: Color.fromARGB(255, 107, 107, 107), - fontSize: 18))), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - NumberInput( - numberInputKey: const Key('rest-seconds'), - numberValue: workout.restTime, - formatter: (value) { - return workout.restTime; - }, - validator: (value) { - if (value == null || value.isEmpty) { - return 'Enter time'; + setState(() => repeat = 0); } - return null; - }, - onSaved: (value) { + } else { if (value != "") { - setState(() => restSeconds = value!.contains(".") - ? int.parse( - value.substring(0, value.indexOf("."))) - : int.parse(value)); + setState(() => + timeMap["${titleList[index]}-seconds"] = value! + .contains(".") + ? int.parse( + value.substring(0, value.indexOf("."))) + : int.parse(value)); } else { - setState(() => restSeconds = 0); + setState(() => + timeMap["${titleList[index]}-seconds"] = 0); } - }, - unit: "s", - min: 1, - max: 999), - ], - ), - ], - ), - ), - ))); + } + }, + secondsOnChanged: (text) { + if (titleList[index] == repeatTitle) { + // setState(() { + if (text! != "") { + iterationsNotifier.value = int.parse(text); + print("Changed: ${iterationsNotifier.value}"); + } + // }); + } + }, + minutesKey: minutesKey, + secondsKey: secondsKey, + )) + : const Text(""), + ); + }); } - @override - Widget build(BuildContext context) { - Workout workout = ModalRoute.of(context)!.settings.arguments as Workout; + Widget returnExpansionTile( + Workout workoutArg, int index, ValueNotifier iterationsNotifier) { + return ExpansionTile( + title: Text(timeTitles[index]), + subtitle: Text(timeSubTitles[index]), + leading: timeLeadingIcons[index], + children: returnAdditionalTiles(workoutArg, index, iterationsNotifier), + ); + } - return Scaffold( - appBar: AppBar( - title: const Text("New Interval Timer"), - ), - bottomSheet: SubmitButton( - text: "Submit", - color: const Color.fromARGB(255,58,165,255), - onTap: () { - submitTimings(workout); - }, - ), - body: workout.showMinutes == 1 - ? returnMinutesSecondsForm(workout) - : returnSecondsForm(workout)); + List returnAdditionalTiles( + Workout workoutArg, int index, ValueNotifier iterationsNotifier) { + List tileList = []; + for (int i = 0; i < additionalTimeTitles.length; i++) { + tileList.add(returnTile( + workoutArg, + i, + determinePrefilledTime(workoutArg, additionalTimeTitles[i]), + additionalTimeTitles, + additionalTimeSubTitles, + additionalTimeLeadingIcons, + additionalMinutesKeys[index], + additionalSecondsKeys[index], + additionalTimeTitles[i] == repeatTitle || + additionalTimeTitles[i] == breakTitle + ? iterationsNotifier + : ValueNotifier(0))); + } + return tileList; + } + + int determinePrefilledTime(Workout workoutArg, String title) { + switch (title) { + case workTitle: + return workoutArg.id != "" ? workoutArg.workTime : -1; + case restTitle: + return workoutArg.id != "" ? workoutArg.restTime : -1; + case getReadyTitle: + return workoutArg.id != "" ? workoutArg.getReadyTime : 10; + case warmUpTitle: + return workoutArg.id != "" ? workoutArg.warmupTime : 0; + case coolDownTitle: + return workoutArg.id != "" ? workoutArg.cooldownTime : 0; + case repeatTitle: + return workoutArg.iterations; + case breakTitle: + return workoutArg.id != "" ? workoutArg.breakTime : 0; + default: + return 9; + } } } + + +// import 'package:auto_size_text/auto_size_text.dart'; +// import 'package:flutter/material.dart'; +// import 'package:openhiit/create_workout/constants/set_timings_constants.dart'; +// import 'package:openhiit/create_workout/helper_widgets/expansion_repeat_tile.dart'; +// import '../workout_data_type/workout_type.dart'; +// import './set_sounds.dart'; +// import 'helper_widgets/number_input.dart'; +// import 'helper_widgets/submit_button.dart'; +// import 'helper_widgets/time_list_item.dart'; +// import 'utils/utils.dart'; + +// class SetTimings extends StatefulWidget { +// const SetTimings({super.key}); + +// @override +// State createState() => _SetTimingsState(); +// } + +// // Define a corresponding State class. +// // This class holds the data related to the Form. +// class _SetTimingsState extends State { +// /// The global key for the form. +// /// +// final formKey = GlobalKey(); + +// int workMinutes = 0; +// int workSeconds = 0; +// int restMinutes = 0; +// int restSeconds = 0; + +// int calcMinutes(int seconds) { +// return (seconds - (seconds % 60)) ~/ 60; +// } + +// int calcSeconds(int seconds) { +// return (seconds % 60); +// } + +// void submitTimings(Workout workout) async { +// // Validate returns true if the form is valid, or false otherwise. +// final form = formKey.currentState!; +// if (form.validate()) { +// form.save(); + +// workout.workTime = (workMinutes * 60) + workSeconds; +// workout.restTime = (restMinutes * 60) + restSeconds; +// workout.breakTime = 0; +// workout.warmupTime = 0; +// workout.cooldownTime = 0; +// workout.iterations = 0; + +// Navigator.push( +// context, +// MaterialPageRoute( +// builder: (context) => const SetSounds(), +// settings: RouteSettings( +// arguments: workout, +// ), +// ), +// ); +// } +// } + +// // Widget returnCombinedForm(Workout workout) { +// // return SizedBox( +// // height: (MediaQuery.of(context).size.height * 10) / 12, +// // child: SingleChildScrollView( +// // child: Padding( +// // padding: const EdgeInsets.all(30), +// // child: Form( +// // key: formKey, +// // child: Column( +// // crossAxisAlignment: CrossAxisAlignment.start, +// // children: [ +// // SizedBox( +// // height: MediaQuery.of(context).size.height / 22, +// // child: const AutoSizeText("Enter the work time:", +// // maxFontSize: 50, +// // minFontSize: 16, +// // style: TextStyle( +// // color: Color.fromARGB(255, 107, 107, 107), +// // fontSize: 30)), +// // ), +// // Row( +// // mainAxisAlignment: MainAxisAlignment.center, +// // children: [ +// // NumberInput( +// // numberInputKey: const Key('work-minutes'), +// // numberValue: workout.workTime, +// // formatter: (value) { +// // int calculation = ((workout.workTime - +// // (workout.workTime % 60)) / +// // 60) +// // .round(); +// // if (calculation == 0) { +// // return ""; +// // } +// // return calculation; +// // }, +// // validator: (value) { +// // if (value == null || value.isEmpty) { +// // return 'Enter time'; +// // } +// // return null; +// // }, +// // onSaved: (value) { +// // setState(() { +// // workMinutes = value!.contains(".") +// // ? int.parse( +// // value.substring(0, value.indexOf("."))) +// // : int.parse(value); +// // }); +// // }, +// // unit: "m", +// // min: 1, +// // max: 99), +// // NumberInput( +// // numberInputKey: const Key('work-seconds'), +// // numberValue: workout.workTime, +// // formatter: (value) { +// // return workout.workTime % 60; +// // }, +// // validator: (value) { +// // return null; +// // }, +// // onSaved: (value) { +// // if (value != "") { +// // setState(() => workSeconds = value!.contains(".") +// // ? int.parse( +// // value.substring(0, value.indexOf("."))) +// // : int.parse(value)); +// // } else { +// // setState(() => workSeconds = 0); +// // } +// // }, +// // unit: "s", +// // min: 0, +// // max: 59), +// // ], +// // ), +// // const SizedBox( +// // height: 30, +// // ), +// // SizedBox( +// // height: MediaQuery.of(context).size.height / 22, +// // child: const AutoSizeText("Enter the rest time:", +// // maxFontSize: 50, +// // minFontSize: 16, +// // style: TextStyle( +// // color: Color.fromARGB(255, 107, 107, 107), +// // fontSize: 30))), +// // Row( +// // mainAxisAlignment: MainAxisAlignment.center, +// // children: [ +// // NumberInput( +// // numberInputKey: const Key('rest-minutes'), +// // numberValue: workout.restTime, +// // formatter: (value) { +// // int calculation = +// // ((workout.restTime - (workout.restTime % 60)) / +// // 60) +// // .round(); +// // if (calculation == 0) { +// // return ""; +// // } +// // return calculation; +// // }, +// // validator: (value) { +// // if (value == null || value.isEmpty) { +// // return 'Enter time'; +// // } +// // return null; +// // }, +// // onSaved: (value) => setState(() => restMinutes = value! +// // .contains(".") +// // ? int.parse(value.substring(0, value.indexOf("."))) +// // : int.parse(value)), +// // unit: "m", +// // min: 1, +// // max: 99), +// // NumberInput( +// // numberInputKey: const Key('rest-seconds'), +// // numberValue: workout.restTime, +// // formatter: (value) { +// // return workout.restTime % 60; +// // }, +// // validator: (value) { +// // return null; +// // }, +// // onSaved: (value) { +// // if (value != "") { +// // setState(() => restSeconds = value!.contains(".") +// // ? int.parse( +// // value.substring(0, value.indexOf("."))) +// // : int.parse(value)); +// // } else { +// // setState(() => restSeconds = 0); +// // } +// // }, +// // unit: "s", +// // min: 0, +// // max: 59), +// // ], +// // ), +// // ], +// // ), +// // ), +// // ))); +// // } + +// // Widget returnMinutesSecondsForm(Workout workout) { +// // return SizedBox( +// // height: (MediaQuery.of(context).size.height * 10) / 12, +// // child: SingleChildScrollView( +// // child: Padding( +// // padding: const EdgeInsets.all(30), +// // child: Form( +// // key: formKey, +// // child: Column( +// // crossAxisAlignment: CrossAxisAlignment.start, +// // children: [ +// // SizedBox( +// // height: MediaQuery.of(context).size.height / 22, +// // child: const AutoSizeText("Enter the work time:", +// // maxFontSize: 50, +// // minFontSize: 16, +// // style: TextStyle( +// // color: Color.fromARGB(255, 107, 107, 107), +// // fontSize: 30)), +// // ), +// // Row( +// // mainAxisAlignment: MainAxisAlignment.center, +// // children: [ +// // NumberInput( +// // numberInputKey: const Key('work-minutes'), +// // numberValue: workout.workTime, +// // formatter: (value) { +// // int calculation = ((workout.workTime - +// // (workout.workTime % 60)) / +// // 60) +// // .round(); +// // if (calculation == 0) { +// // return ""; +// // } +// // return calculation; +// // }, +// // validator: (value) { +// // if (value == null || value.isEmpty) { +// // return 'Enter time'; +// // } +// // return null; +// // }, +// // onSaved: (value) { +// // setState(() { +// // workMinutes = value!.contains(".") +// // ? int.parse( +// // value.substring(0, value.indexOf("."))) +// // : int.parse(value); +// // }); +// // }, +// // unit: "m", +// // min: 1, +// // max: 99), +// // NumberInput( +// // numberInputKey: const Key('work-seconds'), +// // numberValue: workout.workTime, +// // formatter: (value) { +// // return workout.workTime % 60; +// // }, +// // validator: (value) { +// // return null; +// // }, +// // onSaved: (value) { +// // if (value != "") { +// // setState(() => workSeconds = value!.contains(".") +// // ? int.parse( +// // value.substring(0, value.indexOf("."))) +// // : int.parse(value)); +// // } else { +// // setState(() => workSeconds = 0); +// // } +// // }, +// // unit: "s", +// // min: 0, +// // max: 59), +// // ], +// // ), +// // const SizedBox( +// // height: 30, +// // ), +// // SizedBox( +// // height: MediaQuery.of(context).size.height / 22, +// // child: const AutoSizeText("Enter the rest time:", +// // maxFontSize: 50, +// // minFontSize: 16, +// // style: TextStyle( +// // color: Color.fromARGB(255, 107, 107, 107), +// // fontSize: 30))), +// // Row( +// // mainAxisAlignment: MainAxisAlignment.center, +// // children: [ +// // NumberInput( +// // numberInputKey: const Key('rest-minutes'), +// // numberValue: workout.restTime, +// // formatter: (value) { +// // int calculation = +// // ((workout.restTime - (workout.restTime % 60)) / +// // 60) +// // .round(); +// // if (calculation == 0) { +// // return ""; +// // } +// // return calculation; +// // }, +// // validator: (value) { +// // if (value == null || value.isEmpty) { +// // return 'Enter time'; +// // } +// // return null; +// // }, +// // onSaved: (value) => setState(() => restMinutes = value! +// // .contains(".") +// // ? int.parse(value.substring(0, value.indexOf("."))) +// // : int.parse(value)), +// // unit: "m", +// // min: 1, +// // max: 99), +// // NumberInput( +// // numberInputKey: const Key('rest-seconds'), +// // numberValue: workout.restTime, +// // formatter: (value) { +// // return workout.restTime % 60; +// // }, +// // validator: (value) { +// // return null; +// // }, +// // onSaved: (value) { +// // if (value != "") { +// // setState(() => restSeconds = value!.contains(".") +// // ? int.parse( +// // value.substring(0, value.indexOf("."))) +// // : int.parse(value)); +// // } else { +// // setState(() => restSeconds = 0); +// // } +// // }, +// // unit: "s", +// // min: 0, +// // max: 59), +// // ], +// // ), +// // ], +// // ), +// // ), +// // ))); +// // } + +// // Widget returnSecondsForm(Workout workout) { +// // return SizedBox( +// // height: (MediaQuery.of(context).size.height * 10) / 12, +// // child: SingleChildScrollView( +// // child: Padding( +// // padding: const EdgeInsets.all(30), +// // child: Form( +// // key: formKey, +// // child: Column( +// // crossAxisAlignment: CrossAxisAlignment.start, +// // children: [ +// // const Padding( +// // padding: EdgeInsets.fromLTRB(0, 10, 0, 0), +// // child: Text("Enter the work time:", +// // style: TextStyle( +// // color: Color.fromARGB(255, 107, 107, 107), +// // fontSize: 18))), +// // Row( +// // mainAxisAlignment: MainAxisAlignment.center, +// // children: [ +// // NumberInput( +// // numberInputKey: const Key('work-seconds'), +// // numberValue: workout.workTime, +// // formatter: (value) { +// // return workout.workTime; +// // }, +// // validator: (value) { +// // if (value == null || value.isEmpty) { +// // return 'Enter time'; +// // } +// // return null; +// // }, +// // onSaved: (value) { +// // if (value != "") { +// // setState(() => workSeconds = value!.contains(".") +// // ? int.parse( +// // value.substring(0, value.indexOf("."))) +// // : int.parse(value)); +// // } else { +// // setState(() => workSeconds = 0); +// // } +// // }, +// // unit: "s", +// // min: 1, +// // max: 999), +// // ], +// // ), +// // const Padding( +// // padding: EdgeInsets.fromLTRB(0, 20, 0, 0), +// // child: Text("Enter the rest time:", +// // style: TextStyle( +// // color: Color.fromARGB(255, 107, 107, 107), +// // fontSize: 18))), +// // Row( +// // mainAxisAlignment: MainAxisAlignment.center, +// // children: [ +// // NumberInput( +// // numberInputKey: const Key('rest-seconds'), +// // numberValue: workout.restTime, +// // formatter: (value) { +// // return workout.restTime; +// // }, +// // validator: (value) { +// // if (value == null || value.isEmpty) { +// // return 'Enter time'; +// // } +// // return null; +// // }, +// // onSaved: (value) { +// // if (value != "") { +// // setState(() => restSeconds = value!.contains(".") +// // ? int.parse( +// // value.substring(0, value.indexOf("."))) +// // : int.parse(value)); +// // } else { +// // setState(() => restSeconds = 0); +// // } +// // }, +// // unit: "s", +// // min: 1, +// // max: 999), +// // ], +// // ), +// // ], +// // ), +// // ), +// // ))); +// // } + +// @override +// Widget build(BuildContext context) { +// Workout workout = ModalRoute.of(context)!.settings.arguments as Workout; + +// final List items = List.generate( +// timeTitles.length, +// (i) => TimeMessageItem(timeTitles[i], timeSubTitles[i], workout), +// ); + +// return Scaffold( +// appBar: AppBar( +// title: const Text("New Interval Timer"), +// ), +// bottomSheet: SubmitButton( +// text: "Submit", +// color: const Color.fromARGB(255, 58, 165, 255), +// onTap: () { +// submitTimings(workout); +// }, +// ), +// body: ListView.builder( +// // Let the ListView know how many items it needs to build. +// itemCount: items.length + 1, +// // Provide a builder function. This is where the magic happens. +// // Convert each item into a widget based on the type of item it is. +// itemBuilder: (context, index) { +// if (index > 1) { +// return ExpansionRepeatTileClass(); +// } + +// final item = items[index]; + +// return ListTile( +// title: item.buildTitle(context), +// subtitle: item.buildSubtitle(context), +// leading: index < timeLeadingIcons.length +// ? Icon(timeLeadingIcons[index]) +// : const Text(""), +// trailing: buildTrailingWidget(timeTitles[index], workout), +// ); +// }, +// )); +// } + +// Widget buildTrailingWidget(String title, Workout workout) { +// int numberValue = 0, min = 0, max = 0; +// Function onSaved, validator; +// String numberInputKey; + + +// if (workout.showMinutes == 1) { + +// switch (title) { +// case workTitle: +// numberValue = -1; +// onSaved = +// validator = +// break; +// case restTitle: +// numberValue = -1; +// onSaved = +// validator = +// break; +// } + +// return SizedBox( +// width: 120, +// child: Row( +// children: [ +// NumberInput( +// numberValue: 0, +// formatter: secondsFormatter, +// onSaved: (value) {}, +// validator: (value) {}, +// unit: "m", +// min: 0, +// max: 99, +// numberInputKey: const Key('getready-seconds')), +// NumberInput( +// numberValue: numberValue, +// formatter: secondsFormatter, +// onSaved: (value) {}, +// validator: (value) {}, +// unit: "s", +// min: 0, +// max: 59, +// numberInputKey: const Key('getready-seconds')) +// ], +// ), +// ); +// } else { + + + +// return NumberInput( +// numberValue: numberValue, +// formatter: secondsFormatter, +// onSaved: (value) {}, +// validator: (value) {}, +// unit: "s", +// min: 0, +// max: 999, +// numberInputKey: const Key('getready-seconds')); +// } +// } +// } diff --git a/lib/create_workout/utils/set_timings_utils.dart b/lib/create_workout/utils/set_timings_utils.dart new file mode 100644 index 00000000..a747835c --- /dev/null +++ b/lib/create_workout/utils/set_timings_utils.dart @@ -0,0 +1,15 @@ +String minutesFormatter(int time) { + int calculation = ((time - (time % 60)) / 60).round(); + if (calculation == 0) { + return ""; + } + return calculation.toString(); +} + +String secondsRemainderFormatter(int time) { + return (time % 60).toString(); +} + +String secondsFormatter(int time) { + return time.toString(); +} diff --git a/lib/database/database_manager.dart b/lib/database/database_manager.dart index 5ffcea1e..56fa3ee0 100644 --- a/lib/database/database_manager.dart +++ b/lib/database/database_manager.dart @@ -6,12 +6,6 @@ import 'package:sqflite_common_ffi/sqflite_ffi.dart'; import '../workout_data_type/workout_type.dart'; class DatabaseManager { - /// - /// ------------- - /// FIELDS - /// ------------- - /// - /// The name of the database. /// /// e.g., "database.db" @@ -24,18 +18,6 @@ class DatabaseManager { /// static const String _workoutTableName = "WorkoutTable"; - /// - /// ------------- - /// END FIELDS - /// ------------- - /// - - /// - /// ------------- - /// FUNCTIONS - /// ------------- - /// - Future initDB() async { debugPrint("initDB executed"); @@ -60,9 +42,14 @@ class DatabaseManager { title TEXT, numExercises INTEGER, exercises TEXT, - exerciseTime INTEGER, + getReadyTime INTEGER, + workTime INTEGER, restTime INTEGER, halfTime INTEGER, + breakTime INTEGER, + warmupTime INTEGER, + cooldownTime INTEGER, + iterations INTEGER, halfwayMark INTEGER, workSound TEXT, restSound TEXT, @@ -84,10 +71,22 @@ class DatabaseManager { await db.execute( "ALTER TABLE WorkoutTable ADD COLUMN workoutIndex INTEGER;"); } - if (oldVersion < newVersion) { + if (oldVersion == 3) { await db.execute( "ALTER TABLE WorkoutTable ADD COLUMN showMinutes INTEGER;"); } + if (oldVersion < newVersion) { + await db.execute( + "ALTER TABLE WorkoutTable ADD COLUMN getReadyTime INTEGER;"); + await db.execute( + "ALTER TABLE WorkoutTable ADD COLUMN breakTime INTEGER;"); + await db.execute( + "ALTER TABLE WorkoutTable ADD COLUMN warmupTime INTEGER;"); + await db.execute( + "ALTER TABLE WorkoutTable ADD COLUMN cooldownTime INTEGER;"); + await db.execute( + "ALTER TABLE WorkoutTable ADD COLUMN iterations INTEGER;"); + } }, ); } @@ -100,9 +99,14 @@ class DatabaseManager { title TEXT, numExercises INTEGER, exercises TEXT, - exerciseTime INTEGER, + getReadyTime INTEGER, + workTime INTEGER, restTime INTEGER, halfTime INTEGER, + breakTime INTEGER, + warmupTime INTEGER, + cooldownTime INTEGER, + iterations INTEGER, halfwayMark INTEGER, workSound TEXT, restSound TEXT, @@ -124,10 +128,22 @@ class DatabaseManager { await db.execute( "ALTER TABLE WorkoutTable ADD COLUMN workoutIndex INTEGER;"); } - if (oldVersion < newVersion) { + if (oldVersion == 4) { await db.execute( "ALTER TABLE WorkoutTable ADD COLUMN showMinutes INTEGER;"); } + if (oldVersion < newVersion) { + await db.execute( + "ALTER TABLE WorkoutTable ADD COLUMN getReadyTime INTEGER;"); + await db.execute( + "ALTER TABLE WorkoutTable ADD COLUMN breakTime INTEGER;"); + await db.execute( + "ALTER TABLE WorkoutTable ADD COLUMN warmupTime INTEGER;"); + await db.execute( + "ALTER TABLE WorkoutTable ADD COLUMN cooldownTime INTEGER;"); + await db.execute( + "ALTER TABLE WorkoutTable ADD COLUMN iterations INTEGER;"); + } }, ); } @@ -198,9 +214,14 @@ class DatabaseManager { maps[i]['title'], maps[i]['numExercises'], maps[i]['exercises'], - maps[i]['exerciseTime'], + maps[i]['getReadyTime'] ?? 0, + maps[i]['workTime'], maps[i]['restTime'], maps[i]['halfTime'], + maps[i]['breakTime'] ?? 0, + maps[i]['warmupTime'] ?? 0, + maps[i]['cooldownTime'] ?? 0, + maps[i]['iterations'] ?? 0, maps[i]['halfwayMark'], maps[i]['workSound'], maps[i]['restSound'], diff --git a/lib/helper_widgets/timer_list_tile.dart b/lib/helper_widgets/timer_list_tile.dart index e7ea7174..e25a4251 100644 --- a/lib/helper_widgets/timer_list_tile.dart +++ b/lib/helper_widgets/timer_list_tile.dart @@ -1,7 +1,7 @@ import 'dart:convert'; import 'package:flutter/material.dart'; -import '../helper_functions/functions.dart'; +import '../utils/functions.dart'; import '../workout_data_type/workout_type.dart'; /// @@ -77,7 +77,7 @@ class TimerListTileState extends State // Workout metadata. subtitle: Text( '''${widget.workout.exercises != "" ? 'Exercises - ${jsonDecode(widget.workout.exercises).length}' : 'Intervals - ${widget.workout.numExercises}'} -Exercise time - ${timeString(widget.workout.showMinutes, widget.workout.exerciseTime)} +Exercise time - ${timeString(widget.workout.showMinutes, widget.workout.workTime)} Rest time - ${timeString(widget.workout.showMinutes, widget.workout.restTime)} Total - ${calculateWorkoutTime(widget.workout)} minutes'''), subtitleTextStyle: const TextStyle( diff --git a/lib/main.dart b/lib/main.dart index 68b27197..e6711e3e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -5,7 +5,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; -import 'package:openhiit/helper_functions/functions.dart'; +import 'package:openhiit/utils/functions.dart'; import 'package:sqflite/sqflite.dart'; import 'create_workout/select_timer.dart'; import 'workout_data_type/workout_type.dart'; @@ -155,7 +155,7 @@ class _MyHomePageState extends State { for (final workout in snapshot.data) TimerListTile( key: Key( - '${workout.workoutIndex}'),// Unique key for each list item. + '${workout.workoutIndex}'), // Unique key for each list item. workout: workout, onTap: () { onWorkoutTap(workout); diff --git a/lib/start_workout/view_workout.dart b/lib/start_workout/view_workout.dart index 576bc559..4262fc4d 100644 --- a/lib/start_workout/view_workout.dart +++ b/lib/start_workout/view_workout.dart @@ -1,7 +1,7 @@ import 'dart:convert'; import 'package:uuid/uuid.dart'; import 'package:flutter/material.dart'; -import '../helper_functions/functions.dart'; +import '../utils/functions.dart'; import '../helper_widgets/start_button.dart'; import 'package:sqflite/sqflite.dart'; import '../card_widgets/card_item_animated.dart'; @@ -127,7 +127,8 @@ class ViewWorkoutState extends State { /// It duplicates the current workout and updates the list and the database accordingly. /// Fetch the list of workouts from the database. - List workouts = await DatabaseManager().lists(DatabaseManager().initDB()); + List workouts = + await DatabaseManager().lists(DatabaseManager().initDB()); /// Increment the workoutIndex of each workout in the list. for (Workout workout in workouts) { @@ -140,9 +141,14 @@ class ViewWorkoutState extends State { workout.title, workout.numExercises, workout.exercises, - workout.exerciseTime, + workout.getReadyTime, + workout.workTime, workout.restTime, workout.halfTime, + workout.breakTime, + workout.warmupTime, + workout.cooldownTime, + workout.iterations, workout.halfwayMark, workout.workSound, workout.restSound, diff --git a/lib/start_workout/workout.dart b/lib/start_workout/workout.dart index 4767c170..a230df1c 100644 --- a/lib/start_workout/workout.dart +++ b/lib/start_workout/workout.dart @@ -10,7 +10,7 @@ import 'package:audio_session/audio_session.dart'; import 'package:background_timer/background_timer.dart'; import 'package:background_timer/background_timer_data.dart'; import 'package:confetti/confetti.dart'; -import '../helper_functions/functions.dart'; +import '../utils/functions.dart'; import '../workout_data_type/workout_type.dart'; import '../card_widgets/card_item_animated.dart'; import '../models/list_model_animated.dart'; @@ -121,6 +121,8 @@ class CountDownTimerState extends State switch (status) { case 'start': return "Get ready"; + case 'warmup': + return "Warm-up"; case 'work': String exercise = workoutArgument.numExercises == exercises.length ? exercises[interval] @@ -133,6 +135,10 @@ class CountDownTimerState extends State flipCurrentWorkInterval = false; } return "Rest"; + case 'cooldown': + return "Cooldown"; + case 'break': + return "Break"; default: return "Rest"; } @@ -288,11 +294,16 @@ class CountDownTimerState extends State return Countdown( controller: _workoutController, - workSeconds: workoutArgument.exerciseTime, + iterations: workoutArgument.iterations, + workSeconds: workoutArgument.workTime, restSeconds: workoutArgument.restTime, + breakSeconds: workoutArgument.breakTime, + getreadySeconds: workoutArgument.getReadyTime, + warmupSeconds: workoutArgument.warmupTime, + cooldownSeconds: workoutArgument.cooldownTime, workSound: workoutArgument.workSound, restSound: workoutArgument.restSound, - endSound: workoutArgument.completeSound, + completeSound: workoutArgument.completeSound, countdownSound: workoutArgument.countdownSound, halfwaySound: workoutArgument.halfwaySound, numberOfWorkIntervals: workoutArgument.numExercises, @@ -337,7 +348,7 @@ class CountDownTimerState extends State restart = true; } - while ((intervalInfo.length + timerData.numberOfIntervals) > + while ((intervalInfo.length + timerData.currentOverallInterval) > intervalTotal) { if (intervalInfo.length > 0 && doneVisible == false) { intervalInfo.removeAt(0); @@ -353,9 +364,6 @@ class CountDownTimerState extends State color: backgroundColor(timerData.status), child: Column( children: [ - // Padding( - // padding: EdgeInsets.fromLTRB(0, 10, 0, 0), - // child: Expanded( flex: 10, child: Padding( @@ -520,14 +528,21 @@ class CountDownTimerState extends State } Color backgroundColor(String status) { - if (status == "work") { - return Colors.green; - } else if (status == "rest") { - return Colors.red; - } else if (status == "start") { - return Colors.black; - } else { - return const Color.fromARGB(255, 0, 225, 255); + switch (status) { + case "work": + return Colors.green; + case "rest": + return Colors.red; + case "start": + return Colors.black; + case "break": + return Colors.teal; + case "warmup": + return Colors.orange; + case "cooldown": + return Colors.blue; + default: + return const Color.fromARGB(255, 0, 225, 255); } } diff --git a/lib/helper_functions/functions.dart b/lib/utils/functions.dart similarity index 60% rename from lib/helper_functions/functions.dart rename to lib/utils/functions.dart index 73892155..dbc6de52 100644 --- a/lib/helper_functions/functions.dart +++ b/lib/utils/functions.dart @@ -54,7 +54,7 @@ void pushCreateTimer(Workout workout, BuildContext context) { /// - An integer representing the total workout time rounded to the nearest minute. /// int calculateWorkoutTime(Workout workout) { - return (((workout.exerciseTime * workout.numExercises) + + return (((workout.workTime * workout.numExercises) + (workout.restTime * (workout.numExercises - 1)) + (workout.halfTime * workout.numExercises)) / 60) @@ -87,66 +87,93 @@ void setStatusBarBrightness(BuildContext context) { /// Returns: /// - A list of [ListTileModel] objects representing each interval in the workout. /// -List listItems(List exercises, Workout workoutArgument) { +List listItems(List exercises, Workout workoutArg) { List listItems = []; - for (var i = 0; i < workoutArgument.numExercises + 1; i++) { - if (i == 0) { - listItems.add( - ListTileModel( - action: "Prepare", - showMinutes: workoutArgument.showMinutes, - interval: 0, - total: workoutArgument.numExercises, - seconds: 10, - ), - ); - } else { - if (exercises.length < workoutArgument.numExercises) { + if (workoutArg.getReadyTime > 0) { + listItems.add( + ListTileModel( + action: "Get ready", + showMinutes: workoutArg.showMinutes, + interval: 0, + total: workoutArg.numExercises, + seconds: workoutArg.getReadyTime, + ), + ); + } + if (workoutArg.warmupTime > 0) { + listItems.add( + ListTileModel( + action: "Warmup", + showMinutes: workoutArg.showMinutes, + interval: 0, + total: workoutArg.numExercises, + seconds: workoutArg.warmupTime, + ), + ); + listItems.add( + ListTileModel( + action: "Rest", + showMinutes: workoutArg.showMinutes, + interval: 0, + total: workoutArg.numExercises, + seconds: workoutArg.restTime, + ), + ); + } + + for (var iteration = 0; iteration <= workoutArg.iterations; iteration++) { + for (var interval = 1; interval <= workoutArg.numExercises; interval++) { + if (workoutArg.workTime > 0) { listItems.add( ListTileModel( action: "Work", - showMinutes: workoutArgument.showMinutes, - interval: i, - total: workoutArgument.numExercises, - seconds: workoutArgument.exerciseTime, + showMinutes: workoutArg.showMinutes, + interval: interval, + total: workoutArg.numExercises, + seconds: workoutArg.workTime, ), ); - if (i < workoutArgument.numExercises) { - listItems.add( - ListTileModel( - action: "Rest", - showMinutes: workoutArgument.showMinutes, - interval: 0, - total: workoutArgument.numExercises, - seconds: workoutArgument.restTime, - ), - ); - } - } else { + } + + if (workoutArg.restTime > 0 && interval != workoutArg.numExercises) { listItems.add( ListTileModel( - action: exercises[i - 1], - showMinutes: workoutArgument.showMinutes, - interval: i, - total: workoutArgument.numExercises, - seconds: workoutArgument.exerciseTime, + action: "Rest", + showMinutes: workoutArg.showMinutes, + interval: 0, + total: workoutArg.numExercises, + seconds: workoutArg.restTime, + ), + ); + } else if (interval == workoutArg.numExercises && + workoutArg.iterations > 0 && + iteration < workoutArg.iterations && + workoutArg.breakTime > 0) { + listItems.add( + ListTileModel( + action: "Break", + showMinutes: workoutArg.showMinutes, + interval: 0, + total: workoutArg.numExercises, + seconds: workoutArg.breakTime, ), ); - if (i < workoutArgument.numExercises) { - listItems.add( - ListTileModel( - action: "Rest", - showMinutes: workoutArgument.showMinutes, - interval: 0, - total: workoutArgument.numExercises, - seconds: workoutArgument.restTime, - ), - ); - } } } } + if (workoutArg.cooldownTime > 0) { + listItems.add( + ListTileModel( + action: "Cooldown", + showMinutes: workoutArg.showMinutes, + interval: 0, + total: workoutArg.numExercises, + seconds: workoutArg.cooldownTime, + ), + ); + } + return listItems; } diff --git a/lib/workout_data_type/workout_type.dart b/lib/workout_data_type/workout_type.dart index 04ee3869..7f1412da 100644 --- a/lib/workout_data_type/workout_type.dart +++ b/lib/workout_data_type/workout_type.dart @@ -1,12 +1,6 @@ import 'dart:core'; class Workout { - /// - /// ------------- - /// FIELDS - /// ------------- - /// - /// The workout ID. /// late String id; @@ -23,17 +17,23 @@ class Workout { /// late int numExercises; - /// List of the exercises. + /// List of the exercises, JSON encoded string. /// /// e.g., ["Burpee", "Push-ups", "Rows"] /// late String exercises; + /// Amount of time to count down to the timer start, in seconds. + /// + /// e.g., 10 + /// + late int getReadyTime; + /// Amount of time for an exercise, in seconds. /// /// e.g., 30 /// - late int exerciseTime; + late int workTime; /// Amount of time between exercises, in seconds. (Rest time) /// @@ -47,16 +47,64 @@ class Workout { /// late int halfTime; + /// Amount of time for breaks between exercise cycles, in seconds. + /// + /// e.g., 60 + /// + late int breakTime; + + /// Amount of time dedicated to warm-up before the exercise routine starts, in seconds. + /// + /// e.g., 120 + /// + late int warmupTime; + + /// Amount of time dedicated to cooldown after completing the exercise routine, in seconds. + /// + /// e.g., 90 + /// + late int cooldownTime; + + /// The total number of exercise cycles or iterations in the routine. + /// + /// e.g., 5 + /// + late int iterations; + + /// The time mark, in seconds, at which the exercise routine is considered halfway completed. + /// + /// e.g., 300 + /// late int halfwayMark; + /// The sound file associated with the work phase of the exercise routine. + /// + /// e.g., "work_sound.mp3" + /// late String workSound; + /// The sound file associated with the rest phase of the exercise routine. + /// + /// e.g., "rest_sound.mp3" + /// late String restSound; + /// The sound file played at the halfway mark of the exercise routine. + /// + /// e.g., "halfway_sound.mp3" + /// late String halfwaySound; + /// The sound file played upon completing the entire exercise routine. + /// + /// e.g., "complete_sound.mp3" + /// late String completeSound; + /// The sound file played during countdowns or preparations. + /// + /// e.g., "countdown_sound.mp3" + /// late String countdownSound; /// Color selected for the background of the workout @@ -77,33 +125,19 @@ class Workout { /// late int showMinutes; - /// - /// ------------- - /// END FIELDS - /// ------------- - /// - - /// - /// ------------- - /// CONSTRUCTORS - /// ------------- - /// - // Workout( - // {required this.title, - // required this.numExercises, - // required this.exercises, - // required this.exerciseTime, - // required this.restTime, - // required this.halfTime}); - Workout( this.id, this.title, this.numExercises, this.exercises, - this.exerciseTime, + this.getReadyTime, + this.workTime, this.restTime, this.halfTime, + this.breakTime, + this.warmupTime, + this.cooldownTime, + this.iterations, this.halfwayMark, this.workSound, this.restSound, @@ -119,9 +153,14 @@ class Workout { title = ""; numExercises = 0; exercises = ""; - exerciseTime = 0; + getReadyTime = 0; + workTime = 0; restTime = 0; halfTime = 0; + breakTime = 0; + warmupTime = 0; + cooldownTime = 0; + iterations = 0; halfwayMark = 0; workSound = "short-whistle"; restSound = "short-rest-beep"; @@ -133,25 +172,20 @@ class Workout { showMinutes = 0; } - /// - /// ------------- - /// END CONSTRUCTORS - /// ------------- - /// - /// - /// ------------- - /// FUNCTIONS - /// ------------- - /// Map toMap() { return { 'id': id, 'title': title, 'numExercises': numExercises, 'exercises': exercises, - 'exerciseTime': exerciseTime, + 'getReadyTime': getReadyTime, + 'workTime': workTime, 'restTime': restTime, 'halfTime': halfTime, + 'breakTime': breakTime, + 'warmupTime': warmupTime, + 'cooldownTime': cooldownTime, + 'iterations': iterations, 'halfwayMark': halfwayMark, 'workSound': workSound, 'restSound': restSound, @@ -169,7 +203,7 @@ class Workout { /// @override String toString() { - return 'Workout{id: $id,title: $title, numExercises: $numExercises, exercises: $exercises, exerciseTime: $exerciseTime, restTime: $restTime, halfTime: $halfTime, halfwayMark: $halfwayMark, colorInt: $colorInt, index: $workoutIndex}'; + return 'Workout{id: $id, title: $title, numExercises: $numExercises, exercises: $exercises, getReadyTime: $getReadyTime, workTime: $workTime, restTime: $restTime, halfTime: $halfTime, halfwayMark: $halfwayMark, colorInt: $colorInt, index: $workoutIndex, warmupTime: $warmupTime, cooldownTime: $cooldownTime, breakTime: $breakTime, iterations: $iterations}'; } /// diff --git a/pubspec.lock b/pubspec.lock index c546e265..f3efc958 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -101,8 +101,8 @@ packages: dependency: "direct main" description: path: "." - ref: main - resolved-ref: "41e5ecae17895fca385f32c40f7fcac508b871b8" + ref: cleanup + resolved-ref: c661b5e36993df2861f4f8115f23687ae82527f7 url: "https://github.com/a-mabe/background_timer.git" source: git version: "0.0.1" @@ -317,10 +317,10 @@ packages: dependency: transitive description: name: flutter_local_notifications - sha256: "501ed9d54f1c8c0535b7991bade36f9e7e3b45a2346401f03775c1ec7a3c06ae" + sha256: "401643a6ea9d8451365f2ec11145335bf130560cfde367bdf8f0be6d60f89479" url: "https://pub.dev" source: hosted - version: "15.1.2" + version: "15.1.3" flutter_local_notifications_linux: dependency: transitive description: @@ -383,10 +383,10 @@ packages: dependency: transitive description: name: image - sha256: "004a2e90ce080f8627b5a04aecb4cdfac87d2c3f3b520aa291260be5a32c033d" + sha256: "49a0d4b0c12402853d3f227fe7c315601b238d126aa4caa5dbb2dcf99421aa4a" url: "https://pub.dev" source: hosted - version: "4.1.4" + version: "4.1.6" infinite_listview: dependency: transitive description: @@ -443,6 +443,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.0" + logger: + dependency: "direct main" + description: + name: logger + sha256: "6bbb9d6f7056729537a4309bda2e74e18e5d9f14302489cc1e93f33b3fe32cac" + url: "https://pub.dev" + source: hosted + version: "2.0.2+1" logging: dependency: transitive description: @@ -716,26 +724,26 @@ packages: dependency: "direct main" description: name: sqflite - sha256: "591f1602816e9c31377d5f008c2d9ef7b8aca8941c3f89cc5fd9d84da0c38a9a" + sha256: a9016f495c927cb90557c909ff26a6d92d9bd54fc42ba92e19d4e79d61e798c6 url: "https://pub.dev" source: hosted - version: "2.3.0" + version: "2.3.2" sqflite_common: dependency: transitive description: name: sqflite_common - sha256: bb4738f15b23352822f4c42a531677e5c6f522e079461fd240ead29d8d8a54a6 + sha256: "28d8c66baee4968519fb8bd6cdbedad982d6e53359091f0b74544a9f32ec72d5" url: "https://pub.dev" source: hosted - version: "2.5.0+2" + version: "2.5.3" sqflite_common_ffi: dependency: "direct main" description: name: sqflite_common_ffi - sha256: "873677ee78738a723d1ded4ccb23980581998d873d30ee9c331f6a81748663ff" + sha256: "754927d82de369a6b9e760fb60640aa81da650f35ffd468d5a992814d6022908" url: "https://pub.dev" source: hosted - version: "2.3.1" + version: "2.3.2+1" sqlite3: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 0fb928f0..eb36b791 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -53,12 +53,13 @@ dependencies: background_timer: git: url: https://github.com/a-mabe/background_timer.git - ref: main # branch name + ref: cleanup # branch name just_audio: ^0.9.35 soundpool: ^2.4.1 auto_size_text: ^3.0.0 google_fonts: ^6.1.0 shimmer: ^3.0.0 + logger: ^2.0.2+1 flutter_launcher_icons: android: "launcher_icon" From d23083466ebe6fe495aee54ea250035d13c8e5a3 Mon Sep 17 00:00:00 2001 From: a-mabe Date: Mon, 12 Feb 2024 19:23:23 -0500 Subject: [PATCH 02/26] Rearrange --- .../constants/set_timings_constants.dart | 2 +- lib/create_workout/create_timer.dart | 4 +-- lib/create_workout/create_workout.dart | 4 +-- .../clock_picker.dart | 0 .../color_picker.dart | 0 .../expansion_additional_config_tile.dart | 0 .../number_input.dart | 2 -- .../numerical_input_formatter.dart | 0 .../sound_dropdown.dart | 0 .../time_input_trailing.dart | 4 +-- .../time_list_item.dart | 0 .../helper_widgets/list_time_tile.dart | 36 ------------------- lib/create_workout/helper_widgets/sample.dart | 29 --------------- .../create_form.dart | 6 ++-- .../submit_button.dart | 0 .../timer_option_card.dart | 0 lib/create_workout/select_timer.dart | 2 +- lib/create_workout/set_exercises.dart | 2 +- lib/create_workout/set_sounds.dart | 4 +-- lib/create_workout/set_timings.dart | 6 ++-- .../set_timings_utils.dart | 0 lib/utils/functions.dart | 27 +++++++++++--- 22 files changed, 39 insertions(+), 89 deletions(-) rename lib/create_workout/{helper_widgets => form_picker_widgets}/clock_picker.dart (100%) rename lib/create_workout/{helper_widgets => form_picker_widgets}/color_picker.dart (100%) rename lib/create_workout/{helper_widgets => form_picker_widgets}/expansion_additional_config_tile.dart (100%) rename lib/create_workout/{helper_widgets => form_picker_widgets}/number_input.dart (96%) rename lib/create_workout/{helper_widgets => form_picker_widgets}/numerical_input_formatter.dart (100%) rename lib/create_workout/{helper_widgets => form_picker_widgets}/sound_dropdown.dart (100%) rename lib/create_workout/{helper_widgets => form_picker_widgets}/time_input_trailing.dart (95%) rename lib/create_workout/{helper_widgets => form_picker_widgets}/time_list_item.dart (100%) delete mode 100644 lib/create_workout/helper_widgets/list_time_tile.dart delete mode 100644 lib/create_workout/helper_widgets/sample.dart rename lib/create_workout/{helper_widgets => main_widgets}/create_form.dart (97%) rename lib/create_workout/{helper_widgets => main_widgets}/submit_button.dart (100%) rename lib/create_workout/{helper_widgets => main_widgets}/timer_option_card.dart (100%) rename lib/create_workout/{utils => set_timings_utils}/set_timings_utils.dart (100%) diff --git a/lib/create_workout/constants/set_timings_constants.dart b/lib/create_workout/constants/set_timings_constants.dart index 2fe8c419..cac1e951 100644 --- a/lib/create_workout/constants/set_timings_constants.dart +++ b/lib/create_workout/constants/set_timings_constants.dart @@ -6,7 +6,7 @@ const String additionalConfigTitle = "Additional configuration"; const String getReadyTitle = "Get ready"; const String warmUpTitle = "Warm-up"; const String coolDownTitle = "Cool down"; -const String repeatTitle = "Repeat"; +const String repeatTitle = "Restart"; const String breakTitle = "Break"; const String workMinutesKey = "work-minutes"; diff --git a/lib/create_workout/create_timer.dart b/lib/create_workout/create_timer.dart index 5940f635..122a7134 100644 --- a/lib/create_workout/create_timer.dart +++ b/lib/create_workout/create_timer.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; -import 'package:openhiit/create_workout/helper_widgets/create_form.dart'; +import 'package:openhiit/create_workout/main_widgets/create_form.dart'; import '../workout_data_type/workout_type.dart'; import './set_timings.dart'; -import './helper_widgets/submit_button.dart'; +import 'main_widgets/submit_button.dart'; class CreateTimer extends StatefulWidget { const CreateTimer({super.key}); diff --git a/lib/create_workout/create_workout.dart b/lib/create_workout/create_workout.dart index 8f4d39d8..eb9c72df 100644 --- a/lib/create_workout/create_workout.dart +++ b/lib/create_workout/create_workout.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; -import 'package:openhiit/create_workout/helper_widgets/create_form.dart'; +import 'package:openhiit/create_workout/main_widgets/create_form.dart'; import '../workout_data_type/workout_type.dart'; -import './helper_widgets/submit_button.dart'; +import 'main_widgets/submit_button.dart'; import 'set_exercises.dart'; class CreateWorkout extends StatefulWidget { diff --git a/lib/create_workout/helper_widgets/clock_picker.dart b/lib/create_workout/form_picker_widgets/clock_picker.dart similarity index 100% rename from lib/create_workout/helper_widgets/clock_picker.dart rename to lib/create_workout/form_picker_widgets/clock_picker.dart diff --git a/lib/create_workout/helper_widgets/color_picker.dart b/lib/create_workout/form_picker_widgets/color_picker.dart similarity index 100% rename from lib/create_workout/helper_widgets/color_picker.dart rename to lib/create_workout/form_picker_widgets/color_picker.dart diff --git a/lib/create_workout/helper_widgets/expansion_additional_config_tile.dart b/lib/create_workout/form_picker_widgets/expansion_additional_config_tile.dart similarity index 100% rename from lib/create_workout/helper_widgets/expansion_additional_config_tile.dart rename to lib/create_workout/form_picker_widgets/expansion_additional_config_tile.dart diff --git a/lib/create_workout/helper_widgets/number_input.dart b/lib/create_workout/form_picker_widgets/number_input.dart similarity index 96% rename from lib/create_workout/helper_widgets/number_input.dart rename to lib/create_workout/form_picker_widgets/number_input.dart index 6d0abe02..4d2a1945 100644 --- a/lib/create_workout/helper_widgets/number_input.dart +++ b/lib/create_workout/form_picker_widgets/number_input.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:openhiit/create_workout/constants/set_timings_constants.dart'; import 'numerical_input_formatter.dart'; @@ -63,7 +62,6 @@ class NumberInputState extends State { Widget build(BuildContext context) { return SizedBox( width: widget.widgetWidth, - // color: Colors.red, child: Row( crossAxisAlignment: CrossAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end, diff --git a/lib/create_workout/helper_widgets/numerical_input_formatter.dart b/lib/create_workout/form_picker_widgets/numerical_input_formatter.dart similarity index 100% rename from lib/create_workout/helper_widgets/numerical_input_formatter.dart rename to lib/create_workout/form_picker_widgets/numerical_input_formatter.dart diff --git a/lib/create_workout/helper_widgets/sound_dropdown.dart b/lib/create_workout/form_picker_widgets/sound_dropdown.dart similarity index 100% rename from lib/create_workout/helper_widgets/sound_dropdown.dart rename to lib/create_workout/form_picker_widgets/sound_dropdown.dart diff --git a/lib/create_workout/helper_widgets/time_input_trailing.dart b/lib/create_workout/form_picker_widgets/time_input_trailing.dart similarity index 95% rename from lib/create_workout/helper_widgets/time_input_trailing.dart rename to lib/create_workout/form_picker_widgets/time_input_trailing.dart index 24009a4e..4764e8aa 100644 --- a/lib/create_workout/helper_widgets/time_input_trailing.dart +++ b/lib/create_workout/form_picker_widgets/time_input_trailing.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:openhiit/create_workout/utils/set_timings_utils.dart'; +import 'package:openhiit/create_workout/set_timings_utils/set_timings_utils.dart'; import 'number_input.dart'; @@ -70,7 +70,7 @@ class TimeInputTrailingState extends State { Visibility( visible: widget.showMinutes == 1, child: NumberInput( - widgetWidth: 80, + widgetWidth: widget.widgetWidth, numberValue: widget.timeInSeconds, formatter: minutesFormatter, onSaved: widget.minutesOnSaved!, diff --git a/lib/create_workout/helper_widgets/time_list_item.dart b/lib/create_workout/form_picker_widgets/time_list_item.dart similarity index 100% rename from lib/create_workout/helper_widgets/time_list_item.dart rename to lib/create_workout/form_picker_widgets/time_list_item.dart diff --git a/lib/create_workout/helper_widgets/list_time_tile.dart b/lib/create_workout/helper_widgets/list_time_tile.dart deleted file mode 100644 index 5812c323..00000000 --- a/lib/create_workout/helper_widgets/list_time_tile.dart +++ /dev/null @@ -1,36 +0,0 @@ -import 'package:flutter/material.dart'; - -class ListTimeTileClass extends StatefulWidget { - /// Vars - - final String? title; - - final String? subtitle; - - final Widget? leadingWidget; - - final Widget? trailingWidget; - - const ListTimeTileClass({ - this.title, - this.subtitle, - this.leadingWidget, - this.trailingWidget, - super.key, - }); - - @override - ListTimeTileClassState createState() => ListTimeTileClassState(); -} - -class ListTimeTileClassState extends State { - @override - Widget build(BuildContext context) { - return ListTile( - title: Text(widget.title!), - subtitle: Text(widget.subtitle!), - leading: widget.leadingWidget ?? const Text(""), - trailing: widget.trailingWidget ?? const Text(""), - ); - } -} diff --git a/lib/create_workout/helper_widgets/sample.dart b/lib/create_workout/helper_widgets/sample.dart deleted file mode 100644 index 446db1dc..00000000 --- a/lib/create_workout/helper_widgets/sample.dart +++ /dev/null @@ -1,29 +0,0 @@ -import 'package:flutter/material.dart'; - -class SampleClass extends StatefulWidget { - /// Vars - - const SampleClass({ - super.key, - }); - - @override - SampleClassState createState() => SampleClassState(); -} - -class SampleClassState extends State { - @override - void initState() { - super.initState(); - } - - @override - void dispose() { - super.dispose(); - } - - @override - Widget build(BuildContext context) { - return const Text("This is a sample class"); - } -} diff --git a/lib/create_workout/helper_widgets/create_form.dart b/lib/create_workout/main_widgets/create_form.dart similarity index 97% rename from lib/create_workout/helper_widgets/create_form.dart rename to lib/create_workout/main_widgets/create_form.dart index d2047af0..d59225fc 100644 --- a/lib/create_workout/helper_widgets/create_form.dart +++ b/lib/create_workout/main_widgets/create_form.dart @@ -1,10 +1,10 @@ import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; import 'package:flutter_material_color_picker/flutter_material_color_picker.dart'; -import 'package:openhiit/create_workout/helper_widgets/clock_picker.dart'; -import 'package:openhiit/create_workout/helper_widgets/number_input.dart'; +import '../form_picker_widgets/clock_picker.dart'; +import '../form_picker_widgets/number_input.dart'; import '../../workout_data_type/workout_type.dart'; -import './color_picker.dart'; +import '../form_picker_widgets/color_picker.dart'; class CreateForm extends StatefulWidget { /// Vars diff --git a/lib/create_workout/helper_widgets/submit_button.dart b/lib/create_workout/main_widgets/submit_button.dart similarity index 100% rename from lib/create_workout/helper_widgets/submit_button.dart rename to lib/create_workout/main_widgets/submit_button.dart diff --git a/lib/create_workout/helper_widgets/timer_option_card.dart b/lib/create_workout/main_widgets/timer_option_card.dart similarity index 100% rename from lib/create_workout/helper_widgets/timer_option_card.dart rename to lib/create_workout/main_widgets/timer_option_card.dart diff --git a/lib/create_workout/select_timer.dart b/lib/create_workout/select_timer.dart index f12b5284..fb420859 100644 --- a/lib/create_workout/select_timer.dart +++ b/lib/create_workout/select_timer.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import '../utils/functions.dart'; import '../workout_data_type/workout_type.dart'; -import './helper_widgets/timer_option_card.dart'; +import 'main_widgets/timer_option_card.dart'; class SelectTimer extends StatefulWidget { const SelectTimer({super.key}); diff --git a/lib/create_workout/set_exercises.dart b/lib/create_workout/set_exercises.dart index 9dd9d5db..c3d02b8e 100644 --- a/lib/create_workout/set_exercises.dart +++ b/lib/create_workout/set_exercises.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'dart:convert'; import '../workout_data_type/workout_type.dart'; import './set_timings.dart'; -import 'helper_widgets/submit_button.dart'; +import 'main_widgets/submit_button.dart'; class SetExercises extends StatefulWidget { const SetExercises({super.key}); diff --git a/lib/create_workout/set_sounds.dart b/lib/create_workout/set_sounds.dart index 8daaac30..ceb178a6 100644 --- a/lib/create_workout/set_sounds.dart +++ b/lib/create_workout/set_sounds.dart @@ -6,8 +6,8 @@ import 'package:uuid/uuid.dart'; import '../main.dart'; import '../workout_data_type/workout_type.dart'; import '../database/database_manager.dart'; -import './helper_widgets/sound_dropdown.dart'; -import './helper_widgets/submit_button.dart'; +import 'form_picker_widgets/sound_dropdown.dart'; +import 'main_widgets/submit_button.dart'; import 'constants/sounds.dart'; List allSounds = soundsList + countdownSounds; diff --git a/lib/create_workout/set_timings.dart b/lib/create_workout/set_timings.dart index e1111a71..68722b3a 100644 --- a/lib/create_workout/set_timings.dart +++ b/lib/create_workout/set_timings.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; import 'package:logger/logger.dart'; import 'package:openhiit/create_workout/constants/set_timings_constants.dart'; -import 'package:openhiit/create_workout/helper_widgets/time_input_trailing.dart'; +import './form_picker_widgets/time_input_trailing.dart'; import '../workout_data_type/workout_type.dart'; -import 'helper_widgets/submit_button.dart'; -import 'helper_widgets/time_list_item.dart'; +import 'main_widgets/submit_button.dart'; +import './form_picker_widgets/time_list_item.dart'; import 'set_sounds.dart'; var logger = Logger( diff --git a/lib/create_workout/utils/set_timings_utils.dart b/lib/create_workout/set_timings_utils/set_timings_utils.dart similarity index 100% rename from lib/create_workout/utils/set_timings_utils.dart rename to lib/create_workout/set_timings_utils/set_timings_utils.dart diff --git a/lib/utils/functions.dart b/lib/utils/functions.dart index dbc6de52..7844d30a 100644 --- a/lib/utils/functions.dart +++ b/lib/utils/functions.dart @@ -54,11 +54,28 @@ void pushCreateTimer(Workout workout, BuildContext context) { /// - An integer representing the total workout time rounded to the nearest minute. /// int calculateWorkoutTime(Workout workout) { - return (((workout.workTime * workout.numExercises) + - (workout.restTime * (workout.numExercises - 1)) + - (workout.halfTime * workout.numExercises)) / - 60) - .round(); + if (workout.iterations > 0) { + return (((workout.workTime * + workout.numExercises * + (workout.iterations + 1)) + + (workout.restTime * + (workout.numExercises - 1) * + workout.iterations) + + (workout.halfTime * workout.numExercises) + + (workout.breakTime * (workout.iterations + 1)) + + workout.warmupTime + + workout.cooldownTime) / + 60) + .ceil(); + } else { + return (((workout.workTime * workout.numExercises) + + (workout.restTime * (workout.numExercises - 1)) + + (workout.halfTime * workout.numExercises) + + workout.warmupTime + + workout.cooldownTime) / + 60) + .ceil(); + } } /// Sets the status bar brightness based on the brightness theme of the provided From 759d08707141ea5c54890e8a437b9af02f86ee3a Mon Sep 17 00:00:00 2001 From: a-mabe Date: Mon, 12 Feb 2024 19:28:19 -0500 Subject: [PATCH 03/26] Decrease number input size --- lib/create_workout/form_picker_widgets/number_input.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/create_workout/form_picker_widgets/number_input.dart b/lib/create_workout/form_picker_widgets/number_input.dart index 4d2a1945..9435917e 100644 --- a/lib/create_workout/form_picker_widgets/number_input.dart +++ b/lib/create_workout/form_picker_widgets/number_input.dart @@ -67,7 +67,7 @@ class NumberInputState extends State { mainAxisAlignment: MainAxisAlignment.end, children: [ SizedBox( - width: 55, + width: 50, child: TextFormField( key: widget.numberInputKey, initialValue: widget.numberValue == -1 From df063a724a995780a92e05725af10671a6bfa9e2 Mon Sep 17 00:00:00 2001 From: a-mabe Date: Mon, 12 Feb 2024 19:41:53 -0500 Subject: [PATCH 04/26] Remove sizedbox wrap from numberinput --- .../form_picker_widgets/number_input.dart | 86 +++++++++---------- .../main_widgets/create_form.dart | 50 +++++------ 2 files changed, 68 insertions(+), 68 deletions(-) diff --git a/lib/create_workout/form_picker_widgets/number_input.dart b/lib/create_workout/form_picker_widgets/number_input.dart index 9435917e..95ed1388 100644 --- a/lib/create_workout/form_picker_widgets/number_input.dart +++ b/lib/create_workout/form_picker_widgets/number_input.dart @@ -60,49 +60,47 @@ class NumberInputState extends State { @override Widget build(BuildContext context) { - return SizedBox( - width: widget.widgetWidth, - child: Row( - crossAxisAlignment: CrossAxisAlignment.end, - mainAxisAlignment: MainAxisAlignment.end, - children: [ - SizedBox( - width: 50, - child: TextFormField( - key: widget.numberInputKey, - initialValue: widget.numberValue == -1 - ? "" - : widget.formatter(widget.numberValue).toString(), - keyboardType: TextInputType.number, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, - NumericalRangeFormatter(min: widget.min, max: widget.max), - ], - textInputAction: TextInputAction.done, - style: const TextStyle(fontSize: 30), - textAlign: TextAlign.center, - maxLength: 3, - decoration: const InputDecoration( - hintText: "00", - errorStyle: TextStyle(height: 0.1, fontSize: 10), - errorMaxLines: 1, - border: InputBorder.none, - fillColor: Colors.white, - counterText: "", - contentPadding: EdgeInsets.zero, - ), - onChanged: widget.onChanged, - validator: widget.validator, - onSaved: widget.onSaved, - )), - Padding( - padding: const EdgeInsets.fromLTRB(0, 0, 0, 3), - child: Text( - widget.unit, - textAlign: TextAlign.left, - style: const TextStyle(color: Colors.grey, fontSize: 18), - )), - ], - )); + return Row( + crossAxisAlignment: CrossAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.end, + children: [ + SizedBox( + width: 50, + child: TextFormField( + key: widget.numberInputKey, + initialValue: widget.numberValue == -1 + ? "" + : widget.formatter(widget.numberValue).toString(), + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + NumericalRangeFormatter(min: widget.min, max: widget.max), + ], + textInputAction: TextInputAction.done, + style: const TextStyle(fontSize: 30), + textAlign: TextAlign.center, + maxLength: 3, + decoration: const InputDecoration( + hintText: "00", + errorStyle: TextStyle(height: 0.1, fontSize: 10), + errorMaxLines: 1, + border: InputBorder.none, + fillColor: Colors.white, + counterText: "", + contentPadding: EdgeInsets.zero, + ), + onChanged: widget.onChanged, + validator: widget.validator, + onSaved: widget.onSaved, + )), + Padding( + padding: const EdgeInsets.fromLTRB(0, 0, 0, 3), + child: Text( + widget.unit, + textAlign: TextAlign.left, + style: const TextStyle(color: Colors.grey, fontSize: 18), + )), + ], + ); } } diff --git a/lib/create_workout/main_widgets/create_form.dart b/lib/create_workout/main_widgets/create_form.dart index d59225fc..4b1c005d 100644 --- a/lib/create_workout/main_widgets/create_form.dart +++ b/lib/create_workout/main_widgets/create_form.dart @@ -152,30 +152,32 @@ class CreateFormState extends State { ), ), Align( - alignment: Alignment.center, - child: NumberInput( - widgetWidth: 140, - numberInputKey: const Key('interval-input'), - numberValue: widget.workout.numExercises == 0 - ? -1 - : widget.workout.numExercises, - formatter: (value) { - return value; - }, - validator: (value) { - if (value == null || value.isEmpty) { - return 'Enter intervals'; - } - return null; - }, - onSaved: (String? val) { - widget.workout.numExercises = int.parse(val!); - }, - onChanged: (text) {}, - unit: "intervals", - min: 1, - max: 999), - ), + alignment: Alignment.center, + child: SizedBox( + width: 140, + child: NumberInput( + widgetWidth: 140, + numberInputKey: const Key('interval-input'), + numberValue: widget.workout.numExercises == 0 + ? -1 + : widget.workout.numExercises, + formatter: (value) { + return value; + }, + validator: (value) { + if (value == null || value.isEmpty) { + return 'Enter intervals'; + } + return null; + }, + onSaved: (String? val) { + widget.workout.numExercises = int.parse(val!); + }, + onChanged: (text) {}, + unit: "intervals", + min: 1, + max: 999), + )), /// Workout/timer timer display /// From 9f91daed904bd951011dea9cf902686cbefc2c5f Mon Sep 17 00:00:00 2001 From: a-mabe Date: Mon, 12 Feb 2024 19:45:39 -0500 Subject: [PATCH 05/26] Remove sizedbox --- .../main_widgets/create_form.dart | 50 +++++++++---------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/lib/create_workout/main_widgets/create_form.dart b/lib/create_workout/main_widgets/create_form.dart index 4b1c005d..d59225fc 100644 --- a/lib/create_workout/main_widgets/create_form.dart +++ b/lib/create_workout/main_widgets/create_form.dart @@ -152,32 +152,30 @@ class CreateFormState extends State { ), ), Align( - alignment: Alignment.center, - child: SizedBox( - width: 140, - child: NumberInput( - widgetWidth: 140, - numberInputKey: const Key('interval-input'), - numberValue: widget.workout.numExercises == 0 - ? -1 - : widget.workout.numExercises, - formatter: (value) { - return value; - }, - validator: (value) { - if (value == null || value.isEmpty) { - return 'Enter intervals'; - } - return null; - }, - onSaved: (String? val) { - widget.workout.numExercises = int.parse(val!); - }, - onChanged: (text) {}, - unit: "intervals", - min: 1, - max: 999), - )), + alignment: Alignment.center, + child: NumberInput( + widgetWidth: 140, + numberInputKey: const Key('interval-input'), + numberValue: widget.workout.numExercises == 0 + ? -1 + : widget.workout.numExercises, + formatter: (value) { + return value; + }, + validator: (value) { + if (value == null || value.isEmpty) { + return 'Enter intervals'; + } + return null; + }, + onSaved: (String? val) { + widget.workout.numExercises = int.parse(val!); + }, + onChanged: (text) {}, + unit: "intervals", + min: 1, + max: 999), + ), /// Workout/timer timer display /// From b98a1d839cd30c6f56ced38deb8d4118d8b5fa07 Mon Sep 17 00:00:00 2001 From: a-mabe Date: Tue, 13 Feb 2024 07:54:35 -0500 Subject: [PATCH 06/26] Add back sizedbox and increase size --- .../main_widgets/create_form.dart | 50 ++++++++++--------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/lib/create_workout/main_widgets/create_form.dart b/lib/create_workout/main_widgets/create_form.dart index d59225fc..30d5df17 100644 --- a/lib/create_workout/main_widgets/create_form.dart +++ b/lib/create_workout/main_widgets/create_form.dart @@ -152,30 +152,32 @@ class CreateFormState extends State { ), ), Align( - alignment: Alignment.center, - child: NumberInput( - widgetWidth: 140, - numberInputKey: const Key('interval-input'), - numberValue: widget.workout.numExercises == 0 - ? -1 - : widget.workout.numExercises, - formatter: (value) { - return value; - }, - validator: (value) { - if (value == null || value.isEmpty) { - return 'Enter intervals'; - } - return null; - }, - onSaved: (String? val) { - widget.workout.numExercises = int.parse(val!); - }, - onChanged: (text) {}, - unit: "intervals", - min: 1, - max: 999), - ), + alignment: Alignment.center, + child: SizedBox( + width: 250, + child: NumberInput( + widgetWidth: 140, + numberInputKey: const Key('interval-input'), + numberValue: widget.workout.numExercises == 0 + ? -1 + : widget.workout.numExercises, + formatter: (value) { + return value; + }, + validator: (value) { + if (value == null || value.isEmpty) { + return 'Enter intervals'; + } + return null; + }, + onSaved: (String? val) { + widget.workout.numExercises = int.parse(val!); + }, + onChanged: (text) {}, + unit: "intervals", + min: 1, + max: 999), + )), /// Workout/timer timer display /// From ddec00ee8ba9c7c4023fd6ade71d9634c907d243 Mon Sep 17 00:00:00 2001 From: a-mabe Date: Tue, 13 Feb 2024 07:56:28 -0500 Subject: [PATCH 07/26] Numberinput use width param --- lib/create_workout/form_picker_widgets/number_input.dart | 2 +- lib/create_workout/main_widgets/create_form.dart | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/create_workout/form_picker_widgets/number_input.dart b/lib/create_workout/form_picker_widgets/number_input.dart index 95ed1388..028a2739 100644 --- a/lib/create_workout/form_picker_widgets/number_input.dart +++ b/lib/create_workout/form_picker_widgets/number_input.dart @@ -65,7 +65,7 @@ class NumberInputState extends State { mainAxisAlignment: MainAxisAlignment.end, children: [ SizedBox( - width: 50, + width: widget.widgetWidth, child: TextFormField( key: widget.numberInputKey, initialValue: widget.numberValue == -1 diff --git a/lib/create_workout/main_widgets/create_form.dart b/lib/create_workout/main_widgets/create_form.dart index 30d5df17..862f43f4 100644 --- a/lib/create_workout/main_widgets/create_form.dart +++ b/lib/create_workout/main_widgets/create_form.dart @@ -154,9 +154,9 @@ class CreateFormState extends State { Align( alignment: Alignment.center, child: SizedBox( - width: 250, + width: 150, child: NumberInput( - widgetWidth: 140, + widgetWidth: 60, numberInputKey: const Key('interval-input'), numberValue: widget.workout.numExercises == 0 ? -1 From 1ea1f295c838ac0e66f1dd7a5059f13383cc7b28 Mon Sep 17 00:00:00 2001 From: a-mabe Date: Tue, 13 Feb 2024 08:10:31 -0500 Subject: [PATCH 08/26] Fix number input centering --- .../form_picker_widgets/number_input.dart | 2 +- .../time_input_trailing.dart | 6 +-- .../main_widgets/create_form.dart | 49 +++++++++---------- lib/create_workout/set_timings.dart | 5 +- 4 files changed, 30 insertions(+), 32 deletions(-) diff --git a/lib/create_workout/form_picker_widgets/number_input.dart b/lib/create_workout/form_picker_widgets/number_input.dart index 028a2739..a97bc0bc 100644 --- a/lib/create_workout/form_picker_widgets/number_input.dart +++ b/lib/create_workout/form_picker_widgets/number_input.dart @@ -62,7 +62,7 @@ class NumberInputState extends State { Widget build(BuildContext context) { return Row( crossAxisAlignment: CrossAxisAlignment.end, - mainAxisAlignment: MainAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox( width: widget.widgetWidth, diff --git a/lib/create_workout/form_picker_widgets/time_input_trailing.dart b/lib/create_workout/form_picker_widgets/time_input_trailing.dart index 4764e8aa..2b51be32 100644 --- a/lib/create_workout/form_picker_widgets/time_input_trailing.dart +++ b/lib/create_workout/form_picker_widgets/time_input_trailing.dart @@ -68,9 +68,9 @@ class TimeInputTrailingState extends State { mainAxisAlignment: MainAxisAlignment.end, children: [ Visibility( - visible: widget.showMinutes == 1, + visible: (widget.showMinutes == 1 && widget.unit != "time(s)"), child: NumberInput( - widgetWidth: widget.widgetWidth, + widgetWidth: 50, numberValue: widget.timeInSeconds, formatter: minutesFormatter, onSaved: widget.minutesOnSaved!, @@ -82,7 +82,7 @@ class TimeInputTrailingState extends State { numberInputKey: Key(widget.minutesKey))), NumberInput( title: widget.title, - widgetWidth: widget.unit == "time(s)" ? 120 : 70, + widgetWidth: 50, numberValue: widget.timeInSeconds, formatter: widget.showMinutes == 1 ? secondsRemainderFormatter diff --git a/lib/create_workout/main_widgets/create_form.dart b/lib/create_workout/main_widgets/create_form.dart index 862f43f4..62728ee7 100644 --- a/lib/create_workout/main_widgets/create_form.dart +++ b/lib/create_workout/main_widgets/create_form.dart @@ -151,33 +151,28 @@ class CreateFormState extends State { fontSize: 30)), ), ), - Align( - alignment: Alignment.center, - child: SizedBox( - width: 150, - child: NumberInput( - widgetWidth: 60, - numberInputKey: const Key('interval-input'), - numberValue: widget.workout.numExercises == 0 - ? -1 - : widget.workout.numExercises, - formatter: (value) { - return value; - }, - validator: (value) { - if (value == null || value.isEmpty) { - return 'Enter intervals'; - } - return null; - }, - onSaved: (String? val) { - widget.workout.numExercises = int.parse(val!); - }, - onChanged: (text) {}, - unit: "intervals", - min: 1, - max: 999), - )), + NumberInput( + widgetWidth: 60, + numberInputKey: const Key('interval-input'), + numberValue: widget.workout.numExercises == 0 + ? -1 + : widget.workout.numExercises, + formatter: (value) { + return value; + }, + validator: (value) { + if (value == null || value.isEmpty) { + return 'Enter intervals'; + } + return null; + }, + onSaved: (String? val) { + widget.workout.numExercises = int.parse(val!); + }, + onChanged: (text) {}, + unit: "intervals", + min: 1, + max: 999), /// Workout/timer timer display /// diff --git a/lib/create_workout/set_timings.dart b/lib/create_workout/set_timings.dart index 68722b3a..843c805f 100644 --- a/lib/create_workout/set_timings.dart +++ b/lib/create_workout/set_timings.dart @@ -153,7 +153,10 @@ class _SetTimingsState extends State { child: TimeInputTrailing( title: titleList[index], unit: titleList[index] == repeatTitle ? "time(s)" : "s", - widgetWidth: workoutArg.showMinutes == 1 ? 160 : 120, + widgetWidth: (workoutArg.showMinutes == 1 || + titleList[index] == repeatTitle) + ? 150 + : 80, showMinutes: workoutArg.showMinutes, timeInSeconds: time, minutesValidator: (value) { From ba93c2694d1c0e4a423df54cd58deed08337081a Mon Sep 17 00:00:00 2001 From: a-mabe Date: Tue, 13 Feb 2024 19:20:25 -0500 Subject: [PATCH 09/26] Remove requirements to fill out work and rest times If you want a 0 second timer who am I to judge --- lib/create_workout/set_timings.dart | 571 ---------------------------- 1 file changed, 571 deletions(-) diff --git a/lib/create_workout/set_timings.dart b/lib/create_workout/set_timings.dart index 843c805f..883bc882 100644 --- a/lib/create_workout/set_timings.dart +++ b/lib/create_workout/set_timings.dart @@ -160,13 +160,6 @@ class _SetTimingsState extends State { showMinutes: workoutArg.showMinutes, timeInSeconds: time, minutesValidator: (value) { - if ((titleList[index] == workTitle || - titleList[index] == restTitle) && - (value == null || - value.isEmpty || - int.parse(value) == 0)) { - return 'Enter time'; - } return null; }, minutesOnSaved: (value) { @@ -183,13 +176,6 @@ class _SetTimingsState extends State { } }, secondsValidator: (value) { - if ((titleList[index] == workTitle || - titleList[index] == restTitle) && - (value == null || - value.isEmpty || - int.parse(value) == 0)) { - return 'Enter time'; - } return null; }, secondsOnSaved: (value) { @@ -218,12 +204,9 @@ class _SetTimingsState extends State { }, secondsOnChanged: (text) { if (titleList[index] == repeatTitle) { - // setState(() { if (text! != "") { iterationsNotifier.value = int.parse(text); - print("Changed: ${iterationsNotifier.value}"); } - // }); } }, minutesKey: minutesKey, @@ -286,557 +269,3 @@ class _SetTimingsState extends State { } } } - - -// import 'package:auto_size_text/auto_size_text.dart'; -// import 'package:flutter/material.dart'; -// import 'package:openhiit/create_workout/constants/set_timings_constants.dart'; -// import 'package:openhiit/create_workout/helper_widgets/expansion_repeat_tile.dart'; -// import '../workout_data_type/workout_type.dart'; -// import './set_sounds.dart'; -// import 'helper_widgets/number_input.dart'; -// import 'helper_widgets/submit_button.dart'; -// import 'helper_widgets/time_list_item.dart'; -// import 'utils/utils.dart'; - -// class SetTimings extends StatefulWidget { -// const SetTimings({super.key}); - -// @override -// State createState() => _SetTimingsState(); -// } - -// // Define a corresponding State class. -// // This class holds the data related to the Form. -// class _SetTimingsState extends State { -// /// The global key for the form. -// /// -// final formKey = GlobalKey(); - -// int workMinutes = 0; -// int workSeconds = 0; -// int restMinutes = 0; -// int restSeconds = 0; - -// int calcMinutes(int seconds) { -// return (seconds - (seconds % 60)) ~/ 60; -// } - -// int calcSeconds(int seconds) { -// return (seconds % 60); -// } - -// void submitTimings(Workout workout) async { -// // Validate returns true if the form is valid, or false otherwise. -// final form = formKey.currentState!; -// if (form.validate()) { -// form.save(); - -// workout.workTime = (workMinutes * 60) + workSeconds; -// workout.restTime = (restMinutes * 60) + restSeconds; -// workout.breakTime = 0; -// workout.warmupTime = 0; -// workout.cooldownTime = 0; -// workout.iterations = 0; - -// Navigator.push( -// context, -// MaterialPageRoute( -// builder: (context) => const SetSounds(), -// settings: RouteSettings( -// arguments: workout, -// ), -// ), -// ); -// } -// } - -// // Widget returnCombinedForm(Workout workout) { -// // return SizedBox( -// // height: (MediaQuery.of(context).size.height * 10) / 12, -// // child: SingleChildScrollView( -// // child: Padding( -// // padding: const EdgeInsets.all(30), -// // child: Form( -// // key: formKey, -// // child: Column( -// // crossAxisAlignment: CrossAxisAlignment.start, -// // children: [ -// // SizedBox( -// // height: MediaQuery.of(context).size.height / 22, -// // child: const AutoSizeText("Enter the work time:", -// // maxFontSize: 50, -// // minFontSize: 16, -// // style: TextStyle( -// // color: Color.fromARGB(255, 107, 107, 107), -// // fontSize: 30)), -// // ), -// // Row( -// // mainAxisAlignment: MainAxisAlignment.center, -// // children: [ -// // NumberInput( -// // numberInputKey: const Key('work-minutes'), -// // numberValue: workout.workTime, -// // formatter: (value) { -// // int calculation = ((workout.workTime - -// // (workout.workTime % 60)) / -// // 60) -// // .round(); -// // if (calculation == 0) { -// // return ""; -// // } -// // return calculation; -// // }, -// // validator: (value) { -// // if (value == null || value.isEmpty) { -// // return 'Enter time'; -// // } -// // return null; -// // }, -// // onSaved: (value) { -// // setState(() { -// // workMinutes = value!.contains(".") -// // ? int.parse( -// // value.substring(0, value.indexOf("."))) -// // : int.parse(value); -// // }); -// // }, -// // unit: "m", -// // min: 1, -// // max: 99), -// // NumberInput( -// // numberInputKey: const Key('work-seconds'), -// // numberValue: workout.workTime, -// // formatter: (value) { -// // return workout.workTime % 60; -// // }, -// // validator: (value) { -// // return null; -// // }, -// // onSaved: (value) { -// // if (value != "") { -// // setState(() => workSeconds = value!.contains(".") -// // ? int.parse( -// // value.substring(0, value.indexOf("."))) -// // : int.parse(value)); -// // } else { -// // setState(() => workSeconds = 0); -// // } -// // }, -// // unit: "s", -// // min: 0, -// // max: 59), -// // ], -// // ), -// // const SizedBox( -// // height: 30, -// // ), -// // SizedBox( -// // height: MediaQuery.of(context).size.height / 22, -// // child: const AutoSizeText("Enter the rest time:", -// // maxFontSize: 50, -// // minFontSize: 16, -// // style: TextStyle( -// // color: Color.fromARGB(255, 107, 107, 107), -// // fontSize: 30))), -// // Row( -// // mainAxisAlignment: MainAxisAlignment.center, -// // children: [ -// // NumberInput( -// // numberInputKey: const Key('rest-minutes'), -// // numberValue: workout.restTime, -// // formatter: (value) { -// // int calculation = -// // ((workout.restTime - (workout.restTime % 60)) / -// // 60) -// // .round(); -// // if (calculation == 0) { -// // return ""; -// // } -// // return calculation; -// // }, -// // validator: (value) { -// // if (value == null || value.isEmpty) { -// // return 'Enter time'; -// // } -// // return null; -// // }, -// // onSaved: (value) => setState(() => restMinutes = value! -// // .contains(".") -// // ? int.parse(value.substring(0, value.indexOf("."))) -// // : int.parse(value)), -// // unit: "m", -// // min: 1, -// // max: 99), -// // NumberInput( -// // numberInputKey: const Key('rest-seconds'), -// // numberValue: workout.restTime, -// // formatter: (value) { -// // return workout.restTime % 60; -// // }, -// // validator: (value) { -// // return null; -// // }, -// // onSaved: (value) { -// // if (value != "") { -// // setState(() => restSeconds = value!.contains(".") -// // ? int.parse( -// // value.substring(0, value.indexOf("."))) -// // : int.parse(value)); -// // } else { -// // setState(() => restSeconds = 0); -// // } -// // }, -// // unit: "s", -// // min: 0, -// // max: 59), -// // ], -// // ), -// // ], -// // ), -// // ), -// // ))); -// // } - -// // Widget returnMinutesSecondsForm(Workout workout) { -// // return SizedBox( -// // height: (MediaQuery.of(context).size.height * 10) / 12, -// // child: SingleChildScrollView( -// // child: Padding( -// // padding: const EdgeInsets.all(30), -// // child: Form( -// // key: formKey, -// // child: Column( -// // crossAxisAlignment: CrossAxisAlignment.start, -// // children: [ -// // SizedBox( -// // height: MediaQuery.of(context).size.height / 22, -// // child: const AutoSizeText("Enter the work time:", -// // maxFontSize: 50, -// // minFontSize: 16, -// // style: TextStyle( -// // color: Color.fromARGB(255, 107, 107, 107), -// // fontSize: 30)), -// // ), -// // Row( -// // mainAxisAlignment: MainAxisAlignment.center, -// // children: [ -// // NumberInput( -// // numberInputKey: const Key('work-minutes'), -// // numberValue: workout.workTime, -// // formatter: (value) { -// // int calculation = ((workout.workTime - -// // (workout.workTime % 60)) / -// // 60) -// // .round(); -// // if (calculation == 0) { -// // return ""; -// // } -// // return calculation; -// // }, -// // validator: (value) { -// // if (value == null || value.isEmpty) { -// // return 'Enter time'; -// // } -// // return null; -// // }, -// // onSaved: (value) { -// // setState(() { -// // workMinutes = value!.contains(".") -// // ? int.parse( -// // value.substring(0, value.indexOf("."))) -// // : int.parse(value); -// // }); -// // }, -// // unit: "m", -// // min: 1, -// // max: 99), -// // NumberInput( -// // numberInputKey: const Key('work-seconds'), -// // numberValue: workout.workTime, -// // formatter: (value) { -// // return workout.workTime % 60; -// // }, -// // validator: (value) { -// // return null; -// // }, -// // onSaved: (value) { -// // if (value != "") { -// // setState(() => workSeconds = value!.contains(".") -// // ? int.parse( -// // value.substring(0, value.indexOf("."))) -// // : int.parse(value)); -// // } else { -// // setState(() => workSeconds = 0); -// // } -// // }, -// // unit: "s", -// // min: 0, -// // max: 59), -// // ], -// // ), -// // const SizedBox( -// // height: 30, -// // ), -// // SizedBox( -// // height: MediaQuery.of(context).size.height / 22, -// // child: const AutoSizeText("Enter the rest time:", -// // maxFontSize: 50, -// // minFontSize: 16, -// // style: TextStyle( -// // color: Color.fromARGB(255, 107, 107, 107), -// // fontSize: 30))), -// // Row( -// // mainAxisAlignment: MainAxisAlignment.center, -// // children: [ -// // NumberInput( -// // numberInputKey: const Key('rest-minutes'), -// // numberValue: workout.restTime, -// // formatter: (value) { -// // int calculation = -// // ((workout.restTime - (workout.restTime % 60)) / -// // 60) -// // .round(); -// // if (calculation == 0) { -// // return ""; -// // } -// // return calculation; -// // }, -// // validator: (value) { -// // if (value == null || value.isEmpty) { -// // return 'Enter time'; -// // } -// // return null; -// // }, -// // onSaved: (value) => setState(() => restMinutes = value! -// // .contains(".") -// // ? int.parse(value.substring(0, value.indexOf("."))) -// // : int.parse(value)), -// // unit: "m", -// // min: 1, -// // max: 99), -// // NumberInput( -// // numberInputKey: const Key('rest-seconds'), -// // numberValue: workout.restTime, -// // formatter: (value) { -// // return workout.restTime % 60; -// // }, -// // validator: (value) { -// // return null; -// // }, -// // onSaved: (value) { -// // if (value != "") { -// // setState(() => restSeconds = value!.contains(".") -// // ? int.parse( -// // value.substring(0, value.indexOf("."))) -// // : int.parse(value)); -// // } else { -// // setState(() => restSeconds = 0); -// // } -// // }, -// // unit: "s", -// // min: 0, -// // max: 59), -// // ], -// // ), -// // ], -// // ), -// // ), -// // ))); -// // } - -// // Widget returnSecondsForm(Workout workout) { -// // return SizedBox( -// // height: (MediaQuery.of(context).size.height * 10) / 12, -// // child: SingleChildScrollView( -// // child: Padding( -// // padding: const EdgeInsets.all(30), -// // child: Form( -// // key: formKey, -// // child: Column( -// // crossAxisAlignment: CrossAxisAlignment.start, -// // children: [ -// // const Padding( -// // padding: EdgeInsets.fromLTRB(0, 10, 0, 0), -// // child: Text("Enter the work time:", -// // style: TextStyle( -// // color: Color.fromARGB(255, 107, 107, 107), -// // fontSize: 18))), -// // Row( -// // mainAxisAlignment: MainAxisAlignment.center, -// // children: [ -// // NumberInput( -// // numberInputKey: const Key('work-seconds'), -// // numberValue: workout.workTime, -// // formatter: (value) { -// // return workout.workTime; -// // }, -// // validator: (value) { -// // if (value == null || value.isEmpty) { -// // return 'Enter time'; -// // } -// // return null; -// // }, -// // onSaved: (value) { -// // if (value != "") { -// // setState(() => workSeconds = value!.contains(".") -// // ? int.parse( -// // value.substring(0, value.indexOf("."))) -// // : int.parse(value)); -// // } else { -// // setState(() => workSeconds = 0); -// // } -// // }, -// // unit: "s", -// // min: 1, -// // max: 999), -// // ], -// // ), -// // const Padding( -// // padding: EdgeInsets.fromLTRB(0, 20, 0, 0), -// // child: Text("Enter the rest time:", -// // style: TextStyle( -// // color: Color.fromARGB(255, 107, 107, 107), -// // fontSize: 18))), -// // Row( -// // mainAxisAlignment: MainAxisAlignment.center, -// // children: [ -// // NumberInput( -// // numberInputKey: const Key('rest-seconds'), -// // numberValue: workout.restTime, -// // formatter: (value) { -// // return workout.restTime; -// // }, -// // validator: (value) { -// // if (value == null || value.isEmpty) { -// // return 'Enter time'; -// // } -// // return null; -// // }, -// // onSaved: (value) { -// // if (value != "") { -// // setState(() => restSeconds = value!.contains(".") -// // ? int.parse( -// // value.substring(0, value.indexOf("."))) -// // : int.parse(value)); -// // } else { -// // setState(() => restSeconds = 0); -// // } -// // }, -// // unit: "s", -// // min: 1, -// // max: 999), -// // ], -// // ), -// // ], -// // ), -// // ), -// // ))); -// // } - -// @override -// Widget build(BuildContext context) { -// Workout workout = ModalRoute.of(context)!.settings.arguments as Workout; - -// final List items = List.generate( -// timeTitles.length, -// (i) => TimeMessageItem(timeTitles[i], timeSubTitles[i], workout), -// ); - -// return Scaffold( -// appBar: AppBar( -// title: const Text("New Interval Timer"), -// ), -// bottomSheet: SubmitButton( -// text: "Submit", -// color: const Color.fromARGB(255, 58, 165, 255), -// onTap: () { -// submitTimings(workout); -// }, -// ), -// body: ListView.builder( -// // Let the ListView know how many items it needs to build. -// itemCount: items.length + 1, -// // Provide a builder function. This is where the magic happens. -// // Convert each item into a widget based on the type of item it is. -// itemBuilder: (context, index) { -// if (index > 1) { -// return ExpansionRepeatTileClass(); -// } - -// final item = items[index]; - -// return ListTile( -// title: item.buildTitle(context), -// subtitle: item.buildSubtitle(context), -// leading: index < timeLeadingIcons.length -// ? Icon(timeLeadingIcons[index]) -// : const Text(""), -// trailing: buildTrailingWidget(timeTitles[index], workout), -// ); -// }, -// )); -// } - -// Widget buildTrailingWidget(String title, Workout workout) { -// int numberValue = 0, min = 0, max = 0; -// Function onSaved, validator; -// String numberInputKey; - - -// if (workout.showMinutes == 1) { - -// switch (title) { -// case workTitle: -// numberValue = -1; -// onSaved = -// validator = -// break; -// case restTitle: -// numberValue = -1; -// onSaved = -// validator = -// break; -// } - -// return SizedBox( -// width: 120, -// child: Row( -// children: [ -// NumberInput( -// numberValue: 0, -// formatter: secondsFormatter, -// onSaved: (value) {}, -// validator: (value) {}, -// unit: "m", -// min: 0, -// max: 99, -// numberInputKey: const Key('getready-seconds')), -// NumberInput( -// numberValue: numberValue, -// formatter: secondsFormatter, -// onSaved: (value) {}, -// validator: (value) {}, -// unit: "s", -// min: 0, -// max: 59, -// numberInputKey: const Key('getready-seconds')) -// ], -// ), -// ); -// } else { - - - -// return NumberInput( -// numberValue: numberValue, -// formatter: secondsFormatter, -// onSaved: (value) {}, -// validator: (value) {}, -// unit: "s", -// min: 0, -// max: 999, -// numberInputKey: const Key('getready-seconds')); -// } -// } -// } From ee1284565bd34b9b5f6f6889c85404412240d622 Mon Sep 17 00:00:00 2001 From: a-mabe Date: Mon, 19 Feb 2024 10:06:09 -0500 Subject: [PATCH 10/26] Bump DB version, change workTime name --- lib/create_workout/set_timings.dart | 50 +++++++++++++++---------- lib/database/database_manager.dart | 12 +++--- lib/workout_data_type/workout_type.dart | 2 +- 3 files changed, 38 insertions(+), 26 deletions(-) diff --git a/lib/create_workout/set_timings.dart b/lib/create_workout/set_timings.dart index 883bc882..c956203c 100644 --- a/lib/create_workout/set_timings.dart +++ b/lib/create_workout/set_timings.dart @@ -44,7 +44,17 @@ class _SetTimingsState extends State { final formKey = GlobalKey(); - ValueNotifier iterationsNotifier = ValueNotifier(workout.iterations); + // ValueNotifier iterationsNotifier = ValueNotifier(workout.iterations); + + Map> notifierMap = { + "Work": ValueNotifier(workout.workTime), + "Rest": ValueNotifier(workout.restTime), + "Warm-up": ValueNotifier(workout.warmupTime), + "Cool down": ValueNotifier(workout.cooldownTime), + // "Restart": ValueNotifier(workout.iterations), + "Break": ValueNotifier(workout.iterations), + "Get ready": ValueNotifier(workout.getReadyTime) + }; return Scaffold( appBar: AppBar( @@ -64,7 +74,7 @@ class _SetTimingsState extends State { child: ListView.builder( itemCount: timeTitles.length, itemBuilder: (context, index) { - return determineTile(workout, index, iterationsNotifier); + return determineTile(workout, index, notifierMap); })))); } @@ -103,8 +113,8 @@ class _SetTimingsState extends State { } } - Widget determineTile( - Workout workoutArg, int index, ValueNotifier iterationsNotifier) { + Widget determineTile(Workout workoutArg, int index, + Map> notifierMap) { switch (index) { case 0: case 1: @@ -117,9 +127,9 @@ class _SetTimingsState extends State { timeLeadingIcons, timeMinutesKeys[index], timeSecondsKeys[index], - iterationsNotifier); + notifierMap); case 2: - return returnExpansionTile(workoutArg, index, iterationsNotifier); + return returnExpansionTile(workoutArg, index, notifierMap); default: return const Text(""); } @@ -134,21 +144,24 @@ class _SetTimingsState extends State { List iconList, String minutesKey, String secondsKey, - ValueNotifier iterationsNotifier) { + Map> notifierMap) { return ValueListenableBuilder( - valueListenable: iterationsNotifier, + valueListenable: + (titleList[index] == breakTitle || titleList[index] == repeatTitle) + ? notifierMap[breakTitle]! + : notifierMap[titleList[index]]!, builder: (BuildContext context, int val, Widget? child) { return TimeListItem( titleText: titleList[index], subtitleText: subtitleList[index], enabled: titleList[index] == breakTitle - ? (iterationsNotifier.value > 0 ? true : false) + ? (notifierMap[breakTitle]!.value > 0 ? true : false) : true, leadingWidget: iconList[index], trailingWidget: titleList[index] != additionalConfigTitle ? Visibility( visible: titleList[index] == breakTitle - ? (iterationsNotifier.value > 0 ? true : false) + ? (notifierMap[breakTitle]!.value > 0 ? true : false) : true, child: TimeInputTrailing( title: titleList[index], @@ -205,7 +218,7 @@ class _SetTimingsState extends State { secondsOnChanged: (text) { if (titleList[index] == repeatTitle) { if (text! != "") { - iterationsNotifier.value = int.parse(text); + notifierMap[breakTitle]!.value = int.parse(text); } } }, @@ -217,18 +230,18 @@ class _SetTimingsState extends State { }); } - Widget returnExpansionTile( - Workout workoutArg, int index, ValueNotifier iterationsNotifier) { + Widget returnExpansionTile(Workout workoutArg, int index, + Map> notifierMap) { return ExpansionTile( title: Text(timeTitles[index]), subtitle: Text(timeSubTitles[index]), leading: timeLeadingIcons[index], - children: returnAdditionalTiles(workoutArg, index, iterationsNotifier), + children: returnAdditionalTiles(workoutArg, index, notifierMap), ); } - List returnAdditionalTiles( - Workout workoutArg, int index, ValueNotifier iterationsNotifier) { + List returnAdditionalTiles(Workout workoutArg, int index, + Map> notifierMap) { List tileList = []; for (int i = 0; i < additionalTimeTitles.length; i++) { tileList.add(returnTile( @@ -240,10 +253,7 @@ class _SetTimingsState extends State { additionalTimeLeadingIcons, additionalMinutesKeys[index], additionalSecondsKeys[index], - additionalTimeTitles[i] == repeatTitle || - additionalTimeTitles[i] == breakTitle - ? iterationsNotifier - : ValueNotifier(0))); + notifierMap)); } return tileList; } diff --git a/lib/database/database_manager.dart b/lib/database/database_manager.dart index 56fa3ee0..058335f3 100644 --- a/lib/database/database_manager.dart +++ b/lib/database/database_manager.dart @@ -35,7 +35,7 @@ class DatabaseManager { if (Platform.isWindows || Platform.isLinux) { return await openDatabase( inMemoryDatabasePath, - version: 4, + version: 5, onCreate: (db, version) async { await db.execute(''' CREATE TABLE IF NOT EXISTS WorkoutTable(id TEXT PRIMARY KEY, @@ -43,7 +43,7 @@ class DatabaseManager { numExercises INTEGER, exercises TEXT, getReadyTime INTEGER, - workTime INTEGER, + exerciseTime INTEGER, restTime INTEGER, halfTime INTEGER, breakTime INTEGER, @@ -76,6 +76,7 @@ class DatabaseManager { "ALTER TABLE WorkoutTable ADD COLUMN showMinutes INTEGER;"); } if (oldVersion < newVersion) { + print("Add columns"); await db.execute( "ALTER TABLE WorkoutTable ADD COLUMN getReadyTime INTEGER;"); await db.execute( @@ -92,7 +93,7 @@ class DatabaseManager { } return await openDatabase( path, - version: 5, + version: 6, onCreate: (Database db, int version) async { await db.execute(''' CREATE TABLE IF NOT EXISTS WorkoutTable(id TEXT PRIMARY KEY, @@ -100,7 +101,7 @@ class DatabaseManager { numExercises INTEGER, exercises TEXT, getReadyTime INTEGER, - workTime INTEGER, + exerciseTime INTEGER, restTime INTEGER, halfTime INTEGER, breakTime INTEGER, @@ -133,6 +134,7 @@ class DatabaseManager { "ALTER TABLE WorkoutTable ADD COLUMN showMinutes INTEGER;"); } if (oldVersion < newVersion) { + print("Add columns"); await db.execute( "ALTER TABLE WorkoutTable ADD COLUMN getReadyTime INTEGER;"); await db.execute( @@ -215,7 +217,7 @@ class DatabaseManager { maps[i]['numExercises'], maps[i]['exercises'], maps[i]['getReadyTime'] ?? 0, - maps[i]['workTime'], + maps[i]['exerciseTime'], maps[i]['restTime'], maps[i]['halfTime'], maps[i]['breakTime'] ?? 0, diff --git a/lib/workout_data_type/workout_type.dart b/lib/workout_data_type/workout_type.dart index 7f1412da..574c8e50 100644 --- a/lib/workout_data_type/workout_type.dart +++ b/lib/workout_data_type/workout_type.dart @@ -179,7 +179,7 @@ class Workout { 'numExercises': numExercises, 'exercises': exercises, 'getReadyTime': getReadyTime, - 'workTime': workTime, + 'exerciseTime': workTime, 'restTime': restTime, 'halfTime': halfTime, 'breakTime': breakTime, From 3380fe918c3002cddbbeb404c3863b17375c94f3 Mon Sep 17 00:00:00 2001 From: a-mabe Date: Mon, 19 Feb 2024 11:13:28 -0500 Subject: [PATCH 11/26] Revert "Bump DB version, change workTime name" This reverts commit ee1284565bd34b9b5f6f6889c85404412240d622. --- lib/create_workout/set_timings.dart | 50 ++++++++++--------------- lib/database/database_manager.dart | 12 +++--- lib/workout_data_type/workout_type.dart | 2 +- 3 files changed, 26 insertions(+), 38 deletions(-) diff --git a/lib/create_workout/set_timings.dart b/lib/create_workout/set_timings.dart index c956203c..883bc882 100644 --- a/lib/create_workout/set_timings.dart +++ b/lib/create_workout/set_timings.dart @@ -44,17 +44,7 @@ class _SetTimingsState extends State { final formKey = GlobalKey(); - // ValueNotifier iterationsNotifier = ValueNotifier(workout.iterations); - - Map> notifierMap = { - "Work": ValueNotifier(workout.workTime), - "Rest": ValueNotifier(workout.restTime), - "Warm-up": ValueNotifier(workout.warmupTime), - "Cool down": ValueNotifier(workout.cooldownTime), - // "Restart": ValueNotifier(workout.iterations), - "Break": ValueNotifier(workout.iterations), - "Get ready": ValueNotifier(workout.getReadyTime) - }; + ValueNotifier iterationsNotifier = ValueNotifier(workout.iterations); return Scaffold( appBar: AppBar( @@ -74,7 +64,7 @@ class _SetTimingsState extends State { child: ListView.builder( itemCount: timeTitles.length, itemBuilder: (context, index) { - return determineTile(workout, index, notifierMap); + return determineTile(workout, index, iterationsNotifier); })))); } @@ -113,8 +103,8 @@ class _SetTimingsState extends State { } } - Widget determineTile(Workout workoutArg, int index, - Map> notifierMap) { + Widget determineTile( + Workout workoutArg, int index, ValueNotifier iterationsNotifier) { switch (index) { case 0: case 1: @@ -127,9 +117,9 @@ class _SetTimingsState extends State { timeLeadingIcons, timeMinutesKeys[index], timeSecondsKeys[index], - notifierMap); + iterationsNotifier); case 2: - return returnExpansionTile(workoutArg, index, notifierMap); + return returnExpansionTile(workoutArg, index, iterationsNotifier); default: return const Text(""); } @@ -144,24 +134,21 @@ class _SetTimingsState extends State { List iconList, String minutesKey, String secondsKey, - Map> notifierMap) { + ValueNotifier iterationsNotifier) { return ValueListenableBuilder( - valueListenable: - (titleList[index] == breakTitle || titleList[index] == repeatTitle) - ? notifierMap[breakTitle]! - : notifierMap[titleList[index]]!, + valueListenable: iterationsNotifier, builder: (BuildContext context, int val, Widget? child) { return TimeListItem( titleText: titleList[index], subtitleText: subtitleList[index], enabled: titleList[index] == breakTitle - ? (notifierMap[breakTitle]!.value > 0 ? true : false) + ? (iterationsNotifier.value > 0 ? true : false) : true, leadingWidget: iconList[index], trailingWidget: titleList[index] != additionalConfigTitle ? Visibility( visible: titleList[index] == breakTitle - ? (notifierMap[breakTitle]!.value > 0 ? true : false) + ? (iterationsNotifier.value > 0 ? true : false) : true, child: TimeInputTrailing( title: titleList[index], @@ -218,7 +205,7 @@ class _SetTimingsState extends State { secondsOnChanged: (text) { if (titleList[index] == repeatTitle) { if (text! != "") { - notifierMap[breakTitle]!.value = int.parse(text); + iterationsNotifier.value = int.parse(text); } } }, @@ -230,18 +217,18 @@ class _SetTimingsState extends State { }); } - Widget returnExpansionTile(Workout workoutArg, int index, - Map> notifierMap) { + Widget returnExpansionTile( + Workout workoutArg, int index, ValueNotifier iterationsNotifier) { return ExpansionTile( title: Text(timeTitles[index]), subtitle: Text(timeSubTitles[index]), leading: timeLeadingIcons[index], - children: returnAdditionalTiles(workoutArg, index, notifierMap), + children: returnAdditionalTiles(workoutArg, index, iterationsNotifier), ); } - List returnAdditionalTiles(Workout workoutArg, int index, - Map> notifierMap) { + List returnAdditionalTiles( + Workout workoutArg, int index, ValueNotifier iterationsNotifier) { List tileList = []; for (int i = 0; i < additionalTimeTitles.length; i++) { tileList.add(returnTile( @@ -253,7 +240,10 @@ class _SetTimingsState extends State { additionalTimeLeadingIcons, additionalMinutesKeys[index], additionalSecondsKeys[index], - notifierMap)); + additionalTimeTitles[i] == repeatTitle || + additionalTimeTitles[i] == breakTitle + ? iterationsNotifier + : ValueNotifier(0))); } return tileList; } diff --git a/lib/database/database_manager.dart b/lib/database/database_manager.dart index 058335f3..56fa3ee0 100644 --- a/lib/database/database_manager.dart +++ b/lib/database/database_manager.dart @@ -35,7 +35,7 @@ class DatabaseManager { if (Platform.isWindows || Platform.isLinux) { return await openDatabase( inMemoryDatabasePath, - version: 5, + version: 4, onCreate: (db, version) async { await db.execute(''' CREATE TABLE IF NOT EXISTS WorkoutTable(id TEXT PRIMARY KEY, @@ -43,7 +43,7 @@ class DatabaseManager { numExercises INTEGER, exercises TEXT, getReadyTime INTEGER, - exerciseTime INTEGER, + workTime INTEGER, restTime INTEGER, halfTime INTEGER, breakTime INTEGER, @@ -76,7 +76,6 @@ class DatabaseManager { "ALTER TABLE WorkoutTable ADD COLUMN showMinutes INTEGER;"); } if (oldVersion < newVersion) { - print("Add columns"); await db.execute( "ALTER TABLE WorkoutTable ADD COLUMN getReadyTime INTEGER;"); await db.execute( @@ -93,7 +92,7 @@ class DatabaseManager { } return await openDatabase( path, - version: 6, + version: 5, onCreate: (Database db, int version) async { await db.execute(''' CREATE TABLE IF NOT EXISTS WorkoutTable(id TEXT PRIMARY KEY, @@ -101,7 +100,7 @@ class DatabaseManager { numExercises INTEGER, exercises TEXT, getReadyTime INTEGER, - exerciseTime INTEGER, + workTime INTEGER, restTime INTEGER, halfTime INTEGER, breakTime INTEGER, @@ -134,7 +133,6 @@ class DatabaseManager { "ALTER TABLE WorkoutTable ADD COLUMN showMinutes INTEGER;"); } if (oldVersion < newVersion) { - print("Add columns"); await db.execute( "ALTER TABLE WorkoutTable ADD COLUMN getReadyTime INTEGER;"); await db.execute( @@ -217,7 +215,7 @@ class DatabaseManager { maps[i]['numExercises'], maps[i]['exercises'], maps[i]['getReadyTime'] ?? 0, - maps[i]['exerciseTime'], + maps[i]['workTime'], maps[i]['restTime'], maps[i]['halfTime'], maps[i]['breakTime'] ?? 0, diff --git a/lib/workout_data_type/workout_type.dart b/lib/workout_data_type/workout_type.dart index 574c8e50..7f1412da 100644 --- a/lib/workout_data_type/workout_type.dart +++ b/lib/workout_data_type/workout_type.dart @@ -179,7 +179,7 @@ class Workout { 'numExercises': numExercises, 'exercises': exercises, 'getReadyTime': getReadyTime, - 'exerciseTime': workTime, + 'workTime': workTime, 'restTime': restTime, 'halfTime': halfTime, 'breakTime': breakTime, From cafc5cdc5c4046609495259976c2e77161f34b44 Mon Sep 17 00:00:00 2001 From: a-mabe Date: Mon, 19 Feb 2024 11:29:08 -0500 Subject: [PATCH 12/26] Revert "Revert "Bump DB version, change workTime name"" This reverts commit 3380fe918c3002cddbbeb404c3863b17375c94f3. --- lib/create_workout/set_timings.dart | 50 +++++++++++++++---------- lib/database/database_manager.dart | 12 +++--- lib/workout_data_type/workout_type.dart | 2 +- 3 files changed, 38 insertions(+), 26 deletions(-) diff --git a/lib/create_workout/set_timings.dart b/lib/create_workout/set_timings.dart index 883bc882..c956203c 100644 --- a/lib/create_workout/set_timings.dart +++ b/lib/create_workout/set_timings.dart @@ -44,7 +44,17 @@ class _SetTimingsState extends State { final formKey = GlobalKey(); - ValueNotifier iterationsNotifier = ValueNotifier(workout.iterations); + // ValueNotifier iterationsNotifier = ValueNotifier(workout.iterations); + + Map> notifierMap = { + "Work": ValueNotifier(workout.workTime), + "Rest": ValueNotifier(workout.restTime), + "Warm-up": ValueNotifier(workout.warmupTime), + "Cool down": ValueNotifier(workout.cooldownTime), + // "Restart": ValueNotifier(workout.iterations), + "Break": ValueNotifier(workout.iterations), + "Get ready": ValueNotifier(workout.getReadyTime) + }; return Scaffold( appBar: AppBar( @@ -64,7 +74,7 @@ class _SetTimingsState extends State { child: ListView.builder( itemCount: timeTitles.length, itemBuilder: (context, index) { - return determineTile(workout, index, iterationsNotifier); + return determineTile(workout, index, notifierMap); })))); } @@ -103,8 +113,8 @@ class _SetTimingsState extends State { } } - Widget determineTile( - Workout workoutArg, int index, ValueNotifier iterationsNotifier) { + Widget determineTile(Workout workoutArg, int index, + Map> notifierMap) { switch (index) { case 0: case 1: @@ -117,9 +127,9 @@ class _SetTimingsState extends State { timeLeadingIcons, timeMinutesKeys[index], timeSecondsKeys[index], - iterationsNotifier); + notifierMap); case 2: - return returnExpansionTile(workoutArg, index, iterationsNotifier); + return returnExpansionTile(workoutArg, index, notifierMap); default: return const Text(""); } @@ -134,21 +144,24 @@ class _SetTimingsState extends State { List iconList, String minutesKey, String secondsKey, - ValueNotifier iterationsNotifier) { + Map> notifierMap) { return ValueListenableBuilder( - valueListenable: iterationsNotifier, + valueListenable: + (titleList[index] == breakTitle || titleList[index] == repeatTitle) + ? notifierMap[breakTitle]! + : notifierMap[titleList[index]]!, builder: (BuildContext context, int val, Widget? child) { return TimeListItem( titleText: titleList[index], subtitleText: subtitleList[index], enabled: titleList[index] == breakTitle - ? (iterationsNotifier.value > 0 ? true : false) + ? (notifierMap[breakTitle]!.value > 0 ? true : false) : true, leadingWidget: iconList[index], trailingWidget: titleList[index] != additionalConfigTitle ? Visibility( visible: titleList[index] == breakTitle - ? (iterationsNotifier.value > 0 ? true : false) + ? (notifierMap[breakTitle]!.value > 0 ? true : false) : true, child: TimeInputTrailing( title: titleList[index], @@ -205,7 +218,7 @@ class _SetTimingsState extends State { secondsOnChanged: (text) { if (titleList[index] == repeatTitle) { if (text! != "") { - iterationsNotifier.value = int.parse(text); + notifierMap[breakTitle]!.value = int.parse(text); } } }, @@ -217,18 +230,18 @@ class _SetTimingsState extends State { }); } - Widget returnExpansionTile( - Workout workoutArg, int index, ValueNotifier iterationsNotifier) { + Widget returnExpansionTile(Workout workoutArg, int index, + Map> notifierMap) { return ExpansionTile( title: Text(timeTitles[index]), subtitle: Text(timeSubTitles[index]), leading: timeLeadingIcons[index], - children: returnAdditionalTiles(workoutArg, index, iterationsNotifier), + children: returnAdditionalTiles(workoutArg, index, notifierMap), ); } - List returnAdditionalTiles( - Workout workoutArg, int index, ValueNotifier iterationsNotifier) { + List returnAdditionalTiles(Workout workoutArg, int index, + Map> notifierMap) { List tileList = []; for (int i = 0; i < additionalTimeTitles.length; i++) { tileList.add(returnTile( @@ -240,10 +253,7 @@ class _SetTimingsState extends State { additionalTimeLeadingIcons, additionalMinutesKeys[index], additionalSecondsKeys[index], - additionalTimeTitles[i] == repeatTitle || - additionalTimeTitles[i] == breakTitle - ? iterationsNotifier - : ValueNotifier(0))); + notifierMap)); } return tileList; } diff --git a/lib/database/database_manager.dart b/lib/database/database_manager.dart index 56fa3ee0..058335f3 100644 --- a/lib/database/database_manager.dart +++ b/lib/database/database_manager.dart @@ -35,7 +35,7 @@ class DatabaseManager { if (Platform.isWindows || Platform.isLinux) { return await openDatabase( inMemoryDatabasePath, - version: 4, + version: 5, onCreate: (db, version) async { await db.execute(''' CREATE TABLE IF NOT EXISTS WorkoutTable(id TEXT PRIMARY KEY, @@ -43,7 +43,7 @@ class DatabaseManager { numExercises INTEGER, exercises TEXT, getReadyTime INTEGER, - workTime INTEGER, + exerciseTime INTEGER, restTime INTEGER, halfTime INTEGER, breakTime INTEGER, @@ -76,6 +76,7 @@ class DatabaseManager { "ALTER TABLE WorkoutTable ADD COLUMN showMinutes INTEGER;"); } if (oldVersion < newVersion) { + print("Add columns"); await db.execute( "ALTER TABLE WorkoutTable ADD COLUMN getReadyTime INTEGER;"); await db.execute( @@ -92,7 +93,7 @@ class DatabaseManager { } return await openDatabase( path, - version: 5, + version: 6, onCreate: (Database db, int version) async { await db.execute(''' CREATE TABLE IF NOT EXISTS WorkoutTable(id TEXT PRIMARY KEY, @@ -100,7 +101,7 @@ class DatabaseManager { numExercises INTEGER, exercises TEXT, getReadyTime INTEGER, - workTime INTEGER, + exerciseTime INTEGER, restTime INTEGER, halfTime INTEGER, breakTime INTEGER, @@ -133,6 +134,7 @@ class DatabaseManager { "ALTER TABLE WorkoutTable ADD COLUMN showMinutes INTEGER;"); } if (oldVersion < newVersion) { + print("Add columns"); await db.execute( "ALTER TABLE WorkoutTable ADD COLUMN getReadyTime INTEGER;"); await db.execute( @@ -215,7 +217,7 @@ class DatabaseManager { maps[i]['numExercises'], maps[i]['exercises'], maps[i]['getReadyTime'] ?? 0, - maps[i]['workTime'], + maps[i]['exerciseTime'], maps[i]['restTime'], maps[i]['halfTime'], maps[i]['breakTime'] ?? 0, diff --git a/lib/workout_data_type/workout_type.dart b/lib/workout_data_type/workout_type.dart index 7f1412da..574c8e50 100644 --- a/lib/workout_data_type/workout_type.dart +++ b/lib/workout_data_type/workout_type.dart @@ -179,7 +179,7 @@ class Workout { 'numExercises': numExercises, 'exercises': exercises, 'getReadyTime': getReadyTime, - 'workTime': workTime, + 'exerciseTime': workTime, 'restTime': restTime, 'halfTime': halfTime, 'breakTime': breakTime, From ae87fc2436622a75a77ae98a68a915825dbed932 Mon Sep 17 00:00:00 2001 From: a-mabe Date: Mon, 19 Feb 2024 11:31:23 -0500 Subject: [PATCH 13/26] Add wait time --- test/functions.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/functions.dart b/test/functions.dart index fba6a83b..3d93aa24 100644 --- a/test/functions.dart +++ b/test/functions.dart @@ -43,6 +43,7 @@ Future createOrEditWorkout( // Submit the form await tester.tap(find.text( 'Submit')); // Replace 'Submit' with the actual text of your submit button + await tester.pump(const Duration(seconds: 1)); await tester.pumpAndSettle(); /// @@ -62,6 +63,7 @@ Future createOrEditWorkout( await tester.tap(find.text('Submit')); // Wait for the navigation to complete + await tester.pump(const Duration(seconds: 1)); await tester.pumpAndSettle(); } From 719b582c624979126b1217ffa44f5b0bf4e74306 Mon Sep 17 00:00:00 2001 From: a-mabe Date: Mon, 19 Feb 2024 19:12:22 -0500 Subject: [PATCH 14/26] Fixing workout test --- lib/create_workout/create_timer.dart | 27 +---------- lib/create_workout/create_workout.dart | 27 +---------- .../main_widgets/create_form.dart | 7 ++- lib/create_workout/select_timer.dart | 2 +- lib/create_workout/set_sounds.dart | 4 +- lib/start_workout/view_workout.dart | 8 +++- lib/utils/functions.dart | 8 +++- test/functions.dart | 10 ++-- test/interval_timer_test.dart | 4 +- test/workout_test.dart | 48 ++++++++++--------- 10 files changed, 59 insertions(+), 86 deletions(-) diff --git a/lib/create_workout/create_timer.dart b/lib/create_workout/create_timer.dart index 122a7134..0f755ac7 100644 --- a/lib/create_workout/create_timer.dart +++ b/lib/create_workout/create_timer.dart @@ -18,29 +18,6 @@ class CreateTimerState extends State { /// from the previous view. Workout workout = ModalRoute.of(context)!.settings.arguments as Workout; - Workout workoutCopy = Workout( - workout.id, - workout.title, - workout.numExercises, - workout.exercises, - workout.getReadyTime, - workout.workTime, - workout.restTime, - workout.halfTime, - workout.breakTime, - workout.warmupTime, - workout.cooldownTime, - workout.iterations, - workout.halfwayMark, - workout.workSound, - workout.restSound, - workout.halfwaySound, - workout.completeSound, - workout.countdownSound, - workout.colorInt, - workout.workoutIndex, - workout.showMinutes); - // Create a global key that uniquely identifies the Form widget // and allows validation of the form. // @@ -85,9 +62,9 @@ class CreateTimerState extends State { text: "Submit", color: const Color.fromARGB(255, 58, 165, 255), onTap: () { - submitForm(workoutCopy); + submitForm(workout); }, ), - body: CreateForm(workout: workoutCopy, formKey: formKey)); + body: CreateForm(workout: workout, formKey: formKey)); } } diff --git a/lib/create_workout/create_workout.dart b/lib/create_workout/create_workout.dart index eb9c72df..9988a787 100644 --- a/lib/create_workout/create_workout.dart +++ b/lib/create_workout/create_workout.dart @@ -19,29 +19,6 @@ class CreateWorkoutState extends State { /// Workout workout = ModalRoute.of(context)!.settings.arguments as Workout; - Workout workoutCopy = Workout( - workout.id, - workout.title, - workout.numExercises, - workout.exercises, - workout.getReadyTime, - workout.workTime, - workout.restTime, - workout.halfTime, - workout.breakTime, - workout.warmupTime, - workout.cooldownTime, - workout.iterations, - workout.halfwayMark, - workout.workSound, - workout.restSound, - workout.halfwaySound, - workout.completeSound, - workout.countdownSound, - workout.colorInt, - workout.workoutIndex, - workout.showMinutes); - /// Create a global key that uniquely identifies the Form widget /// and allows validation of the form. /// @@ -85,9 +62,9 @@ class CreateWorkoutState extends State { text: "Submit", color: Colors.blue, onTap: () { - submitForm(workoutCopy); + submitForm(workout); }, ), - body: CreateForm(workout: workoutCopy, formKey: formKey)); + body: CreateForm(workout: workout, formKey: formKey)); } } diff --git a/lib/create_workout/main_widgets/create_form.dart b/lib/create_workout/main_widgets/create_form.dart index 62728ee7..fe6a5a2b 100644 --- a/lib/create_workout/main_widgets/create_form.dart +++ b/lib/create_workout/main_widgets/create_form.dart @@ -111,6 +111,9 @@ class CreateFormState extends State { onSaved: (String? val) { widget.workout.title = val!; }, + onChanged: (String? val) { + widget.workout.title = val!; + }, style: const TextStyle(fontSize: 18), ), @@ -169,7 +172,9 @@ class CreateFormState extends State { onSaved: (String? val) { widget.workout.numExercises = int.parse(val!); }, - onChanged: (text) {}, + onChanged: (String? val) { + widget.workout.numExercises = int.parse(val!); + }, unit: "intervals", min: 1, max: 999), diff --git a/lib/create_workout/select_timer.dart b/lib/create_workout/select_timer.dart index fb420859..1a0074a0 100644 --- a/lib/create_workout/select_timer.dart +++ b/lib/create_workout/select_timer.dart @@ -39,7 +39,7 @@ class SelectTimerState extends State { /// TimerOptionCard( onTap: () { - pushCreateWorkout(workout, context); + pushCreateWorkout(workout, context, (value) {}); }, optionIcon: Icons.fitness_center, optionTitle: "Workout", diff --git a/lib/create_workout/set_sounds.dart b/lib/create_workout/set_sounds.dart index ceb178a6..ebde7f91 100644 --- a/lib/create_workout/set_sounds.dart +++ b/lib/create_workout/set_sounds.dart @@ -123,7 +123,7 @@ class _SetSoundsState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ SoundDropdown( - dropdownKey: Key("work-sound"), + dropdownKey: const Key("work-sound"), title: "Work Sound", initialSelection: workout.workSound, pool: pool, @@ -138,7 +138,7 @@ class _SetSoundsState extends State { }); }), SoundDropdown( - dropdownKey: Key("rest-sound"), + dropdownKey: const Key("rest-sound"), title: "Rest Sound", initialSelection: workout.restSound, pool: pool, diff --git a/lib/start_workout/view_workout.dart b/lib/start_workout/view_workout.dart index 4262fc4d..b4156bc4 100644 --- a/lib/start_workout/view_workout.dart +++ b/lib/start_workout/view_workout.dart @@ -119,7 +119,13 @@ class ViewWorkoutState extends State { if (exercises.isEmpty) { pushCreateTimer(workout, context); } else { - pushCreateWorkout(workout, context); + pushCreateWorkout(workout, context, (value) { + /// When we come back, reload the workout arg. + /// + setState(() { + workout = ModalRoute.of(context)!.settings.arguments as Workout; + }); + }); } }, onCopy: () async { diff --git a/lib/utils/functions.dart b/lib/utils/functions.dart index 7844d30a..c8779377 100644 --- a/lib/utils/functions.dart +++ b/lib/utils/functions.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -13,7 +15,9 @@ import '../workout_data_type/workout_type.dart'; /// - [workout]: The 'Workout' object to be passed to the 'CreateWorkout' screen. /// - [context]: The BuildContext required for navigation within the Flutter app. /// -void pushCreateWorkout(Workout workout, BuildContext context) { + +void pushCreateWorkout(Workout workout, BuildContext context, + FutureOr Function(dynamic) then) { Navigator.push( context, MaterialPageRoute( @@ -22,7 +26,7 @@ void pushCreateWorkout(Workout workout, BuildContext context) { arguments: workout, ), ), - ); + ).then(then); } /// Navigates to the 'CreateTimer' screen while passing the provided 'Workout' object diff --git a/test/functions.dart b/test/functions.dart index 3d93aa24..4a294186 100644 --- a/test/functions.dart +++ b/test/functions.dart @@ -4,10 +4,12 @@ import 'package:flutter_test/flutter_test.dart'; Future selectSound(WidgetTester tester, Key key, String soundName) async { await tester.tap(find.byKey(key)); await tester.pump(const Duration(seconds: 1)); - await tester.tap(find.descendant( - of: find.byKey(key), - matching: find.text(soundName), - )); + await tester.tap(find + .descendant( + of: find.byKey(key), + matching: find.text(soundName), + ) + .last); await tester.pumpAndSettle(); } diff --git a/test/interval_timer_test.dart b/test/interval_timer_test.dart index 93e3a627..539cb9d7 100644 --- a/test/interval_timer_test.dart +++ b/test/interval_timer_test.dart @@ -49,7 +49,7 @@ void main() { 3, false, false, - "Long whistle", + "Harsh beep sequence", "Ding", "Quick beep sequence", "Beep", @@ -75,7 +75,7 @@ void main() { await tester.pump(const Duration(seconds: 1)); // skip past the animation await createOrEditWorkout(tester, timerName, 2, false, false, "Ding", - "Long whistle", "Horn", "None", "Quick beep sequence", "90", "20"); + "Thunk", "Horn", "None", "Quick beep sequence", "90", "20"); // Tap the workout to view details await tester.tap(find.text(timerName)); diff --git a/test/workout_test.dart b/test/workout_test.dart index e5137a5e..343815a8 100644 --- a/test/workout_test.dart +++ b/test/workout_test.dart @@ -49,7 +49,7 @@ void main() { 3, true, true, - "Long whistle", + "Harsh beep sequence", "Ding", "Quick beep sequence", "Beep", @@ -58,48 +58,50 @@ void main() { "30"); // Tap the workout to view details - await tester.tap(find.text(workoutName)); + // await tester.tap(find.text(workoutName)); - await tester.pump(); // allow the application to handle + // await tester.pump(); // allow the application to handle - await tester.pump(const Duration(seconds: 1)); // skip past the animation + // await tester.pump(const Duration(seconds: 1)); // skip past the animation - // Verify the ViewWorkout page has loaded - expect(find.text("Start"), findsOneWidget); + // // Verify the ViewWorkout page has loaded + // expect(find.text("Start"), findsOneWidget); - // Find and tap the edit button - await tester.tap(find.byKey(const Key('edit-workout'))); + // // Find and tap the edit button + // await tester.tap(find.byKey(const Key('edit-workout'))); - await tester.pump(); // allow the application to handle + // await tester.pump(); // allow the application to handle - await tester.pump(const Duration(seconds: 1)); // skip past the animation + // await tester.pump(const Duration(seconds: 1)); // skip past the animation - await createOrEditWorkout(tester, workoutName, 2, false, true, "Ding", - "Long whistle", "Horn", "None", "Quick beep sequence", "90", "20"); + // await createOrEditWorkout(tester, workoutName, 2, false, true, "Ding", + // "Thunk", "Horn", "None", "Quick beep sequence", "90", "20"); + + // await tester.takeException(); // Tap the workout to view details - await tester.tap(find.text(workoutName)); + // await tester.tap(find.text(workoutName)); - await tester.pump(); // allow the application to handle + // await tester.pump(); // allow the application to handle - await tester.pump(const Duration(seconds: 1)); // skip past the animation + // await tester.pump(const Duration(seconds: 1)); // skip past the animation // Find and tap the delete button - await tester.tap(find.byKey(const Key('delete-workout'))); + // await tester.tap(find.byKey(const Key('delete-workout'))); // Wait for the dialog to appear - await tester.pump(const Duration(seconds: 1)); + // await tester.pump(const Duration(seconds: 1)); // Verify that the dialog is displayed - expect(find.text('Delete $workoutName'), findsOneWidget); + // expect(find.text('Delete $workoutName'), findsOneWidget); // Tap the Delete button in the dialog - await tester.tap(find.text('Delete')); + // await tester.tap(find.text('Delete')); - // Wait for the dialog to close - await tester.pumpAndSettle(); + // // Wait for the dialog to close + // await tester.pumpAndSettle(); - // Verify that the workout is no longer displayed - expect(find.text(workoutName), findsNothing); + // // Verify that the workout is no longer displayed + // expect(find.text(workoutName), findsNothing); }); } From f049ce1ce914ef2dd39e640d5f22f278d5a4a6e3 Mon Sep 17 00:00:00 2001 From: a-mabe Date: Mon, 19 Feb 2024 19:14:25 -0500 Subject: [PATCH 15/26] Fixing workout test --- test/workout_test.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/workout_test.dart b/test/workout_test.dart index 343815a8..d0ce6927 100644 --- a/test/workout_test.dart +++ b/test/workout_test.dart @@ -58,14 +58,14 @@ void main() { "30"); // Tap the workout to view details - // await tester.tap(find.text(workoutName)); + await tester.tap(find.text(workoutName)); - // await tester.pump(); // allow the application to handle + await tester.pump(); // allow the application to handle - // await tester.pump(const Duration(seconds: 1)); // skip past the animation + await tester.pump(const Duration(seconds: 1)); // skip past the animation // // Verify the ViewWorkout page has loaded - // expect(find.text("Start"), findsOneWidget); + expect(find.text("Start"), findsOneWidget); // // Find and tap the edit button // await tester.tap(find.byKey(const Key('edit-workout'))); From 7c913b5f3ae139b0ad0827ec0c86014b888b8dd8 Mon Sep 17 00:00:00 2001 From: a-mabe Date: Mon, 19 Feb 2024 19:18:29 -0500 Subject: [PATCH 16/26] Fixing workout test --- test/workout_test.dart | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/workout_test.dart b/test/workout_test.dart index d0ce6927..40725691 100644 --- a/test/workout_test.dart +++ b/test/workout_test.dart @@ -64,18 +64,18 @@ void main() { await tester.pump(const Duration(seconds: 1)); // skip past the animation - // // Verify the ViewWorkout page has loaded + // Verify the ViewWorkout page has loaded expect(find.text("Start"), findsOneWidget); - // // Find and tap the edit button - // await tester.tap(find.byKey(const Key('edit-workout'))); + // Find and tap the edit button + await tester.tap(find.byKey(const Key('edit-workout'))); - // await tester.pump(); // allow the application to handle + await tester.pump(); // allow the application to handle - // await tester.pump(const Duration(seconds: 1)); // skip past the animation + await tester.pump(const Duration(seconds: 1)); // skip past the animation - // await createOrEditWorkout(tester, workoutName, 2, false, true, "Ding", - // "Thunk", "Horn", "None", "Quick beep sequence", "90", "20"); + await createOrEditWorkout(tester, workoutName, 2, false, true, "Ding", + "Thunk", "Horn", "None", "Quick beep sequence", "90", "20"); // await tester.takeException(); From 7f64d85e4233dae9275a859fa1e952690f66eba6 Mon Sep 17 00:00:00 2001 From: a-mabe Date: Mon, 19 Feb 2024 20:36:42 -0500 Subject: [PATCH 17/26] Fixing workout test --- lib/create_workout/create_workout.dart | 9 +++++++ .../main_widgets/create_form.dart | 4 ++- lib/create_workout/set_exercises.dart | 7 +++++ lib/start_workout/view_workout.dart | 6 +++-- lib/workout_data_type/workout_type.dart | 26 +++++++++++++++++++ 5 files changed, 49 insertions(+), 3 deletions(-) diff --git a/lib/create_workout/create_workout.dart b/lib/create_workout/create_workout.dart index 9988a787..6d8c3b02 100644 --- a/lib/create_workout/create_workout.dart +++ b/lib/create_workout/create_workout.dart @@ -1,9 +1,14 @@ import 'package:flutter/material.dart'; +import 'package:logger/logger.dart'; import 'package:openhiit/create_workout/main_widgets/create_form.dart'; import '../workout_data_type/workout_type.dart'; import 'main_widgets/submit_button.dart'; import 'set_exercises.dart'; +var logger = Logger( + printer: PrettyPrinter(methodCount: 0), +); + class CreateWorkout extends StatefulWidget { const CreateWorkout({super.key}); @@ -49,6 +54,10 @@ class CreateWorkoutState extends State { final form = formKey.currentState!; if (form.validate()) { form.save(); + + logger.i( + "Title: ${workout.title}, Color: ${workout.colorInt}, Intervals: ${workout.numExercises}"); + pushExercises(workout); } } diff --git a/lib/create_workout/main_widgets/create_form.dart b/lib/create_workout/main_widgets/create_form.dart index fe6a5a2b..1a63b0b5 100644 --- a/lib/create_workout/main_widgets/create_form.dart +++ b/lib/create_workout/main_widgets/create_form.dart @@ -173,7 +173,9 @@ class CreateFormState extends State { widget.workout.numExercises = int.parse(val!); }, onChanged: (String? val) { - widget.workout.numExercises = int.parse(val!); + if (val!.isNotEmpty) { + widget.workout.numExercises = int.parse(val); + } }, unit: "intervals", min: 1, diff --git a/lib/create_workout/set_exercises.dart b/lib/create_workout/set_exercises.dart index c3d02b8e..e5c53ec8 100644 --- a/lib/create_workout/set_exercises.dart +++ b/lib/create_workout/set_exercises.dart @@ -1,9 +1,14 @@ import 'package:flutter/material.dart'; +import 'package:logger/logger.dart'; import 'dart:convert'; import '../workout_data_type/workout_type.dart'; import './set_timings.dart'; import 'main_widgets/submit_button.dart'; +var logger = Logger( + printer: PrettyPrinter(methodCount: 0), +); + class SetExercises extends StatefulWidget { const SetExercises({super.key}); @@ -64,6 +69,8 @@ class _SetExercisesState extends State { /// Generate the list of TextFormFields based off of the number of exercises. /// List generateTextFormFields(Workout workout) { + logger.i("Generating ${workout.numExercises} TextFormFields"); + return List.generate(workout.numExercises, (int index) { return Padding( padding: const EdgeInsets.fromLTRB(40.0, 15.0, 40.0, 15.0), diff --git a/lib/start_workout/view_workout.dart b/lib/start_workout/view_workout.dart index b4156bc4..3b99a53a 100644 --- a/lib/start_workout/view_workout.dart +++ b/lib/start_workout/view_workout.dart @@ -116,10 +116,12 @@ class ViewWorkoutState extends State { Navigator.of(context).pop(); }, onEdit: () { + Workout workoutCopy = workout.copy(); + if (exercises.isEmpty) { - pushCreateTimer(workout, context); + pushCreateTimer(workoutCopy, context); } else { - pushCreateWorkout(workout, context, (value) { + pushCreateWorkout(workoutCopy, context, (value) { /// When we come back, reload the workout arg. /// setState(() { diff --git a/lib/workout_data_type/workout_type.dart b/lib/workout_data_type/workout_type.dart index 574c8e50..36a0db81 100644 --- a/lib/workout_data_type/workout_type.dart +++ b/lib/workout_data_type/workout_type.dart @@ -198,6 +198,32 @@ class Workout { }; } + Workout copy() { + return Workout( + id, + title, + numExercises, + exercises, + getReadyTime, + workTime, + restTime, + halfTime, + breakTime, + warmupTime, + cooldownTime, + iterations, + halfwayMark, + workSound, + restSound, + halfwaySound, + completeSound, + countdownSound, + colorInt, + workoutIndex, + showMinutes, + ); + } + /// Implement toString to print information about /// each Workout more easily. /// From a863ee634516916bd1db72f14a326222804702b3 Mon Sep 17 00:00:00 2001 From: a-mabe Date: Mon, 19 Feb 2024 20:39:19 -0500 Subject: [PATCH 18/26] Fixing workout test --- test/workout_test.dart | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/test/workout_test.dart b/test/workout_test.dart index 40725691..d651d15b 100644 --- a/test/workout_test.dart +++ b/test/workout_test.dart @@ -77,31 +77,29 @@ void main() { await createOrEditWorkout(tester, workoutName, 2, false, true, "Ding", "Thunk", "Horn", "None", "Quick beep sequence", "90", "20"); - // await tester.takeException(); - // Tap the workout to view details - // await tester.tap(find.text(workoutName)); + await tester.tap(find.text(workoutName)); - // await tester.pump(); // allow the application to handle + await tester.pump(); // allow the application to handle - // await tester.pump(const Duration(seconds: 1)); // skip past the animation + await tester.pump(const Duration(seconds: 1)); // skip past the animation // Find and tap the delete button - // await tester.tap(find.byKey(const Key('delete-workout'))); + await tester.tap(find.byKey(const Key('delete-workout'))); // Wait for the dialog to appear - // await tester.pump(const Duration(seconds: 1)); + await tester.pump(const Duration(seconds: 1)); // Verify that the dialog is displayed - // expect(find.text('Delete $workoutName'), findsOneWidget); + expect(find.text('Delete $workoutName'), findsOneWidget); // Tap the Delete button in the dialog - // await tester.tap(find.text('Delete')); + await tester.tap(find.text('Delete')); - // // Wait for the dialog to close - // await tester.pumpAndSettle(); + // Wait for the dialog to close + await tester.pumpAndSettle(); - // // Verify that the workout is no longer displayed - // expect(find.text(workoutName), findsNothing); + // Verify that the workout is no longer displayed + expect(find.text(workoutName), findsNothing); }); } From 2335e0a2bf7018fe512c18768ac2d88226193b15 Mon Sep 17 00:00:00 2001 From: a-mabe Date: Mon, 26 Feb 2024 20:07:23 -0500 Subject: [PATCH 19/26] Bug fixes --- ios/Podfile.lock | 2 +- lib/create_workout/set_timings.dart | 32 ++++++++----- lib/database/database_manager.dart | 2 +- pubspec.lock | 74 +++++++++++++++++++---------- 4 files changed, 70 insertions(+), 40 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 4b5088f4..ad8a1f54 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -75,7 +75,7 @@ SPEC CHECKSUMS: audio_session: 4f3e461722055d21515cf3261b64c973c062f345 audioplayers_darwin: 877d9a4d06331c5c374595e46e16453ac7eafa40 device_info_plus: e5c5da33f982a436e103237c0c85f9031142abed - Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 + Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 flutter_background_service_ios: e30e0d3ee69e4cee66272d0c78eacd48c2e94aac flutter_fgbg: 31c0d1140a131daea2d342121808f6aa0dcd879d flutter_local_notifications: 0c0b1ae97e741e1521e4c1629a459d04b9aec743 diff --git a/lib/create_workout/set_timings.dart b/lib/create_workout/set_timings.dart index c956203c..d7461769 100644 --- a/lib/create_workout/set_timings.dart +++ b/lib/create_workout/set_timings.dart @@ -38,14 +38,14 @@ class _SetTimingsState extends State { int repeat = 0; + bool hasExpanded = false; + + final formKey = GlobalKey(); + @override Widget build(BuildContext context) { Workout workout = ModalRoute.of(context)!.settings.arguments as Workout; - final formKey = GlobalKey(); - - // ValueNotifier iterationsNotifier = ValueNotifier(workout.iterations); - Map> notifierMap = { "Work": ValueNotifier(workout.workTime), "Rest": ValueNotifier(workout.restTime), @@ -88,15 +88,18 @@ class _SetTimingsState extends State { timeMap["$workTitle-seconds"]!; workoutArg.restTime = (timeMap["$restTitle-minutes"]! * 60) + timeMap["$restTitle-seconds"]!; - workoutArg.getReadyTime = (timeMap["$getReadyTitle-minutes"]! * 60) + - timeMap["$getReadyTitle-seconds"]!; - workoutArg.warmupTime = (timeMap["$warmUpTitle-minutes"]! * 60) + - timeMap["$warmUpTitle-seconds"]!; - workoutArg.cooldownTime = (timeMap["$coolDownTitle-minutes"]! * 60) + - timeMap["$coolDownTitle-seconds"]!; - workoutArg.breakTime = (timeMap["$breakTitle-minutes"]! * 60) + - timeMap["$breakTitle-seconds"]!; - workoutArg.iterations = repeat; + + if (hasExpanded) { + workoutArg.getReadyTime = (timeMap["$getReadyTitle-minutes"]! * 60) + + timeMap["$getReadyTitle-seconds"]!; + workoutArg.warmupTime = (timeMap["$warmUpTitle-minutes"]! * 60) + + timeMap["$warmUpTitle-seconds"]!; + workoutArg.cooldownTime = (timeMap["$coolDownTitle-minutes"]! * 60) + + timeMap["$coolDownTitle-seconds"]!; + workoutArg.breakTime = (timeMap["$breakTitle-minutes"]! * 60) + + timeMap["$breakTitle-seconds"]!; + workoutArg.iterations = repeat; + } logger.i("Saving workout: ${workoutArg.toString()}"); logger.i(repeat); @@ -237,6 +240,9 @@ class _SetTimingsState extends State { subtitle: Text(timeSubTitles[index]), leading: timeLeadingIcons[index], children: returnAdditionalTiles(workoutArg, index, notifierMap), + onExpansionChanged: (expanded) { + hasExpanded = true; + }, ); } diff --git a/lib/database/database_manager.dart b/lib/database/database_manager.dart index 058335f3..9a0c9163 100644 --- a/lib/database/database_manager.dart +++ b/lib/database/database_manager.dart @@ -216,7 +216,7 @@ class DatabaseManager { maps[i]['title'], maps[i]['numExercises'], maps[i]['exercises'], - maps[i]['getReadyTime'] ?? 0, + maps[i]['getReadyTime'] ?? 10, maps[i]['exerciseTime'], maps[i]['restTime'], maps[i]['halfTime'], diff --git a/pubspec.lock b/pubspec.lock index f3efc958..64624126 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -102,7 +102,7 @@ packages: description: path: "." ref: cleanup - resolved-ref: c661b5e36993df2861f4f8115f23687ae82527f7 + resolved-ref: "844ce224d120cedf34b5daa8e6535db215b2d64a" url: "https://github.com/a-mabe/background_timer.git" source: git version: "0.0.1" @@ -230,10 +230,10 @@ packages: dependency: transitive description: name: ffi - sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878" + sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21" url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.2" file: dependency: transitive description: @@ -367,10 +367,10 @@ packages: dependency: transitive description: name: http - sha256: a2bbf9d017fcced29139daa8ed2bba4ece450ab222871df93ca9eec6f80c34ba + sha256: "761a297c042deedc1ffbb156d6e2af13886bb305c2a343a4d972504cd67dd938" url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.2.1" http_parser: dependency: transitive description: @@ -383,10 +383,10 @@ packages: dependency: transitive description: name: image - sha256: "49a0d4b0c12402853d3f227fe7c315601b238d126aa4caa5dbb2dcf99421aa4a" + sha256: "4c68bfd5ae83e700b5204c1e74451e7bf3cf750e6843c6e158289cf56bda018e" url: "https://pub.dev" source: hosted - version: "4.1.6" + version: "4.1.7" infinite_listview: dependency: transitive description: @@ -435,6 +435,30 @@ packages: url: "https://pub.dev" source: hosted version: "0.4.9" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" + url: "https://pub.dev" + source: hosted + version: "10.0.0" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 + url: "https://pub.dev" + source: hosted + version: "2.0.1" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 + url: "https://pub.dev" + source: hosted + version: "2.0.1" lints: dependency: transitive description: @@ -463,26 +487,26 @@ packages: dependency: transitive description: name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted - version: "0.12.16" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "0.8.0" meta: dependency: transitive description: name: meta - sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.0" numberpicker: dependency: "direct main" description: @@ -503,10 +527,10 @@ packages: dependency: "direct main" description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.8.3" + version: "1.9.0" path_provider: dependency: transitive description: @@ -639,10 +663,10 @@ packages: dependency: transitive description: name: shared_preferences_web - sha256: "7b15ffb9387ea3e237bb7a66b8a23d2147663d391cafc5c8f37b2e7b4bde5d21" + sha256: "9aee1089b36bd2aafe06582b7d7817fd317ef05fc30e6ba14bff247d0933042a" url: "https://pub.dev" source: hosted - version: "2.2.2" + version: "2.3.0" shared_preferences_windows: dependency: transitive description: @@ -748,10 +772,10 @@ packages: dependency: transitive description: name: sqlite3 - sha256: c4a4c5a4b2a32e2d0f6837b33d7c91a67903891a5b7dbe706cf4b1f6b0c798c5 + sha256: "072128763f1547e3e9b4735ce846bfd226d68019ccda54db4cd427b12dfdedc9" url: "https://pub.dev" source: hosted - version: "2.3.0" + version: "2.4.0" stack_trace: dependency: transitive description: @@ -844,10 +868,10 @@ packages: dependency: transitive description: name: vm_service - sha256: a2662fb1f114f4296cf3f5a50786a2d888268d7776cf681aa17d660ffa23b246 + sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 url: "https://pub.dev" source: hosted - version: "14.0.0" + version: "13.0.0" wakelock: dependency: "direct main" description: @@ -892,10 +916,10 @@ packages: dependency: transitive description: name: web - sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 + sha256: "1d9158c616048c38f712a6646e317a3426da10e884447626167240d45209cbad" url: "https://pub.dev" source: hosted - version: "0.3.0" + version: "0.5.0" win32: dependency: transitive description: @@ -929,5 +953,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.2.0 <4.0.0" - flutter: ">=3.16.0" + dart: ">=3.3.0 <4.0.0" + flutter: ">=3.19.0" From 9ca6c96bd997c982436212c061abf1fdedcb3137 Mon Sep 17 00:00:00 2001 From: a-mabe Date: Tue, 12 Mar 2024 15:58:09 -0400 Subject: [PATCH 20/26] Add text editing controller --- .../form_picker_widgets/number_input.dart | 11 ++++++++--- .../form_picker_widgets/time_input_trailing.dart | 10 +++++++--- lib/create_workout/main_widgets/create_form.dart | 1 + lib/create_workout/set_timings.dart | 2 ++ lib/main.dart | 8 ++++---- test/interval_timer_test.dart | 2 +- test/run_timer.dart | 2 +- test/workout_test.dart | 2 +- 8 files changed, 25 insertions(+), 13 deletions(-) diff --git a/lib/create_workout/form_picker_widgets/number_input.dart b/lib/create_workout/form_picker_widgets/number_input.dart index a97bc0bc..7643ef5c 100644 --- a/lib/create_workout/form_picker_widgets/number_input.dart +++ b/lib/create_workout/form_picker_widgets/number_input.dart @@ -18,6 +18,8 @@ class NumberInput extends StatefulWidget { final String title; + final TextEditingController controller; + final Key numberInputKey; final Function formatter; @@ -40,6 +42,7 @@ class NumberInput extends StatefulWidget { required this.min, required this.max, required this.numberInputKey, + required this.controller, this.title = "", }); @@ -60,6 +63,10 @@ class NumberInputState extends State { @override Widget build(BuildContext context) { + widget.controller.text = widget.numberValue == -1 + ? "" + : widget.formatter(widget.numberValue).toString(); + return Row( crossAxisAlignment: CrossAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.center, @@ -68,9 +75,7 @@ class NumberInputState extends State { width: widget.widgetWidth, child: TextFormField( key: widget.numberInputKey, - initialValue: widget.numberValue == -1 - ? "" - : widget.formatter(widget.numberValue).toString(), + controller: widget.controller, keyboardType: TextInputType.number, inputFormatters: [ FilteringTextInputFormatter.digitsOnly, diff --git a/lib/create_workout/form_picker_widgets/time_input_trailing.dart b/lib/create_workout/form_picker_widgets/time_input_trailing.dart index 2b51be32..5eacc5e3 100644 --- a/lib/create_workout/form_picker_widgets/time_input_trailing.dart +++ b/lib/create_workout/form_picker_widgets/time_input_trailing.dart @@ -14,13 +14,13 @@ class TimeInputTrailing extends StatefulWidget { final String minutesKey; final String secondsKey; + final TextEditingController? minutesController; + final TextEditingController? secondsController; + final String unit; final String title; - // final Function? minutesFormatter; - // final Function? secondsFormatter; - final Function(String?)? minutesOnSaved; final Function(String?)? secondsOnSaved; @@ -39,6 +39,8 @@ class TimeInputTrailing extends StatefulWidget { this.title = "", this.minutesOnSaved, this.secondsOnSaved, + required this.minutesController, + required this.secondsController, this.minutesValidator, this.secondsValidator, required this.secondsOnChanged, @@ -72,6 +74,7 @@ class TimeInputTrailingState extends State { child: NumberInput( widgetWidth: 50, numberValue: widget.timeInSeconds, + controller: widget.minutesController!, formatter: minutesFormatter, onSaved: widget.minutesOnSaved!, onChanged: (text) {}, @@ -84,6 +87,7 @@ class TimeInputTrailingState extends State { title: widget.title, widgetWidth: 50, numberValue: widget.timeInSeconds, + controller: widget.secondsController!, formatter: widget.showMinutes == 1 ? secondsRemainderFormatter : secondsFormatter, diff --git a/lib/create_workout/main_widgets/create_form.dart b/lib/create_workout/main_widgets/create_form.dart index 1a63b0b5..0ee26462 100644 --- a/lib/create_workout/main_widgets/create_form.dart +++ b/lib/create_workout/main_widgets/create_form.dart @@ -157,6 +157,7 @@ class CreateFormState extends State { NumberInput( widgetWidth: 60, numberInputKey: const Key('interval-input'), + controller: TextEditingController(), numberValue: widget.workout.numExercises == 0 ? -1 : widget.workout.numExercises, diff --git a/lib/create_workout/set_timings.dart b/lib/create_workout/set_timings.dart index d7461769..ce26a099 100644 --- a/lib/create_workout/set_timings.dart +++ b/lib/create_workout/set_timings.dart @@ -168,6 +168,8 @@ class _SetTimingsState extends State { : true, child: TimeInputTrailing( title: titleList[index], + minutesController: TextEditingController(), + secondsController: TextEditingController(), unit: titleList[index] == repeatTitle ? "time(s)" : "s", widgetWidth: (workoutArg.showMinutes == 1 || titleList[index] == repeatTitle) diff --git a/lib/main.dart b/lib/main.dart index e6711e3e..b3a396ef 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -25,17 +25,17 @@ void main() async { yield LicenseEntryWithLineBreaks(['google_fonts'], license); }); - runApp(const WorkoutTimer()); + runApp(const workoutTimerTest()); } -class WorkoutTimer extends StatelessWidget { - const WorkoutTimer({super.key}); +class workoutTimerTest extends StatelessWidget { + const workoutTimerTest({super.key}); /// Application root. @override Widget build(BuildContext context) { return MaterialApp( - title: 'OpenHIIT', + title: 'openhiit', debugShowCheckedModeBanner: false, theme: ThemeData(), darkTheme: ThemeData.dark(), // standard dark theme diff --git a/test/interval_timer_test.dart b/test/interval_timer_test.dart index 539cb9d7..29bc783a 100644 --- a/test/interval_timer_test.dart +++ b/test/interval_timer_test.dart @@ -19,7 +19,7 @@ void main() { String timerName = "Test interval timer 1"; // Build our app and trigger a frame. - await tester.pumpWidget(const WorkoutTimer()); + await tester.pumpWidget(const workoutTimerTest()); // Tap the '+' icon and trigger the add Workout or Timer page. await tester.tap(find.byIcon(Icons.add)); diff --git a/test/run_timer.dart b/test/run_timer.dart index 9fd89ec2..b90c901b 100644 --- a/test/run_timer.dart +++ b/test/run_timer.dart @@ -19,7 +19,7 @@ void main() { String workoutName = "Test workout 1"; // Build our app and trigger a frame. - await tester.pumpWidget(const WorkoutTimer()); + await tester.pumpWidget(const workoutTimerTest()); // Tap the '+' icon and trigger the add Workout or Timer page. await tester.tap(find.byIcon(Icons.add)); diff --git a/test/workout_test.dart b/test/workout_test.dart index d651d15b..a0a153b1 100644 --- a/test/workout_test.dart +++ b/test/workout_test.dart @@ -19,7 +19,7 @@ void main() { String workoutName = "Test workout 1"; // Build our app and trigger a frame. - await tester.pumpWidget(const WorkoutTimer()); + await tester.pumpWidget(const workoutTimerTest()); // Tap the '+' icon and trigger the add Workout or Timer page. await tester.tap(find.byIcon(Icons.add)); From 664a2c015d700ec4ff082c0e69c5bf2f0753ee6b Mon Sep 17 00:00:00 2001 From: a-mabe Date: Tue, 12 Mar 2024 15:59:41 -0400 Subject: [PATCH 21/26] Revert workout test name --- lib/main.dart | 6 +++--- test/interval_timer_test.dart | 2 +- test/run_timer.dart | 2 +- test/workout_test.dart | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index b3a396ef..f448a9cf 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -25,11 +25,11 @@ void main() async { yield LicenseEntryWithLineBreaks(['google_fonts'], license); }); - runApp(const workoutTimerTest()); + runApp(const workouttimer()); } -class workoutTimerTest extends StatelessWidget { - const workoutTimerTest({super.key}); +class workouttimer extends StatelessWidget { + const workouttimer({super.key}); /// Application root. @override diff --git a/test/interval_timer_test.dart b/test/interval_timer_test.dart index 29bc783a..df515867 100644 --- a/test/interval_timer_test.dart +++ b/test/interval_timer_test.dart @@ -19,7 +19,7 @@ void main() { String timerName = "Test interval timer 1"; // Build our app and trigger a frame. - await tester.pumpWidget(const workoutTimerTest()); + await tester.pumpWidget(const workouttimer()); // Tap the '+' icon and trigger the add Workout or Timer page. await tester.tap(find.byIcon(Icons.add)); diff --git a/test/run_timer.dart b/test/run_timer.dart index b90c901b..e03f7045 100644 --- a/test/run_timer.dart +++ b/test/run_timer.dart @@ -19,7 +19,7 @@ void main() { String workoutName = "Test workout 1"; // Build our app and trigger a frame. - await tester.pumpWidget(const workoutTimerTest()); + await tester.pumpWidget(const workouttimer()); // Tap the '+' icon and trigger the add Workout or Timer page. await tester.tap(find.byIcon(Icons.add)); diff --git a/test/workout_test.dart b/test/workout_test.dart index a0a153b1..5f09cedc 100644 --- a/test/workout_test.dart +++ b/test/workout_test.dart @@ -19,7 +19,7 @@ void main() { String workoutName = "Test workout 1"; // Build our app and trigger a frame. - await tester.pumpWidget(const workoutTimerTest()); + await tester.pumpWidget(const workouttimer()); // Tap the '+' icon and trigger the add Workout or Timer page. await tester.tap(find.byIcon(Icons.add)); From 9410c195a2a0faa5a4456e039b40e0697d61b8a6 Mon Sep 17 00:00:00 2001 From: a-mabe Date: Tue, 12 Mar 2024 16:00:52 -0400 Subject: [PATCH 22/26] Revert workout test name --- lib/main.dart | 6 +++--- test/interval_timer_test.dart | 2 +- test/run_timer.dart | 2 +- test/workout_test.dart | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index f448a9cf..789a45d9 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -25,11 +25,11 @@ void main() async { yield LicenseEntryWithLineBreaks(['google_fonts'], license); }); - runApp(const workouttimer()); + runApp(const workoutTimer()); } -class workouttimer extends StatelessWidget { - const workouttimer({super.key}); +class workoutTimer extends StatelessWidget { + const workoutTimer({super.key}); /// Application root. @override diff --git a/test/interval_timer_test.dart b/test/interval_timer_test.dart index df515867..03c5b9cc 100644 --- a/test/interval_timer_test.dart +++ b/test/interval_timer_test.dart @@ -19,7 +19,7 @@ void main() { String timerName = "Test interval timer 1"; // Build our app and trigger a frame. - await tester.pumpWidget(const workouttimer()); + await tester.pumpWidget(const workoutTimer()); // Tap the '+' icon and trigger the add Workout or Timer page. await tester.tap(find.byIcon(Icons.add)); diff --git a/test/run_timer.dart b/test/run_timer.dart index e03f7045..5d25c2b1 100644 --- a/test/run_timer.dart +++ b/test/run_timer.dart @@ -19,7 +19,7 @@ void main() { String workoutName = "Test workout 1"; // Build our app and trigger a frame. - await tester.pumpWidget(const workouttimer()); + await tester.pumpWidget(const workoutTimer()); // Tap the '+' icon and trigger the add Workout or Timer page. await tester.tap(find.byIcon(Icons.add)); diff --git a/test/workout_test.dart b/test/workout_test.dart index 5f09cedc..c4ca4062 100644 --- a/test/workout_test.dart +++ b/test/workout_test.dart @@ -19,7 +19,7 @@ void main() { String workoutName = "Test workout 1"; // Build our app and trigger a frame. - await tester.pumpWidget(const workouttimer()); + await tester.pumpWidget(const workoutTimer()); // Tap the '+' icon and trigger the add Workout or Timer page. await tester.tap(find.byIcon(Icons.add)); From 011f265c98b5adb47a8c4b0c1def11627867cf76 Mon Sep 17 00:00:00 2001 From: a-mabe Date: Tue, 12 Mar 2024 16:02:05 -0400 Subject: [PATCH 23/26] Revert workout test name --- test/interval_timer_test.dart | 2 +- test/run_timer.dart | 2 +- test/workout_test.dart | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/interval_timer_test.dart b/test/interval_timer_test.dart index 03c5b9cc..539cb9d7 100644 --- a/test/interval_timer_test.dart +++ b/test/interval_timer_test.dart @@ -19,7 +19,7 @@ void main() { String timerName = "Test interval timer 1"; // Build our app and trigger a frame. - await tester.pumpWidget(const workoutTimer()); + await tester.pumpWidget(const WorkoutTimer()); // Tap the '+' icon and trigger the add Workout or Timer page. await tester.tap(find.byIcon(Icons.add)); diff --git a/test/run_timer.dart b/test/run_timer.dart index 5d25c2b1..9fd89ec2 100644 --- a/test/run_timer.dart +++ b/test/run_timer.dart @@ -19,7 +19,7 @@ void main() { String workoutName = "Test workout 1"; // Build our app and trigger a frame. - await tester.pumpWidget(const workoutTimer()); + await tester.pumpWidget(const WorkoutTimer()); // Tap the '+' icon and trigger the add Workout or Timer page. await tester.tap(find.byIcon(Icons.add)); diff --git a/test/workout_test.dart b/test/workout_test.dart index c4ca4062..d651d15b 100644 --- a/test/workout_test.dart +++ b/test/workout_test.dart @@ -19,7 +19,7 @@ void main() { String workoutName = "Test workout 1"; // Build our app and trigger a frame. - await tester.pumpWidget(const workoutTimer()); + await tester.pumpWidget(const WorkoutTimer()); // Tap the '+' icon and trigger the add Workout or Timer page. await tester.tap(find.byIcon(Icons.add)); From df027900172bbf2092845fb3a5f5e72f97b00c45 Mon Sep 17 00:00:00 2001 From: a-mabe Date: Tue, 12 Mar 2024 16:03:12 -0400 Subject: [PATCH 24/26] revert names --- lib/main.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 789a45d9..e6711e3e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -25,17 +25,17 @@ void main() async { yield LicenseEntryWithLineBreaks(['google_fonts'], license); }); - runApp(const workoutTimer()); + runApp(const WorkoutTimer()); } -class workoutTimer extends StatelessWidget { - const workoutTimer({super.key}); +class WorkoutTimer extends StatelessWidget { + const WorkoutTimer({super.key}); /// Application root. @override Widget build(BuildContext context) { return MaterialApp( - title: 'openhiit', + title: 'OpenHIIT', debugShowCheckedModeBanner: false, theme: ThemeData(), darkTheme: ThemeData.dark(), // standard dark theme From 7c80d528bab65352a92c5638f948a1276e1ed44e Mon Sep 17 00:00:00 2001 From: a-mabe Date: Sat, 16 Mar 2024 13:28:59 -0400 Subject: [PATCH 25/26] Use singlechildscrollview instead of list builder --- lib/create_workout/set_timings.dart | 21 +++++++++--------- lib/start_workout/workout.dart | 3 ++- lib/utils/functions.dart | 33 +++++++++++++++++++---------- pubspec.lock | 14 ++++++------ 4 files changed, 42 insertions(+), 29 deletions(-) diff --git a/lib/create_workout/set_timings.dart b/lib/create_workout/set_timings.dart index ce26a099..e1a348ac 100644 --- a/lib/create_workout/set_timings.dart +++ b/lib/create_workout/set_timings.dart @@ -51,7 +51,7 @@ class _SetTimingsState extends State { "Rest": ValueNotifier(workout.restTime), "Warm-up": ValueNotifier(workout.warmupTime), "Cool down": ValueNotifier(workout.cooldownTime), - // "Restart": ValueNotifier(workout.iterations), + "Restart": ValueNotifier(workout.iterations), "Break": ValueNotifier(workout.iterations), "Get ready": ValueNotifier(workout.getReadyTime) }; @@ -71,11 +71,13 @@ class _SetTimingsState extends State { padding: const EdgeInsets.fromLTRB(0, 0, 0, 120), child: Form( key: formKey, - child: ListView.builder( - itemCount: timeTitles.length, - itemBuilder: (context, index) { - return determineTile(workout, index, notifierMap); - })))); + child: SingleChildScrollView( + child: Column( + children: List.generate( + timeTitles.length, + (int index) => + determineTile(workout, index, notifierMap))), + )))); } void submitTimings(Workout workoutArg, GlobalKey formKey) { @@ -149,10 +151,9 @@ class _SetTimingsState extends State { String secondsKey, Map> notifierMap) { return ValueListenableBuilder( - valueListenable: - (titleList[index] == breakTitle || titleList[index] == repeatTitle) - ? notifierMap[breakTitle]! - : notifierMap[titleList[index]]!, + valueListenable: (titleList[index] == breakTitle) + ? notifierMap[breakTitle]! + : notifierMap[titleList[index]]!, builder: (BuildContext context, int val, Widget? child) { return TimeListItem( titleText: titleList[index], diff --git a/lib/start_workout/workout.dart b/lib/start_workout/workout.dart index a230df1c..5aa1b857 100644 --- a/lib/start_workout/workout.dart +++ b/lib/start_workout/workout.dart @@ -330,7 +330,8 @@ class CountDownTimerState extends State if (timerData.status == "complete" && restart == false) { done = true; - } else if (timerData.status == "start") { + } else if (timerData.status == "start" && + timerData.iterations == workoutArgument.iterations) { currentWorkInterval = 0; ListModel intervalList = ListModel( listKey: listKey, diff --git a/lib/utils/functions.dart b/lib/utils/functions.dart index c8779377..efbdd9b6 100644 --- a/lib/utils/functions.dart +++ b/lib/utils/functions.dart @@ -169,17 +169,28 @@ List listItems(List exercises, Workout workoutArg) { ); } else if (interval == workoutArg.numExercises && workoutArg.iterations > 0 && - iteration < workoutArg.iterations && - workoutArg.breakTime > 0) { - listItems.add( - ListTileModel( - action: "Break", - showMinutes: workoutArg.showMinutes, - interval: 0, - total: workoutArg.numExercises, - seconds: workoutArg.breakTime, - ), - ); + iteration < workoutArg.iterations) { + if (workoutArg.breakTime > 0) { + listItems.add( + ListTileModel( + action: "Break", + showMinutes: workoutArg.showMinutes, + interval: 0, + total: workoutArg.numExercises, + seconds: workoutArg.breakTime, + ), + ); + } else { + listItems.add( + ListTileModel( + action: "Get ready", + showMinutes: workoutArg.showMinutes, + interval: 0, + total: workoutArg.numExercises, + seconds: workoutArg.getReadyTime, + ), + ); + } } } } diff --git a/pubspec.lock b/pubspec.lock index 64624126..049cada8 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -102,7 +102,7 @@ packages: description: path: "." ref: cleanup - resolved-ref: "844ce224d120cedf34b5daa8e6535db215b2d64a" + resolved-ref: c8f623e26a87dd51971717d60e8d3de89421b8ce url: "https://github.com/a-mabe/background_timer.git" source: git version: "0.0.1" @@ -359,10 +359,10 @@ packages: dependency: "direct main" description: name: google_fonts - sha256: f0b8d115a13ecf827013ec9fc883390ccc0e87a96ed5347a3114cac177ef18e8 + sha256: "5b1726fee554d1cc9db1baef8061b126567ff0a1140a03ed7de936e62f2ab98b" url: "https://pub.dev" source: hosted - version: "6.1.0" + version: "6.2.0" http: dependency: transitive description: @@ -471,10 +471,10 @@ packages: dependency: "direct main" description: name: logger - sha256: "6bbb9d6f7056729537a4309bda2e74e18e5d9f14302489cc1e93f33b3fe32cac" + sha256: b3ff55aeb08d9d8901b767650285872cb1bb8f508373b3e348d60268b0c7f770 url: "https://pub.dev" source: hosted - version: "2.0.2+1" + version: "2.1.0" logging: dependency: transitive description: @@ -916,10 +916,10 @@ packages: dependency: transitive description: name: web - sha256: "1d9158c616048c38f712a6646e317a3426da10e884447626167240d45209cbad" + sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27" url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "0.5.1" win32: dependency: transitive description: From e72513d966652db78ee07c47cf74991b8bc29016 Mon Sep 17 00:00:00 2001 From: a-mabe Date: Sun, 17 Mar 2024 15:42:05 -0400 Subject: [PATCH 26/26] Bump version --- VERSION | 2 +- pubspec.lock | 12 ++++++------ pubspec.yaml | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/VERSION b/VERSION index 7e099ec5..589268e6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.2.6 \ No newline at end of file +1.3.0 \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index 049cada8..28e7e80e 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -101,8 +101,8 @@ packages: dependency: "direct main" description: path: "." - ref: cleanup - resolved-ref: c8f623e26a87dd51971717d60e8d3de89421b8ce + ref: main + resolved-ref: cefc9163c47ceda7c77a77b885ab48c7f6bbd3c0 url: "https://github.com/a-mabe/background_timer.git" source: git version: "0.0.1" @@ -756,18 +756,18 @@ packages: dependency: transitive description: name: sqflite_common - sha256: "28d8c66baee4968519fb8bd6cdbedad982d6e53359091f0b74544a9f32ec72d5" + sha256: "3da423ce7baf868be70e2c0976c28a1bb2f73644268b7ffa7d2e08eab71f16a4" url: "https://pub.dev" source: hosted - version: "2.5.3" + version: "2.5.4" sqflite_common_ffi: dependency: "direct main" description: name: sqflite_common_ffi - sha256: "754927d82de369a6b9e760fb60640aa81da650f35ffd468d5a992814d6022908" + sha256: "4d6137c29e930d6e4a8ff373989dd9de7bac12e3bc87bce950f6e844e8ad3bb5" url: "https://pub.dev" source: hosted - version: "2.3.2+1" + version: "2.3.3" sqlite3: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index eb36b791..bf506ba8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.2.6+21 +version: 1.3.0+22 environment: sdk: '>=2.19.6 <3.0.0' @@ -53,7 +53,7 @@ dependencies: background_timer: git: url: https://github.com/a-mabe/background_timer.git - ref: cleanup # branch name + ref: main # branch name just_audio: ^0.9.35 soundpool: ^2.4.1 auto_size_text: ^3.0.0