diff --git a/lib/helpers/consts.dart b/lib/helpers/consts.dart index 562c4a33..1d255751 100644 --- a/lib/helpers/consts.dart +++ b/lib/helpers/consts.dart @@ -35,14 +35,14 @@ const TESTSERVER_PASSWORD = 'flutteruser'; const MANIFEST_KEY_CHECK_UPDATE = 'wger.check_min_app_version'; /// Default weight unit is "kg" -const DEFAULT_WEIGHT_UNIT = 1; +const WEIGHT_UNIT_KG_ID = 1; /// Default impression for a workout session (neutral) const DEFAULT_IMPRESSION = 2; // Weight and repetition units for the workout logs -const REP_UNIT_REPETITIONS = 1; -const REP_UNIT_TILL_FAILURE = 2; +const REP_UNIT_REPETITIONS_ID = 1; +const REP_UNIT_TILL_FAILURE_ID = 2; const WEIGHT_UNIT_KG = 1; const WEIGHT_UNIT_LB = 2; diff --git a/lib/helpers/misc.dart b/lib/helpers/misc.dart index b880e8c2..b8e38979 100644 --- a/lib/helpers/misc.dart +++ b/lib/helpers/misc.dart @@ -42,7 +42,7 @@ String repText( // rather "8 repetitions". If there is weight we want to output "8 x 50kg", // since the repetitions are implied. If other units are used, we always // print them - if (repetitionUnitObj.id != REP_UNIT_REPETITIONS || weight == 0 || weight == null) { + if (repetitionUnitObj.id != REP_UNIT_REPETITIONS_ID || weight == 0 || weight == null) { out.add(repetitionUnitObj.name); } } diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 33108f7d..4153011a 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -706,6 +706,8 @@ "images": "Images", "language": "Language", "addExercise": "Add exercise", + "addSuperset": "Add superset", + "setHasNoExercises": "This set has no exercises yet!", "contributeExercise": "Contribute an exercise", "translation": "Translation", "translateExercise": "Translate this exercise now", diff --git a/lib/models/workouts/slot_entry.dart b/lib/models/workouts/slot_entry.dart index b5d16345..6d808f10 100644 --- a/lib/models/workouts/slot_entry.dart +++ b/lib/models/workouts/slot_entry.dart @@ -17,6 +17,7 @@ */ import 'package:json_annotation/json_annotation.dart'; +import 'package:wger/helpers/consts.dart'; import 'package:wger/helpers/json.dart'; import 'package:wger/models/exercises/exercise.dart'; import 'package:wger/models/workouts/base_config.dart'; @@ -68,11 +69,11 @@ class SlotEntry { @JsonKey(required: true, name: 'repetition_rounding', fromJson: stringToNum) late num repetitionRounding; - @JsonKey(required: true, name: 'reps_configs') - late List repsConfigs; + @JsonKey(required: false, name: 'reps_configs', includeToJson: false, defaultValue: []) + late List repsConfigs = []; - @JsonKey(required: true, name: 'max_reps_configs') - late List maxRepsConfigs; + @JsonKey(required: false, name: 'max_reps_configs', includeToJson: false, defaultValue: []) + late List maxRepsConfigs = []; @JsonKey(required: true, name: 'weight_unit') late int weightUnitId; @@ -83,23 +84,23 @@ class SlotEntry { @JsonKey(required: true, name: 'weight_rounding', fromJson: stringToNum) late num weightRounding; - @JsonKey(required: true, name: 'weight_configs') - late List weightConfigs; + @JsonKey(required: false, name: 'weight_configs', includeToJson: false, defaultValue: []) + late List weightConfigs = []; - @JsonKey(required: true, name: 'max_weight_configs') - late List maxWeightConfigs; + @JsonKey(required: false, name: 'max_weight_configs', includeToJson: false, defaultValue: []) + late List maxWeightConfigs = []; - @JsonKey(required: true, name: 'set_nr_configs') - late List nrOfSetsConfigs; + @JsonKey(required: false, name: 'set_nr_configs', includeToJson: false, defaultValue: []) + late List nrOfSetsConfigs = []; - @JsonKey(required: true, name: 'rir_configs') - late List rirConfigs; + @JsonKey(required: false, name: 'rir_configs', includeToJson: false, defaultValue: []) + late List rirConfigs = []; - @JsonKey(required: true, name: 'rest_configs') - late List restTimeConfigs; + @JsonKey(required: false, name: 'rest_configs', includeToJson: false, defaultValue: []) + late List restTimeConfigs = []; - @JsonKey(required: true, name: 'max_rest_configs') - late List maxRestTimeConfigs; + @JsonKey(required: false, name: 'max_rest_configs', includeToJson: false, defaultValue: []) + late List maxRestTimeConfigs = []; @JsonKey(required: true) late Object? config; @@ -119,6 +120,30 @@ class SlotEntry { SlotEntry.empty(); + SlotEntry.withData({ + required this.slotId, + String? comment, + int? order, + String? type, + required Exercise exercise, + int? weightUnitId, + num? weightRounding, + int? repetitionUnitId, + num? repetitionRounding, + }) { + this.order = order ?? 1; + this.comment = comment ?? ''; + config = null; + this.type = type ?? 'normal'; + exerciseObj = exercise; + exerciseId = exercise.id!; + this.weightUnitId = weightUnitId ?? WEIGHT_UNIT_KG_ID; + this.weightRounding = weightRounding ?? 2.5; + + this.repetitionUnitId = repetitionUnitId ?? REP_UNIT_REPETITIONS_ID; + this.repetitionRounding = repetitionRounding ?? 1; + } + get rir { return 'DELETE ME! RIR'; } diff --git a/lib/models/workouts/slot_entry.g.dart b/lib/models/workouts/slot_entry.g.dart index dcb57ca6..6a21ba75 100644 --- a/lib/models/workouts/slot_entry.g.dart +++ b/lib/models/workouts/slot_entry.g.dart @@ -18,16 +18,8 @@ SlotEntry _$SlotEntryFromJson(Map json) { 'exercise', 'repetition_unit', 'repetition_rounding', - 'reps_configs', - 'max_reps_configs', 'weight_unit', 'weight_rounding', - 'weight_configs', - 'max_weight_configs', - 'set_nr_configs', - 'rir_configs', - 'rest_configs', - 'max_rest_configs', 'config' ], ); @@ -43,30 +35,38 @@ SlotEntry _$SlotEntryFromJson(Map json) { weightRounding: stringToNum(json['weight_rounding'] as String?), comment: json['comment'] as String, ) - ..repsConfigs = (json['reps_configs'] as List) - .map((e) => BaseConfig.fromJson(e as Map)) - .toList() - ..maxRepsConfigs = (json['max_reps_configs'] as List) - .map((e) => BaseConfig.fromJson(e as Map)) - .toList() - ..weightConfigs = (json['weight_configs'] as List) - .map((e) => BaseConfig.fromJson(e as Map)) - .toList() - ..maxWeightConfigs = (json['max_weight_configs'] as List) - .map((e) => BaseConfig.fromJson(e as Map)) - .toList() - ..nrOfSetsConfigs = (json['set_nr_configs'] as List) - .map((e) => BaseConfig.fromJson(e as Map)) - .toList() - ..rirConfigs = (json['rir_configs'] as List) - .map((e) => BaseConfig.fromJson(e as Map)) - .toList() - ..restTimeConfigs = (json['rest_configs'] as List) - .map((e) => BaseConfig.fromJson(e as Map)) - .toList() - ..maxRestTimeConfigs = (json['max_rest_configs'] as List) - .map((e) => BaseConfig.fromJson(e as Map)) - .toList() + ..repsConfigs = (json['reps_configs'] as List?) + ?.map((e) => BaseConfig.fromJson(e as Map)) + .toList() ?? + [] + ..maxRepsConfigs = (json['max_reps_configs'] as List?) + ?.map((e) => BaseConfig.fromJson(e as Map)) + .toList() ?? + [] + ..weightConfigs = (json['weight_configs'] as List?) + ?.map((e) => BaseConfig.fromJson(e as Map)) + .toList() ?? + [] + ..maxWeightConfigs = (json['max_weight_configs'] as List?) + ?.map((e) => BaseConfig.fromJson(e as Map)) + .toList() ?? + [] + ..nrOfSetsConfigs = (json['set_nr_configs'] as List?) + ?.map((e) => BaseConfig.fromJson(e as Map)) + .toList() ?? + [] + ..rirConfigs = (json['rir_configs'] as List?) + ?.map((e) => BaseConfig.fromJson(e as Map)) + .toList() ?? + [] + ..restTimeConfigs = (json['rest_configs'] as List?) + ?.map((e) => BaseConfig.fromJson(e as Map)) + .toList() ?? + [] + ..maxRestTimeConfigs = (json['max_rest_configs'] as List?) + ?.map((e) => BaseConfig.fromJson(e as Map)) + .toList() ?? + [] ..config = json['config']; } @@ -78,15 +78,7 @@ Map _$SlotEntryToJson(SlotEntry instance) => { 'exercise': instance.exerciseId, 'repetition_unit': instance.repetitionUnitId, 'repetition_rounding': instance.repetitionRounding, - 'reps_configs': instance.repsConfigs, - 'max_reps_configs': instance.maxRepsConfigs, 'weight_unit': instance.weightUnitId, 'weight_rounding': instance.weightRounding, - 'weight_configs': instance.weightConfigs, - 'max_weight_configs': instance.maxWeightConfigs, - 'set_nr_configs': instance.nrOfSetsConfigs, - 'rir_configs': instance.rirConfigs, - 'rest_configs': instance.restTimeConfigs, - 'max_rest_configs': instance.maxRestTimeConfigs, 'config': instance.config, }; diff --git a/lib/providers/routines.dart b/lib/providers/routines.dart index d726c9c3..59e9f8ef 100644 --- a/lib/providers/routines.dart +++ b/lib/providers/routines.dart @@ -86,7 +86,7 @@ class RoutinesProvider with ChangeNotifier { /// Return the default weight unit (kg) WeightUnit get defaultWeightUnit { - return _weightUnits.firstWhere((element) => element.id == DEFAULT_WEIGHT_UNIT); + return _weightUnits.firstWhere((element) => element.id == WEIGHT_UNIT_KG_ID); } List get repetitionUnits { @@ -95,7 +95,7 @@ class RoutinesProvider with ChangeNotifier { /// Return the default weight unit (reps) RepetitionUnit get defaultRepetitionUnit { - return _repetitionUnit.firstWhere((element) => element.id == REP_UNIT_REPETITIONS); + return _repetitionUnit.firstWhere((element) => element.id == REP_UNIT_REPETITIONS_ID); } List getPlans() { @@ -477,7 +477,7 @@ class RoutinesProvider with ChangeNotifier { } Future deleteSlot(int slotId) async { - final data = await baseProvider.deleteRequest(_slotsUrlPath, slotId); + await baseProvider.deleteRequest(_slotsUrlPath, slotId); for (final routine in _routines) { for (final day in routine.days) { @@ -508,8 +508,31 @@ class RoutinesProvider with ChangeNotifier { notifyListeners(); } + Future addSlotEntry(SlotEntry entry) async { + final data = await baseProvider.post( + entry.toJson(), + baseProvider.makeUrl(_slotEntriesUrlPath), + ); + final newEntry = SlotEntry.fromJson(data); + newEntry.exerciseObj = (await _exercises.fetchAndSetExercise(newEntry.exerciseId))!; + + for (final routine in _routines) { + for (final day in routine.days) { + for (final slot in day.slots) { + if (slot.id == entry.slotId) { + slot.entries.add(newEntry); + break; + } + } + } + } + + notifyListeners(); + return newEntry; + } + Future deleteSlotEntry(int id) async { - await baseProvider.deleteRequest(_slotsUrlPath, id); + await baseProvider.deleteRequest(_slotEntriesUrlPath, id); for (final routine in _routines) { for (final day in routine.days) { for (final slot in day.slots) { diff --git a/lib/widgets/routines/forms/slot.dart b/lib/widgets/routines/forms/slot.dart index 0a28b045..b6f1073d 100644 --- a/lib/widgets/routines/forms/slot.dart +++ b/lib/widgets/routines/forms/slot.dart @@ -18,19 +18,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; -import 'package:flutter_typeahead/flutter_typeahead.dart'; import 'package:provider/provider.dart'; import 'package:wger/helpers/consts.dart'; -import 'package:wger/models/exercises/exercise.dart'; -import 'package:wger/models/workouts/day.dart'; import 'package:wger/models/workouts/slot.dart'; import 'package:wger/models/workouts/slot_entry.dart'; -import 'package:wger/providers/exercises.dart'; import 'package:wger/providers/routines.dart'; -import 'package:wger/screens/add_exercise_screen.dart'; import 'package:wger/widgets/exercises/autocompleter.dart'; -import 'package:wger/widgets/exercises/images.dart'; -import 'package:wger/widgets/routines/forms.dart'; class SlotEntryForm extends StatefulWidget { final SlotEntry entry; @@ -73,7 +66,7 @@ class _SlotEntryFormState extends State { } @override - build(BuildContext context) { + Widget build(BuildContext context) { final i18n = AppLocalizations.of(context); final languageCode = Localizations.localeOf(context).languageCode; @@ -85,6 +78,7 @@ class _SlotEntryFormState extends State { title: Text( widget.entry.exerciseObj.getExercise(languageCode).name, style: Theme.of(context).textTheme.titleMedium, + // textAlign: TextAlign.center, ), trailing: Row( mainAxisSize: MainAxisSize.min, @@ -132,7 +126,7 @@ class _SlotEntryFormState extends State { const SizedBox(height: 5), OutlinedButton( key: const Key(SUBMIT_BUTTON_KEY_NAME), - child: Text(AppLocalizations.of(context).save), + child: Text(i18n.save), onPressed: () async { if (!_form.currentState!.validate()) { return; @@ -147,26 +141,58 @@ class _SlotEntryFormState extends State { provider.handleConfig(widget.entry, repsController.text, ConfigType.reps); }, ), - const SizedBox(height: 15), + const SizedBox(height: 10), ], ), ); } } -class SlotDetailWidget extends StatelessWidget { +class SlotDetailWidget extends StatefulWidget { final Slot slot; const SlotDetailWidget(this.slot, {super.key}); @override - build(BuildContext context) => Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ...slot.entries.map((entry) => SlotEntryForm(entry)), - const SizedBox(height: 30), - ], - ); + State createState() => _SlotDetailWidgetState(); +} + +class _SlotDetailWidgetState extends State { + bool _addSuperset = false; + + @override + Widget build(BuildContext context) { + final i18n = AppLocalizations.of(context); + final provider = context.read(); + + return Column( + children: [ + ...widget.slot.entries.map((entry) => SlotEntryForm(entry)), + const SizedBox(height: 10), + if (_addSuperset || widget.slot.entries.isEmpty) + ExerciseAutocompleter( + onExerciseSelected: (exercise) async { + final SlotEntry entry = SlotEntry.withData( + slotId: widget.slot.id!, + order: widget.slot.entries.length + 1, + exercise: exercise, + ); + + _addSuperset = false; + await provider.addSlotEntry(entry); + }, + ), + FilledButton( + onPressed: () { + setState(() { + _addSuperset = !_addSuperset; + }); + }, + child: Text(i18n.addSuperset)), + const SizedBox(height: 5), + ], + ); + } } class ReorderableSlotList extends StatefulWidget { @@ -185,6 +211,8 @@ class _SlotFormWidgetStateNg extends State { @override Widget build(BuildContext context) { + final i18n = AppLocalizations.of(context); + final provider = context.read(); final languageCode = Localizations.localeOf(context).languageCode; @@ -213,34 +241,31 @@ class _SlotFormWidgetStateNg extends State { itemCount: widget.slots.length, itemBuilder: (context, index) { final slot = widget.slots[index]; - final isSlotSelected = slot.id == selectedSlotId; + final isCurrentSlotSelected = slot.id == selectedSlotId; return Card( + color: slot.entries.isEmpty ? Theme.of(context).colorScheme.inversePrimary : null, key: ValueKey(slot.id), child: Column( children: [ ListTile( - title: Text('Set ${index + 1}'), - tileColor: isSlotSelected ? Theme.of(context).highlightColor : null, + title: Text(i18n.setNr(index + 1)), + tileColor: isCurrentSlotSelected ? Theme.of(context).highlightColor : null, leading: selectedSlotId == null ? ReorderableDragStartListener( index: index, child: const Icon(Icons.drag_handle), ) : const Icon(Icons.block), - // : const Icon(Icons.filter_list_off), - subtitle: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - if (slot.entries.isEmpty) - Card( - child: Text('no exercises'), - color: Theme.of(context).splashColor, + subtitle: slot.entries.isEmpty + ? Text(i18n.setHasNoExercises) + : Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ...slot.entries + .map((e) => Text(e.exerciseObj.getExercise(languageCode).name)), + ], ), - ...slot.entries - .map((e) => Text(e.exerciseObj.getExercise(languageCode).name)), - ], - ), trailing: Row( mainAxisSize: MainAxisSize.min, children: [ @@ -253,19 +278,21 @@ class _SlotFormWidgetStateNg extends State { selectedSlotId = slot.id; } }); - // widget.onDaySelected(day.id!); }, - icon: - isSlotSelected ? const Icon(Icons.edit_off) : const Icon(Icons.edit), + icon: isCurrentSlotSelected + ? const Icon(Icons.edit_off) + : const Icon(Icons.edit), ), IconButton( - icon: const Icon(Icons.delete), - onPressed: () => provider.deleteSlot(slot.id!), - ), + icon: const Icon(Icons.delete), + onPressed: () async { + selectedSlotId = null; + await provider.deleteSlot(slot.id!); + }), ], ), ), - if (isSlotSelected) SlotDetailWidget(slot), + if (isCurrentSlotSelected) SlotDetailWidget(slot), ], ), ); @@ -290,369 +317,20 @@ class _SlotFormWidgetStateNg extends State { ListTile( leading: const Icon(Icons.add), title: Text( - AppLocalizations.of(context).newSet, + i18n.newSet, style: Theme.of(context).textTheme.titleMedium, ), - onTap: () { - provider.addSlot(Slot.withData(day: widget.dayId, order: widget.slots.length + 1)); + onTap: () async { + final newSlot = await provider.addSlot(Slot.withData( + day: widget.dayId, + order: widget.slots.length + 1, + )); + setState(() { + selectedSlotId = newSlot.id; + }); }, ), - if (selectedSlot != null) Text(selectedSlot.id!.toString()), ], ); } } - -class SlotFormWidget extends StatefulWidget { - final Day _day; - late final Slot _slot; - - SlotFormWidget(this._day, [Slot? set]) { - _slot = set ?? Slot.withData(day: _day.id, order: _day.slots.length); - } - - @override - _SlotFormWidgetState createState() => _SlotFormWidgetState(); -} - -class _SlotFormWidgetState extends State { - double _currentSetSliderValue = Slot.DEFAULT_NR_SETS.toDouble(); - bool _detailed = false; - bool _searchEnglish = true; - - // Form stuff - final GlobalKey _formKey = GlobalKey(); - final _exercisesController = TextEditingController(); - - /// Removes an exercise from the current set - void removeExerciseBase(Exercise base) { - setState(() { - widget._slot.removeExercise(base); - }); - } - - @override - void dispose() { - _exercisesController.dispose(); - super.dispose(); - } - - /// Adds an exercise to the current set - void addExercise(Exercise base) { - setState(() { - widget._slot.addExerciseBase(base); - addSettings(); - }); - } - - /// Adds settings to the set - void addSettings() { - final workoutProvider = context.read(); - - widget._slot.entries = []; - int order = 0; - for (final exercise in widget._slot.exercisesObj) { - order++; - // for (int loop = 0; loop < widget._set.sets; loop++) { - final SlotEntry setting = SlotEntry.empty(); - setting.order = order; - setting.exercise = exercise; - setting.weightUnit = workoutProvider.defaultWeightUnit; - setting.repetitionUnit = workoutProvider.defaultRepetitionUnit; - - widget._slot.entries.add(setting); - // } - } - } - - @override - Widget build(BuildContext context) { - return Form( - key: _formKey, - child: ListView( - children: [ - Container( - padding: const EdgeInsets.only(top: 10), - color: Theme.of(context).colorScheme.primaryContainer, - child: Column( - //crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text(AppLocalizations.of(context).nrOfSets(_currentSetSliderValue.round())), - Slider( - value: _currentSetSliderValue, - min: 1, - max: 10, - divisions: 10, - label: _currentSetSliderValue.round().toString(), - onChanged: (double value) { - setState(() { - // widget._set.sets = value.round(); - _currentSetSliderValue = value; - addSettings(); - }); - }, - inactiveColor: Theme.of(context).colorScheme.surface, - ), - if (widget._slot.entries.isNotEmpty) - SwitchListTile( - title: Text(AppLocalizations.of(context).setUnitsAndRir), - value: _detailed, - onChanged: (value) { - setState(() { - _detailed = !_detailed; - }); - }, - ), - ], - ), - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - children: [ - Card( - child: Column( - children: [ - TypeAheadField( - key: const Key('field-typeahead'), - decorationBuilder: (context, child) { - return Material( - type: MaterialType.card, - elevation: 4, - borderRadius: BorderRadius.circular(8), - child: child, - ); - }, - controller: _exercisesController, - builder: (context, controller, focusNode) { - return TextFormField( - controller: controller, - focusNode: focusNode, - // autofocus: true, - decoration: InputDecoration( - labelText: AppLocalizations.of(context).searchExercise, - prefixIcon: const Icon(Icons.search), - suffixIcon: IconButton( - icon: const Icon(Icons.help), - onPressed: () { - showDialog( - context: context, - builder: (context) => AlertDialog( - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - // Text(AppLocalizations.of(context).selectExercises), - // const SizedBox(height: 10), - // Text(AppLocalizations.of(context).sameRepetitions), - ], - ), - actions: [ - TextButton( - child: Text( - MaterialLocalizations.of(context).closeButtonLabel, - ), - onPressed: () { - Navigator.of(context).pop(); - }, - ), - ], - ), - ); - }, - ), - errorMaxLines: 2, - border: InputBorder.none, - ), - validator: (value) { - // At least one exercise must be selected - if (widget._slot.exercisesIds.isEmpty) { - return AppLocalizations.of(context).selectExercise; - } - - // At least one setting has to be filled in - // if (widget._set.entries - // .where((s) => s.weight == null && s.reps == null) - // .length == - // widget._set.entries.length) { - // return AppLocalizations.of(context).enterRepetitionsOrWeight; - // } - return null; - }, - ); - }, - suggestionsCallback: (pattern) { - if (pattern == '') { - return null; - } - return context.read().searchExercise( - pattern, - languageCode: Localizations.localeOf(context).languageCode, - searchEnglish: _searchEnglish, - ); - }, - itemBuilder: ( - BuildContext context, - Exercise exerciseSuggestion, - ) => - ListTile( - key: Key('exercise-${exerciseSuggestion.id}'), - leading: SizedBox( - width: 45, - child: ExerciseImageWidget( - image: exerciseSuggestion.getMainImage, - ), - ), - title: Text( - exerciseSuggestion - .getExercise(Localizations.localeOf(context).languageCode) - .name, - ), - subtitle: Text( - '${exerciseSuggestion.category!.name} / ${exerciseSuggestion.equipment.map((e) => e.name).join(', ')}', - ), - ), - emptyBuilder: (context) { - return Column( - mainAxisSize: MainAxisSize.min, - children: [ - ListTile( - title: Text(AppLocalizations.of(context).noMatchingExerciseFound), - ), - ListTile( - title: OutlinedButton( - onPressed: () { - Navigator.of(context).pushNamed(AddExerciseScreen.routeName); - }, - child: Text(AppLocalizations.of(context).contributeExercise), - ), - ), - ], - ); - }, - transitionBuilder: (context, animation, child) => FadeTransition( - opacity: CurvedAnimation( - parent: animation, - curve: Curves.fastOutSlowIn, - ), - child: child, - ), - onSelected: (Exercise exerciseSuggestion) { - // SuggestionsController.of(context).select(exerciseSuggestion); - - addExercise(exerciseSuggestion); - _exercisesController.text = ''; - }, - ), - if (Localizations.localeOf(context).languageCode != LANGUAGE_SHORT_ENGLISH) - SwitchListTile( - title: Text(AppLocalizations.of(context).searchNamesInEnglish), - value: _searchEnglish, - onChanged: (_) { - setState(() { - _searchEnglish = !_searchEnglish; - }); - }, - dense: true, - ), - ], - ), - ), - const SizedBox(height: 10), - TextFormField( - decoration: InputDecoration( - labelText: AppLocalizations.of(context).comment, - errorMaxLines: 2, - ), - keyboardType: TextInputType.text, - validator: (value) { - const minLength = 0; - const maxLength = 200; - if (value!.length > maxLength) { - return AppLocalizations.of(context).enterCharacters(minLength, maxLength); - } - return null; - }, - onSaved: (newValue) { - widget._slot.comment = newValue!; - }, - ), - const SizedBox(height: 10), - ...widget._slot.exercisesObj.asMap().entries.map((entry) { - final index = entry.key; - final exercise = entry.value; - final showSupersetInfo = (index + 1) < widget._slot.exercisesObj.length; - final settings = - widget._slot.entries.where((e) => e.exerciseObj.id == exercise.id).toList(); - - return Column( - children: [ - ExerciseSetting( - exercise, - settings, - _detailed, - _currentSetSliderValue, - removeExerciseBase, - ), - if (showSupersetInfo) - const Padding( - padding: EdgeInsets.all(3.0), - child: Text('+'), - ), - if (showSupersetInfo) Text(AppLocalizations.of(context).supersetWith), - if (showSupersetInfo) - const Padding( - padding: EdgeInsets.all(3.0), - child: Text('+'), - ), - ], - ); - }), - ElevatedButton( - key: const Key(SUBMIT_BUTTON_KEY_NAME), - child: Text(AppLocalizations.of(context).save), - onPressed: () async { - final isValid = _formKey.currentState!.validate(); - if (!isValid) { - return; - } - _formKey.currentState!.save(); - - final workoutProvider = Provider.of( - context, - listen: false, - ); - - // Save set - final Slot setDb = await workoutProvider.addSlot(widget._slot); - widget._slot.id = setDb.id; - - // Remove unused settings - // widget._set.entries.removeWhere((s) => s.weight == null && s.reps == null); - - // Save remaining settings - for (final setting in widget._slot.entries) { - setting.slotId = setDb.id!; - setting.comment = ''; - - final SlotEntry settingDb = await workoutProvider.addSetting(setting); - setting.id = settingDb.id; - } - - // Add to workout day - workoutProvider.fetchComputedSettings(widget._slot); - widget._day.slots.add(widget._slot); - - // Close the bottom sheet - if (context.mounted) { - Navigator.of(context).pop(); - } - }, - ), - ], - ), - ), - ], - ), - ); - } -} diff --git a/pubspec.yaml b/pubspec.yaml index bf46c825..66b7c942 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -89,6 +89,9 @@ dev_dependencies: freezed: ^2.5.2 golden_toolkit: ^0.15.0 + # Script to read out unused translations + #translations_cleaner: ^0.0.5 + # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/test/workout/repetition_unit_form_widget_test.mocks.dart b/test/workout/repetition_unit_form_widget_test.mocks.dart index b10bf128..659fee43 100644 --- a/test/workout/repetition_unit_form_widget_test.mocks.dart +++ b/test/workout/repetition_unit_form_widget_test.mocks.dart @@ -9,7 +9,7 @@ import 'dart:ui' as _i17; import 'package:mockito/mockito.dart' as _i1; import 'package:mockito/src/dummies.dart' as _i16; import 'package:wger/models/exercises/exercise.dart' as _i15; -import 'package:wger/models/workouts/base_config.dart' as _i8; +import 'package:wger/models/workouts/base_config.dart' as _i9; import 'package:wger/models/workouts/day.dart' as _i6; import 'package:wger/models/workouts/day_data.dart' as _i14; import 'package:wger/models/workouts/log.dart' as _i11; @@ -17,7 +17,7 @@ import 'package:wger/models/workouts/repetition_unit.dart' as _i4; import 'package:wger/models/workouts/routine.dart' as _i5; import 'package:wger/models/workouts/session.dart' as _i10; import 'package:wger/models/workouts/slot.dart' as _i7; -import 'package:wger/models/workouts/slot_entry.dart' as _i9; +import 'package:wger/models/workouts/slot_entry.dart' as _i8; import 'package:wger/models/workouts/weight_unit.dart' as _i3; import 'package:wger/providers/base_provider.dart' as _i2; import 'package:wger/providers/routines.dart' as _i12; @@ -95,8 +95,8 @@ class _FakeSlot_5 extends _i1.SmartFake implements _i7.Slot { ); } -class _FakeBaseConfig_6 extends _i1.SmartFake implements _i8.BaseConfig { - _FakeBaseConfig_6( +class _FakeSlotEntry_6 extends _i1.SmartFake implements _i8.SlotEntry { + _FakeSlotEntry_6( Object parent, Invocation parentInvocation, ) : super( @@ -105,8 +105,8 @@ class _FakeBaseConfig_6 extends _i1.SmartFake implements _i8.BaseConfig { ); } -class _FakeSlotEntry_7 extends _i1.SmartFake implements _i9.SlotEntry { - _FakeSlotEntry_7( +class _FakeBaseConfig_7 extends _i1.SmartFake implements _i9.BaseConfig { + _FakeBaseConfig_7( Object parent, Invocation parentInvocation, ) : super( @@ -490,6 +490,21 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider { returnValueForMissingStub: _i13.Future.value(), ) as _i13.Future); + @override + _i13.Future<_i8.SlotEntry> addSlotEntry(_i8.SlotEntry? entry) => (super.noSuchMethod( + Invocation.method( + #addSlotEntry, + [entry], + ), + returnValue: _i13.Future<_i8.SlotEntry>.value(_FakeSlotEntry_6( + this, + Invocation.method( + #addSlotEntry, + [entry], + ), + )), + ) as _i13.Future<_i8.SlotEntry>); + @override _i13.Future deleteSlotEntry(int? id) => (super.noSuchMethod( Invocation.method( @@ -501,7 +516,7 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider { ) as _i13.Future); @override - String getConfigUrl(_i9.ConfigType? type) => (super.noSuchMethod( + String getConfigUrl(_i8.ConfigType? type) => (super.noSuchMethod( Invocation.method( #getConfigUrl, [type], @@ -516,9 +531,9 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider { ) as String); @override - _i13.Future<_i8.BaseConfig> editConfig( - _i8.BaseConfig? config, - _i9.ConfigType? type, + _i13.Future<_i9.BaseConfig> editConfig( + _i9.BaseConfig? config, + _i8.ConfigType? type, ) => (super.noSuchMethod( Invocation.method( @@ -528,7 +543,7 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider { type, ], ), - returnValue: _i13.Future<_i8.BaseConfig>.value(_FakeBaseConfig_6( + returnValue: _i13.Future<_i9.BaseConfig>.value(_FakeBaseConfig_7( this, Invocation.method( #editConfig, @@ -538,12 +553,12 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider { ], ), )), - ) as _i13.Future<_i8.BaseConfig>); + ) as _i13.Future<_i9.BaseConfig>); @override - _i13.Future<_i8.BaseConfig> addConfig( - _i8.BaseConfig? config, - _i9.ConfigType? type, + _i13.Future<_i9.BaseConfig> addConfig( + _i9.BaseConfig? config, + _i8.ConfigType? type, ) => (super.noSuchMethod( Invocation.method( @@ -553,7 +568,7 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider { type, ], ), - returnValue: _i13.Future<_i8.BaseConfig>.value(_FakeBaseConfig_6( + returnValue: _i13.Future<_i9.BaseConfig>.value(_FakeBaseConfig_7( this, Invocation.method( #addConfig, @@ -563,12 +578,12 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider { ], ), )), - ) as _i13.Future<_i8.BaseConfig>); + ) as _i13.Future<_i9.BaseConfig>); @override _i13.Future deleteConfig( int? id, - _i9.ConfigType? type, + _i8.ConfigType? type, ) => (super.noSuchMethod( Invocation.method( @@ -584,9 +599,9 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider { @override _i13.Future handleConfig( - _i9.SlotEntry? entry, + _i8.SlotEntry? entry, String? input, - _i9.ConfigType? type, + _i8.ConfigType? type, ) => (super.noSuchMethod( Invocation.method( @@ -612,19 +627,19 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider { ) as _i13.Future); @override - _i13.Future<_i9.SlotEntry> addSetting(_i9.SlotEntry? workoutSetting) => (super.noSuchMethod( + _i13.Future<_i8.SlotEntry> addSetting(_i8.SlotEntry? workoutSetting) => (super.noSuchMethod( Invocation.method( #addSetting, [workoutSetting], ), - returnValue: _i13.Future<_i9.SlotEntry>.value(_FakeSlotEntry_7( + returnValue: _i13.Future<_i8.SlotEntry>.value(_FakeSlotEntry_6( this, Invocation.method( #addSetting, [workoutSetting], ), )), - ) as _i13.Future<_i9.SlotEntry>); + ) as _i13.Future<_i8.SlotEntry>); @override _i13.Future fetchSessionData() => (super.noSuchMethod( diff --git a/test/workout/workout_day_form_test.mocks.dart b/test/workout/workout_day_form_test.mocks.dart index 79105790..c4daa40b 100644 --- a/test/workout/workout_day_form_test.mocks.dart +++ b/test/workout/workout_day_form_test.mocks.dart @@ -9,7 +9,7 @@ import 'dart:ui' as _i17; import 'package:mockito/mockito.dart' as _i1; import 'package:mockito/src/dummies.dart' as _i16; import 'package:wger/models/exercises/exercise.dart' as _i15; -import 'package:wger/models/workouts/base_config.dart' as _i8; +import 'package:wger/models/workouts/base_config.dart' as _i9; import 'package:wger/models/workouts/day.dart' as _i6; import 'package:wger/models/workouts/day_data.dart' as _i14; import 'package:wger/models/workouts/log.dart' as _i11; @@ -17,7 +17,7 @@ import 'package:wger/models/workouts/repetition_unit.dart' as _i4; import 'package:wger/models/workouts/routine.dart' as _i5; import 'package:wger/models/workouts/session.dart' as _i10; import 'package:wger/models/workouts/slot.dart' as _i7; -import 'package:wger/models/workouts/slot_entry.dart' as _i9; +import 'package:wger/models/workouts/slot_entry.dart' as _i8; import 'package:wger/models/workouts/weight_unit.dart' as _i3; import 'package:wger/providers/base_provider.dart' as _i2; import 'package:wger/providers/routines.dart' as _i12; @@ -95,8 +95,8 @@ class _FakeSlot_5 extends _i1.SmartFake implements _i7.Slot { ); } -class _FakeBaseConfig_6 extends _i1.SmartFake implements _i8.BaseConfig { - _FakeBaseConfig_6( +class _FakeSlotEntry_6 extends _i1.SmartFake implements _i8.SlotEntry { + _FakeSlotEntry_6( Object parent, Invocation parentInvocation, ) : super( @@ -105,8 +105,8 @@ class _FakeBaseConfig_6 extends _i1.SmartFake implements _i8.BaseConfig { ); } -class _FakeSlotEntry_7 extends _i1.SmartFake implements _i9.SlotEntry { - _FakeSlotEntry_7( +class _FakeBaseConfig_7 extends _i1.SmartFake implements _i9.BaseConfig { + _FakeBaseConfig_7( Object parent, Invocation parentInvocation, ) : super( @@ -490,6 +490,21 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider { returnValueForMissingStub: _i13.Future.value(), ) as _i13.Future); + @override + _i13.Future<_i8.SlotEntry> addSlotEntry(_i8.SlotEntry? entry) => (super.noSuchMethod( + Invocation.method( + #addSlotEntry, + [entry], + ), + returnValue: _i13.Future<_i8.SlotEntry>.value(_FakeSlotEntry_6( + this, + Invocation.method( + #addSlotEntry, + [entry], + ), + )), + ) as _i13.Future<_i8.SlotEntry>); + @override _i13.Future deleteSlotEntry(int? id) => (super.noSuchMethod( Invocation.method( @@ -501,7 +516,7 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider { ) as _i13.Future); @override - String getConfigUrl(_i9.ConfigType? type) => (super.noSuchMethod( + String getConfigUrl(_i8.ConfigType? type) => (super.noSuchMethod( Invocation.method( #getConfigUrl, [type], @@ -516,9 +531,9 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider { ) as String); @override - _i13.Future<_i8.BaseConfig> editConfig( - _i8.BaseConfig? config, - _i9.ConfigType? type, + _i13.Future<_i9.BaseConfig> editConfig( + _i9.BaseConfig? config, + _i8.ConfigType? type, ) => (super.noSuchMethod( Invocation.method( @@ -528,7 +543,7 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider { type, ], ), - returnValue: _i13.Future<_i8.BaseConfig>.value(_FakeBaseConfig_6( + returnValue: _i13.Future<_i9.BaseConfig>.value(_FakeBaseConfig_7( this, Invocation.method( #editConfig, @@ -538,12 +553,12 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider { ], ), )), - ) as _i13.Future<_i8.BaseConfig>); + ) as _i13.Future<_i9.BaseConfig>); @override - _i13.Future<_i8.BaseConfig> addConfig( - _i8.BaseConfig? config, - _i9.ConfigType? type, + _i13.Future<_i9.BaseConfig> addConfig( + _i9.BaseConfig? config, + _i8.ConfigType? type, ) => (super.noSuchMethod( Invocation.method( @@ -553,7 +568,7 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider { type, ], ), - returnValue: _i13.Future<_i8.BaseConfig>.value(_FakeBaseConfig_6( + returnValue: _i13.Future<_i9.BaseConfig>.value(_FakeBaseConfig_7( this, Invocation.method( #addConfig, @@ -563,12 +578,12 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider { ], ), )), - ) as _i13.Future<_i8.BaseConfig>); + ) as _i13.Future<_i9.BaseConfig>); @override _i13.Future deleteConfig( int? id, - _i9.ConfigType? type, + _i8.ConfigType? type, ) => (super.noSuchMethod( Invocation.method( @@ -584,9 +599,9 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider { @override _i13.Future handleConfig( - _i9.SlotEntry? entry, + _i8.SlotEntry? entry, String? input, - _i9.ConfigType? type, + _i8.ConfigType? type, ) => (super.noSuchMethod( Invocation.method( @@ -612,19 +627,19 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider { ) as _i13.Future); @override - _i13.Future<_i9.SlotEntry> addSetting(_i9.SlotEntry? workoutSetting) => (super.noSuchMethod( + _i13.Future<_i8.SlotEntry> addSetting(_i8.SlotEntry? workoutSetting) => (super.noSuchMethod( Invocation.method( #addSetting, [workoutSetting], ), - returnValue: _i13.Future<_i9.SlotEntry>.value(_FakeSlotEntry_7( + returnValue: _i13.Future<_i8.SlotEntry>.value(_FakeSlotEntry_6( this, Invocation.method( #addSetting, [workoutSetting], ), )), - ) as _i13.Future<_i9.SlotEntry>); + ) as _i13.Future<_i8.SlotEntry>); @override _i13.Future fetchSessionData() => (super.noSuchMethod( diff --git a/test/workout/workout_form_test.mocks.dart b/test/workout/workout_form_test.mocks.dart index 03b4c8ed..2899e1c2 100644 --- a/test/workout/workout_form_test.mocks.dart +++ b/test/workout/workout_form_test.mocks.dart @@ -9,7 +9,7 @@ import 'dart:ui' as _i17; import 'package:mockito/mockito.dart' as _i1; import 'package:mockito/src/dummies.dart' as _i16; import 'package:wger/models/exercises/exercise.dart' as _i15; -import 'package:wger/models/workouts/base_config.dart' as _i8; +import 'package:wger/models/workouts/base_config.dart' as _i9; import 'package:wger/models/workouts/day.dart' as _i6; import 'package:wger/models/workouts/day_data.dart' as _i14; import 'package:wger/models/workouts/log.dart' as _i11; @@ -17,7 +17,7 @@ import 'package:wger/models/workouts/repetition_unit.dart' as _i4; import 'package:wger/models/workouts/routine.dart' as _i5; import 'package:wger/models/workouts/session.dart' as _i10; import 'package:wger/models/workouts/slot.dart' as _i7; -import 'package:wger/models/workouts/slot_entry.dart' as _i9; +import 'package:wger/models/workouts/slot_entry.dart' as _i8; import 'package:wger/models/workouts/weight_unit.dart' as _i3; import 'package:wger/providers/base_provider.dart' as _i2; import 'package:wger/providers/routines.dart' as _i12; @@ -95,8 +95,8 @@ class _FakeSlot_5 extends _i1.SmartFake implements _i7.Slot { ); } -class _FakeBaseConfig_6 extends _i1.SmartFake implements _i8.BaseConfig { - _FakeBaseConfig_6( +class _FakeSlotEntry_6 extends _i1.SmartFake implements _i8.SlotEntry { + _FakeSlotEntry_6( Object parent, Invocation parentInvocation, ) : super( @@ -105,8 +105,8 @@ class _FakeBaseConfig_6 extends _i1.SmartFake implements _i8.BaseConfig { ); } -class _FakeSlotEntry_7 extends _i1.SmartFake implements _i9.SlotEntry { - _FakeSlotEntry_7( +class _FakeBaseConfig_7 extends _i1.SmartFake implements _i9.BaseConfig { + _FakeBaseConfig_7( Object parent, Invocation parentInvocation, ) : super( @@ -490,6 +490,21 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider { returnValueForMissingStub: _i13.Future.value(), ) as _i13.Future); + @override + _i13.Future<_i8.SlotEntry> addSlotEntry(_i8.SlotEntry? entry) => (super.noSuchMethod( + Invocation.method( + #addSlotEntry, + [entry], + ), + returnValue: _i13.Future<_i8.SlotEntry>.value(_FakeSlotEntry_6( + this, + Invocation.method( + #addSlotEntry, + [entry], + ), + )), + ) as _i13.Future<_i8.SlotEntry>); + @override _i13.Future deleteSlotEntry(int? id) => (super.noSuchMethod( Invocation.method( @@ -501,7 +516,7 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider { ) as _i13.Future); @override - String getConfigUrl(_i9.ConfigType? type) => (super.noSuchMethod( + String getConfigUrl(_i8.ConfigType? type) => (super.noSuchMethod( Invocation.method( #getConfigUrl, [type], @@ -516,9 +531,9 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider { ) as String); @override - _i13.Future<_i8.BaseConfig> editConfig( - _i8.BaseConfig? config, - _i9.ConfigType? type, + _i13.Future<_i9.BaseConfig> editConfig( + _i9.BaseConfig? config, + _i8.ConfigType? type, ) => (super.noSuchMethod( Invocation.method( @@ -528,7 +543,7 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider { type, ], ), - returnValue: _i13.Future<_i8.BaseConfig>.value(_FakeBaseConfig_6( + returnValue: _i13.Future<_i9.BaseConfig>.value(_FakeBaseConfig_7( this, Invocation.method( #editConfig, @@ -538,12 +553,12 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider { ], ), )), - ) as _i13.Future<_i8.BaseConfig>); + ) as _i13.Future<_i9.BaseConfig>); @override - _i13.Future<_i8.BaseConfig> addConfig( - _i8.BaseConfig? config, - _i9.ConfigType? type, + _i13.Future<_i9.BaseConfig> addConfig( + _i9.BaseConfig? config, + _i8.ConfigType? type, ) => (super.noSuchMethod( Invocation.method( @@ -553,7 +568,7 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider { type, ], ), - returnValue: _i13.Future<_i8.BaseConfig>.value(_FakeBaseConfig_6( + returnValue: _i13.Future<_i9.BaseConfig>.value(_FakeBaseConfig_7( this, Invocation.method( #addConfig, @@ -563,12 +578,12 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider { ], ), )), - ) as _i13.Future<_i8.BaseConfig>); + ) as _i13.Future<_i9.BaseConfig>); @override _i13.Future deleteConfig( int? id, - _i9.ConfigType? type, + _i8.ConfigType? type, ) => (super.noSuchMethod( Invocation.method( @@ -584,9 +599,9 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider { @override _i13.Future handleConfig( - _i9.SlotEntry? entry, + _i8.SlotEntry? entry, String? input, - _i9.ConfigType? type, + _i8.ConfigType? type, ) => (super.noSuchMethod( Invocation.method( @@ -612,19 +627,19 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider { ) as _i13.Future); @override - _i13.Future<_i9.SlotEntry> addSetting(_i9.SlotEntry? workoutSetting) => (super.noSuchMethod( + _i13.Future<_i8.SlotEntry> addSetting(_i8.SlotEntry? workoutSetting) => (super.noSuchMethod( Invocation.method( #addSetting, [workoutSetting], ), - returnValue: _i13.Future<_i9.SlotEntry>.value(_FakeSlotEntry_7( + returnValue: _i13.Future<_i8.SlotEntry>.value(_FakeSlotEntry_6( this, Invocation.method( #addSetting, [workoutSetting], ), )), - ) as _i13.Future<_i9.SlotEntry>); + ) as _i13.Future<_i8.SlotEntry>); @override _i13.Future fetchSessionData() => (super.noSuchMethod( diff --git a/test/workout/workout_set_form_test.dart b/test/workout/workout_set_form_test.dart deleted file mode 100644 index a8e435f0..00000000 --- a/test/workout/workout_set_form_test.dart +++ /dev/null @@ -1,105 +0,0 @@ -/* - * This file is part of wger Workout Manager . - * Copyright (C) 2020, 2021 wger Team - * - * wger Workout Manager is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * wger Workout Manager is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -import 'package:flutter/material.dart'; -import 'package:flutter_gen/gen_l10n/app_localizations.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:mockito/annotations.dart'; -import 'package:mockito/mockito.dart'; -import 'package:provider/provider.dart'; -import 'package:wger/helpers/consts.dart'; -import 'package:wger/models/workouts/day.dart'; -import 'package:wger/models/workouts/slot.dart'; -import 'package:wger/models/workouts/slot_entry.dart'; -import 'package:wger/providers/base_provider.dart'; -import 'package:wger/providers/exercises.dart'; -import 'package:wger/providers/routines.dart'; -import 'package:wger/widgets/routines/forms/slot.dart'; - -import '../../test_data/exercises.dart'; -import '../../test_data/routines.dart'; -import 'workout_set_form_test.mocks.dart'; - -@GenerateMocks([ExercisesProvider, WgerBaseProvider, RoutinesProvider]) -void main() { - var mockWorkoutPlans = MockRoutinesProvider(); - final mockBaseProvider = MockWgerBaseProvider(); - final mockExerciseProvider = MockExercisesProvider(); - final workoutPlan = getWorkout(); - - Day day = Day(); - - setUp(() { - day = workoutPlan.days.first; - mockWorkoutPlans = MockRoutinesProvider(); - }); - - Widget createHomeScreen({locale = 'en'}) { - return ChangeNotifierProvider( - create: (context) => RoutinesProvider( - mockBaseProvider, - mockExerciseProvider, - [workoutPlan], - ), - child: ChangeNotifierProvider( - create: (context) => mockExerciseProvider, - child: MaterialApp( - locale: Locale(locale), - localizationsDelegates: AppLocalizations.localizationsDelegates, - supportedLocales: AppLocalizations.supportedLocales, - navigatorKey: GlobalKey(), - home: Scaffold(body: SlotFormWidget(day)), - ), - ), - ); - } - - testWidgets('Test the widgets on the SetFormWidget', (WidgetTester tester) async { - await tester.pumpWidget(createHomeScreen()); - await tester.pumpAndSettle(); - - //TODO: why doesn't it find the typeahead? - //expect(find.byType(TypeAheadFormField), findsOneWidget); - expect(find.byType(Slider), findsOneWidget); - expect(find.byKey(const Key(SUBMIT_BUTTON_KEY_NAME)), findsOneWidget); - expect(find.byType(ElevatedButton), findsOneWidget); - }); - - testWidgets('Test creating a new set', (WidgetTester tester) async { - when(mockWorkoutPlans.addSlot(any)).thenAnswer((_) => Future.value(Slot.empty())); - when(mockWorkoutPlans.addSetting(any)).thenAnswer((_) => Future.value(SlotEntry.empty())); - when(mockExerciseProvider.searchExercise( - any, - languageCode: anyNamed('languageCode'), - searchEnglish: anyNamed('searchEnglish'), - )).thenAnswer((_) => Future.value([getTestExercises().first])); - - await tester.pumpWidget(createHomeScreen()); - await tester.pumpAndSettle(); - - await tester.enterText(find.byKey(const Key('field-typeahead')), 'exercise'); - await tester.pumpAndSettle(); - - //await tester.tap(find.byKey(const Key('exercise-1'))); - await tester.tap(find.byKey(const Key(SUBMIT_BUTTON_KEY_NAME))); - - //verify(mockWorkoutPlans.addSet(any)); - //verify(mockWorkoutPlans.addSettinbg(any)); - //verify(mockWorkoutPlans.fetchSmartText(any, any)); - }); -} diff --git a/test/workout/workout_set_form_test.mocks.dart b/test/workout/workout_set_form_test.mocks.dart deleted file mode 100644 index 1a59d3f8..00000000 --- a/test/workout/workout_set_form_test.mocks.dart +++ /dev/null @@ -1,1434 +0,0 @@ -// Mocks generated by Mockito 5.4.4 from annotations -// in wger/test/workout/workout_set_form_test.dart. -// Do not manually edit this file. - -// ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i21; -import 'dart:ui' as _i22; - -import 'package:http/http.dart' as _i10; -import 'package:mockito/mockito.dart' as _i1; -import 'package:mockito/src/dummies.dart' as _i25; -import 'package:wger/database/exercises/exercise_database.dart' as _i3; -import 'package:wger/models/exercises/category.dart' as _i5; -import 'package:wger/models/exercises/equipment.dart' as _i6; -import 'package:wger/models/exercises/exercise.dart' as _i4; -import 'package:wger/models/exercises/language.dart' as _i8; -import 'package:wger/models/exercises/muscle.dart' as _i7; -import 'package:wger/models/workouts/base_config.dart' as _i16; -import 'package:wger/models/workouts/day.dart' as _i14; -import 'package:wger/models/workouts/day_data.dart' as _i24; -import 'package:wger/models/workouts/log.dart' as _i19; -import 'package:wger/models/workouts/repetition_unit.dart' as _i12; -import 'package:wger/models/workouts/routine.dart' as _i13; -import 'package:wger/models/workouts/session.dart' as _i18; -import 'package:wger/models/workouts/slot.dart' as _i15; -import 'package:wger/models/workouts/slot_entry.dart' as _i17; -import 'package:wger/models/workouts/weight_unit.dart' as _i11; -import 'package:wger/providers/auth.dart' as _i9; -import 'package:wger/providers/base_provider.dart' as _i2; -import 'package:wger/providers/exercises.dart' as _i20; -import 'package:wger/providers/routines.dart' as _i23; - -// ignore_for_file: type=lint -// ignore_for_file: avoid_redundant_argument_values -// ignore_for_file: avoid_setters_without_getters -// ignore_for_file: comment_references -// ignore_for_file: deprecated_member_use -// ignore_for_file: deprecated_member_use_from_same_package -// ignore_for_file: implementation_imports -// ignore_for_file: invalid_use_of_visible_for_testing_member -// ignore_for_file: prefer_const_constructors -// ignore_for_file: unnecessary_parenthesis -// ignore_for_file: camel_case_types -// ignore_for_file: subtype_of_sealed_class - -class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvider { - _FakeWgerBaseProvider_0( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeExerciseDatabase_1 extends _i1.SmartFake implements _i3.ExerciseDatabase { - _FakeExerciseDatabase_1( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeExercise_2 extends _i1.SmartFake implements _i4.Exercise { - _FakeExercise_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeExerciseCategory_3 extends _i1.SmartFake implements _i5.ExerciseCategory { - _FakeExerciseCategory_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeEquipment_4 extends _i1.SmartFake implements _i6.Equipment { - _FakeEquipment_4( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeMuscle_5 extends _i1.SmartFake implements _i7.Muscle { - _FakeMuscle_5( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeLanguage_6 extends _i1.SmartFake implements _i8.Language { - _FakeLanguage_6( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeAuthProvider_7 extends _i1.SmartFake implements _i9.AuthProvider { - _FakeAuthProvider_7( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeClient_8 extends _i1.SmartFake implements _i10.Client { - _FakeClient_8( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeUri_9 extends _i1.SmartFake implements Uri { - _FakeUri_9( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeResponse_10 extends _i1.SmartFake implements _i10.Response { - _FakeResponse_10( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeWeightUnit_11 extends _i1.SmartFake implements _i11.WeightUnit { - _FakeWeightUnit_11( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeRepetitionUnit_12 extends _i1.SmartFake implements _i12.RepetitionUnit { - _FakeRepetitionUnit_12( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeRoutine_13 extends _i1.SmartFake implements _i13.Routine { - _FakeRoutine_13( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeDay_14 extends _i1.SmartFake implements _i14.Day { - _FakeDay_14( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeSlot_15 extends _i1.SmartFake implements _i15.Slot { - _FakeSlot_15( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeBaseConfig_16 extends _i1.SmartFake implements _i16.BaseConfig { - _FakeBaseConfig_16( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeSlotEntry_17 extends _i1.SmartFake implements _i17.SlotEntry { - _FakeSlotEntry_17( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeWorkoutSession_18 extends _i1.SmartFake implements _i18.WorkoutSession { - _FakeWorkoutSession_18( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeLog_19 extends _i1.SmartFake implements _i19.Log { - _FakeLog_19( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -/// A class which mocks [ExercisesProvider]. -/// -/// See the documentation for Mockito's code generation for more information. -class MockExercisesProvider extends _i1.Mock implements _i20.ExercisesProvider { - MockExercisesProvider() { - _i1.throwOnMissingStub(this); - } - - @override - _i2.WgerBaseProvider get baseProvider => (super.noSuchMethod( - Invocation.getter(#baseProvider), - returnValue: _FakeWgerBaseProvider_0( - this, - Invocation.getter(#baseProvider), - ), - ) as _i2.WgerBaseProvider); - - @override - _i3.ExerciseDatabase get database => (super.noSuchMethod( - Invocation.getter(#database), - returnValue: _FakeExerciseDatabase_1( - this, - Invocation.getter(#database), - ), - ) as _i3.ExerciseDatabase); - - @override - set database(_i3.ExerciseDatabase? _database) => super.noSuchMethod( - Invocation.setter( - #database, - _database, - ), - returnValueForMissingStub: null, - ); - - @override - List<_i4.Exercise> get exercises => (super.noSuchMethod( - Invocation.getter(#exercises), - returnValue: <_i4.Exercise>[], - ) as List<_i4.Exercise>); - - @override - set exercises(List<_i4.Exercise>? _exercises) => super.noSuchMethod( - Invocation.setter( - #exercises, - _exercises, - ), - returnValueForMissingStub: null, - ); - - @override - List<_i4.Exercise> get filteredExercises => (super.noSuchMethod( - Invocation.getter(#filteredExercises), - returnValue: <_i4.Exercise>[], - ) as List<_i4.Exercise>); - - @override - set filteredExercises(List<_i4.Exercise>? newFilteredExercises) => super.noSuchMethod( - Invocation.setter( - #filteredExercises, - newFilteredExercises, - ), - returnValueForMissingStub: null, - ); - - @override - Map> get exerciseBasesByVariation => (super.noSuchMethod( - Invocation.getter(#exerciseBasesByVariation), - returnValue: >{}, - ) as Map>); - - @override - List<_i5.ExerciseCategory> get categories => (super.noSuchMethod( - Invocation.getter(#categories), - returnValue: <_i5.ExerciseCategory>[], - ) as List<_i5.ExerciseCategory>); - - @override - List<_i7.Muscle> get muscles => (super.noSuchMethod( - Invocation.getter(#muscles), - returnValue: <_i7.Muscle>[], - ) as List<_i7.Muscle>); - - @override - List<_i6.Equipment> get equipment => (super.noSuchMethod( - Invocation.getter(#equipment), - returnValue: <_i6.Equipment>[], - ) as List<_i6.Equipment>); - - @override - List<_i8.Language> get languages => (super.noSuchMethod( - Invocation.getter(#languages), - returnValue: <_i8.Language>[], - ) as List<_i8.Language>); - - @override - set languages(List<_i8.Language>? languages) => super.noSuchMethod( - Invocation.setter( - #languages, - languages, - ), - returnValueForMissingStub: null, - ); - - @override - bool get hasListeners => (super.noSuchMethod( - Invocation.getter(#hasListeners), - returnValue: false, - ) as bool); - - @override - _i21.Future setFilters(_i20.Filters? newFilters) => (super.noSuchMethod( - Invocation.method( - #setFilters, - [newFilters], - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - void initFilters() => super.noSuchMethod( - Invocation.method( - #initFilters, - [], - ), - returnValueForMissingStub: null, - ); - - @override - _i21.Future findByFilters() => (super.noSuchMethod( - Invocation.method( - #findByFilters, - [], - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - void clear() => super.noSuchMethod( - Invocation.method( - #clear, - [], - ), - returnValueForMissingStub: null, - ); - - @override - _i4.Exercise findExerciseById(int? id) => (super.noSuchMethod( - Invocation.method( - #findExerciseById, - [id], - ), - returnValue: _FakeExercise_2( - this, - Invocation.method( - #findExerciseById, - [id], - ), - ), - ) as _i4.Exercise); - - @override - List<_i4.Exercise> findExercisesByVariationId( - int? id, { - int? exerciseBaseIdToExclude, - }) => - (super.noSuchMethod( - Invocation.method( - #findExercisesByVariationId, - [id], - {#exerciseBaseIdToExclude: exerciseBaseIdToExclude}, - ), - returnValue: <_i4.Exercise>[], - ) as List<_i4.Exercise>); - - @override - _i5.ExerciseCategory findCategoryById(int? id) => (super.noSuchMethod( - Invocation.method( - #findCategoryById, - [id], - ), - returnValue: _FakeExerciseCategory_3( - this, - Invocation.method( - #findCategoryById, - [id], - ), - ), - ) as _i5.ExerciseCategory); - - @override - _i6.Equipment findEquipmentById(int? id) => (super.noSuchMethod( - Invocation.method( - #findEquipmentById, - [id], - ), - returnValue: _FakeEquipment_4( - this, - Invocation.method( - #findEquipmentById, - [id], - ), - ), - ) as _i6.Equipment); - - @override - _i7.Muscle findMuscleById(int? id) => (super.noSuchMethod( - Invocation.method( - #findMuscleById, - [id], - ), - returnValue: _FakeMuscle_5( - this, - Invocation.method( - #findMuscleById, - [id], - ), - ), - ) as _i7.Muscle); - - @override - _i8.Language findLanguageById(int? id) => (super.noSuchMethod( - Invocation.method( - #findLanguageById, - [id], - ), - returnValue: _FakeLanguage_6( - this, - Invocation.method( - #findLanguageById, - [id], - ), - ), - ) as _i8.Language); - - @override - _i21.Future fetchAndSetCategoriesFromApi() => (super.noSuchMethod( - Invocation.method( - #fetchAndSetCategoriesFromApi, - [], - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - _i21.Future fetchAndSetMusclesFromApi() => (super.noSuchMethod( - Invocation.method( - #fetchAndSetMusclesFromApi, - [], - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - _i21.Future fetchAndSetEquipmentsFromApi() => (super.noSuchMethod( - Invocation.method( - #fetchAndSetEquipmentsFromApi, - [], - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - _i21.Future fetchAndSetLanguagesFromApi() => (super.noSuchMethod( - Invocation.method( - #fetchAndSetLanguagesFromApi, - [], - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - _i21.Future<_i4.Exercise?> fetchAndSetExercise(int? exerciseId) => (super.noSuchMethod( - Invocation.method( - #fetchAndSetExercise, - [exerciseId], - ), - returnValue: _i21.Future<_i4.Exercise?>.value(), - ) as _i21.Future<_i4.Exercise?>); - - @override - _i21.Future<_i4.Exercise> handleUpdateExerciseFromApi( - _i3.ExerciseDatabase? database, - int? exerciseId, - ) => - (super.noSuchMethod( - Invocation.method( - #handleUpdateExerciseFromApi, - [ - database, - exerciseId, - ], - ), - returnValue: _i21.Future<_i4.Exercise>.value(_FakeExercise_2( - this, - Invocation.method( - #handleUpdateExerciseFromApi, - [ - database, - exerciseId, - ], - ), - )), - ) as _i21.Future<_i4.Exercise>); - - @override - _i21.Future initCacheTimesLocalPrefs({dynamic forceInit = false}) => (super.noSuchMethod( - Invocation.method( - #initCacheTimesLocalPrefs, - [], - {#forceInit: forceInit}, - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - _i21.Future clearAllCachesAndPrefs() => (super.noSuchMethod( - Invocation.method( - #clearAllCachesAndPrefs, - [], - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - _i21.Future fetchAndSetInitialData() => (super.noSuchMethod( - Invocation.method( - #fetchAndSetInitialData, - [], - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - _i21.Future setExercisesFromDatabase( - _i3.ExerciseDatabase? database, { - bool? forceDeleteCache = false, - }) => - (super.noSuchMethod( - Invocation.method( - #setExercisesFromDatabase, - [database], - {#forceDeleteCache: forceDeleteCache}, - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - _i21.Future fetchAndSetMuscles(_i3.ExerciseDatabase? database) => (super.noSuchMethod( - Invocation.method( - #fetchAndSetMuscles, - [database], - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - _i21.Future fetchAndSetCategories(_i3.ExerciseDatabase? database) => (super.noSuchMethod( - Invocation.method( - #fetchAndSetCategories, - [database], - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - _i21.Future fetchAndSetLanguages(_i3.ExerciseDatabase? database) => (super.noSuchMethod( - Invocation.method( - #fetchAndSetLanguages, - [database], - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - _i21.Future fetchAndSetEquipments(_i3.ExerciseDatabase? database) => (super.noSuchMethod( - Invocation.method( - #fetchAndSetEquipments, - [database], - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - _i21.Future> searchExercise( - String? name, { - String? languageCode = r'en', - bool? searchEnglish = false, - }) => - (super.noSuchMethod( - Invocation.method( - #searchExercise, - [name], - { - #languageCode: languageCode, - #searchEnglish: searchEnglish, - }, - ), - returnValue: _i21.Future>.value(<_i4.Exercise>[]), - ) as _i21.Future>); - - @override - void addListener(_i22.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #addListener, - [listener], - ), - returnValueForMissingStub: null, - ); - - @override - void removeListener(_i22.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #removeListener, - [listener], - ), - returnValueForMissingStub: null, - ); - - @override - void dispose() => super.noSuchMethod( - Invocation.method( - #dispose, - [], - ), - returnValueForMissingStub: null, - ); - - @override - void notifyListeners() => super.noSuchMethod( - Invocation.method( - #notifyListeners, - [], - ), - returnValueForMissingStub: null, - ); -} - -/// A class which mocks [WgerBaseProvider]. -/// -/// See the documentation for Mockito's code generation for more information. -class MockWgerBaseProvider extends _i1.Mock implements _i2.WgerBaseProvider { - MockWgerBaseProvider() { - _i1.throwOnMissingStub(this); - } - - @override - _i9.AuthProvider get auth => (super.noSuchMethod( - Invocation.getter(#auth), - returnValue: _FakeAuthProvider_7( - this, - Invocation.getter(#auth), - ), - ) as _i9.AuthProvider); - - @override - set auth(_i9.AuthProvider? _auth) => super.noSuchMethod( - Invocation.setter( - #auth, - _auth, - ), - returnValueForMissingStub: null, - ); - - @override - _i10.Client get client => (super.noSuchMethod( - Invocation.getter(#client), - returnValue: _FakeClient_8( - this, - Invocation.getter(#client), - ), - ) as _i10.Client); - - @override - set client(_i10.Client? _client) => super.noSuchMethod( - Invocation.setter( - #client, - _client, - ), - returnValueForMissingStub: null, - ); - - @override - Map getDefaultHeaders({bool? includeAuth = false}) => (super.noSuchMethod( - Invocation.method( - #getDefaultHeaders, - [], - {#includeAuth: includeAuth}, - ), - returnValue: {}, - ) as Map); - - @override - Uri makeUrl( - String? path, { - int? id, - String? objectMethod, - Map? query, - }) => - (super.noSuchMethod( - Invocation.method( - #makeUrl, - [path], - { - #id: id, - #objectMethod: objectMethod, - #query: query, - }, - ), - returnValue: _FakeUri_9( - this, - Invocation.method( - #makeUrl, - [path], - { - #id: id, - #objectMethod: objectMethod, - #query: query, - }, - ), - ), - ) as Uri); - - @override - _i21.Future fetch(Uri? uri) => (super.noSuchMethod( - Invocation.method( - #fetch, - [uri], - ), - returnValue: _i21.Future.value(), - ) as _i21.Future); - - @override - _i21.Future> fetchPaginated(Uri? uri) => (super.noSuchMethod( - Invocation.method( - #fetchPaginated, - [uri], - ), - returnValue: _i21.Future>.value([]), - ) as _i21.Future>); - - @override - _i21.Future> post( - Map? data, - Uri? uri, - ) => - (super.noSuchMethod( - Invocation.method( - #post, - [ - data, - uri, - ], - ), - returnValue: _i21.Future>.value({}), - ) as _i21.Future>); - - @override - _i21.Future> patch( - Map? data, - Uri? uri, - ) => - (super.noSuchMethod( - Invocation.method( - #patch, - [ - data, - uri, - ], - ), - returnValue: _i21.Future>.value({}), - ) as _i21.Future>); - - @override - _i21.Future<_i10.Response> deleteRequest( - String? url, - int? id, - ) => - (super.noSuchMethod( - Invocation.method( - #deleteRequest, - [ - url, - id, - ], - ), - returnValue: _i21.Future<_i10.Response>.value(_FakeResponse_10( - this, - Invocation.method( - #deleteRequest, - [ - url, - id, - ], - ), - )), - ) as _i21.Future<_i10.Response>); -} - -/// A class which mocks [RoutinesProvider]. -/// -/// See the documentation for Mockito's code generation for more information. -class MockRoutinesProvider extends _i1.Mock implements _i23.RoutinesProvider { - MockRoutinesProvider() { - _i1.throwOnMissingStub(this); - } - - @override - _i2.WgerBaseProvider get baseProvider => (super.noSuchMethod( - Invocation.getter(#baseProvider), - returnValue: _FakeWgerBaseProvider_0( - this, - Invocation.getter(#baseProvider), - ), - ) as _i2.WgerBaseProvider); - - @override - List<_i13.Routine> get items => (super.noSuchMethod( - Invocation.getter(#items), - returnValue: <_i13.Routine>[], - ) as List<_i13.Routine>); - - @override - List<_i11.WeightUnit> get weightUnits => (super.noSuchMethod( - Invocation.getter(#weightUnits), - returnValue: <_i11.WeightUnit>[], - ) as List<_i11.WeightUnit>); - - @override - _i11.WeightUnit get defaultWeightUnit => (super.noSuchMethod( - Invocation.getter(#defaultWeightUnit), - returnValue: _FakeWeightUnit_11( - this, - Invocation.getter(#defaultWeightUnit), - ), - ) as _i11.WeightUnit); - - @override - List<_i12.RepetitionUnit> get repetitionUnits => (super.noSuchMethod( - Invocation.getter(#repetitionUnits), - returnValue: <_i12.RepetitionUnit>[], - ) as List<_i12.RepetitionUnit>); - - @override - _i12.RepetitionUnit get defaultRepetitionUnit => (super.noSuchMethod( - Invocation.getter(#defaultRepetitionUnit), - returnValue: _FakeRepetitionUnit_12( - this, - Invocation.getter(#defaultRepetitionUnit), - ), - ) as _i12.RepetitionUnit); - - @override - bool get hasListeners => (super.noSuchMethod( - Invocation.getter(#hasListeners), - returnValue: false, - ) as bool); - - @override - void clear() => super.noSuchMethod( - Invocation.method( - #clear, - [], - ), - returnValueForMissingStub: null, - ); - - @override - List<_i13.Routine> getPlans() => (super.noSuchMethod( - Invocation.method( - #getPlans, - [], - ), - returnValue: <_i13.Routine>[], - ) as List<_i13.Routine>); - - @override - _i13.Routine findById(int? id) => (super.noSuchMethod( - Invocation.method( - #findById, - [id], - ), - returnValue: _FakeRoutine_13( - this, - Invocation.method( - #findById, - [id], - ), - ), - ) as _i13.Routine); - - @override - int findIndexById(int? id) => (super.noSuchMethod( - Invocation.method( - #findIndexById, - [id], - ), - returnValue: 0, - ) as int); - - @override - void setCurrentPlan(int? id) => super.noSuchMethod( - Invocation.method( - #setCurrentPlan, - [id], - ), - returnValueForMissingStub: null, - ); - - @override - void resetCurrentPlan() => super.noSuchMethod( - Invocation.method( - #resetCurrentPlan, - [], - ), - returnValueForMissingStub: null, - ); - - @override - _i21.Future fetchAndSetAllRoutinesFull() => (super.noSuchMethod( - Invocation.method( - #fetchAndSetAllRoutinesFull, - [], - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - _i21.Future fetchAndSetAllPlansSparse() => (super.noSuchMethod( - Invocation.method( - #fetchAndSetAllPlansSparse, - [], - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - void setExercisesAndUnits(List<_i24.DayData>? entries) => super.noSuchMethod( - Invocation.method( - #setExercisesAndUnits, - [entries], - ), - returnValueForMissingStub: null, - ); - - @override - _i21.Future<_i13.Routine> fetchAndSetRoutineSparse(int? planId) => (super.noSuchMethod( - Invocation.method( - #fetchAndSetRoutineSparse, - [planId], - ), - returnValue: _i21.Future<_i13.Routine>.value(_FakeRoutine_13( - this, - Invocation.method( - #fetchAndSetRoutineSparse, - [planId], - ), - )), - ) as _i21.Future<_i13.Routine>); - - @override - _i21.Future<_i13.Routine> fetchAndSetRoutineFull(int? routineId) => (super.noSuchMethod( - Invocation.method( - #fetchAndSetRoutineFull, - [routineId], - ), - returnValue: _i21.Future<_i13.Routine>.value(_FakeRoutine_13( - this, - Invocation.method( - #fetchAndSetRoutineFull, - [routineId], - ), - )), - ) as _i21.Future<_i13.Routine>); - - @override - _i21.Future<_i13.Routine> addRoutine(_i13.Routine? routine) => (super.noSuchMethod( - Invocation.method( - #addRoutine, - [routine], - ), - returnValue: _i21.Future<_i13.Routine>.value(_FakeRoutine_13( - this, - Invocation.method( - #addRoutine, - [routine], - ), - )), - ) as _i21.Future<_i13.Routine>); - - @override - _i21.Future editRoutine(_i13.Routine? routine) => (super.noSuchMethod( - Invocation.method( - #editRoutine, - [routine], - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - _i21.Future deleteRoutine(int? id) => (super.noSuchMethod( - Invocation.method( - #deleteRoutine, - [id], - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - _i21.Future> fetchLogData( - _i13.Routine? workout, - _i4.Exercise? base, - ) => - (super.noSuchMethod( - Invocation.method( - #fetchLogData, - [ - workout, - base, - ], - ), - returnValue: _i21.Future>.value({}), - ) as _i21.Future>); - - @override - _i21.Future fetchAndSetRepetitionUnits() => (super.noSuchMethod( - Invocation.method( - #fetchAndSetRepetitionUnits, - [], - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - _i21.Future fetchAndSetWeightUnits() => (super.noSuchMethod( - Invocation.method( - #fetchAndSetWeightUnits, - [], - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - _i21.Future fetchAndSetUnits() => (super.noSuchMethod( - Invocation.method( - #fetchAndSetUnits, - [], - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - _i21.Future<_i14.Day> addDay( - _i14.Day? day, { - dynamic refresh = false, - }) => - (super.noSuchMethod( - Invocation.method( - #addDay, - [day], - {#refresh: refresh}, - ), - returnValue: _i21.Future<_i14.Day>.value(_FakeDay_14( - this, - Invocation.method( - #addDay, - [day], - {#refresh: refresh}, - ), - )), - ) as _i21.Future<_i14.Day>); - - @override - _i21.Future editDay(_i14.Day? day) => (super.noSuchMethod( - Invocation.method( - #editDay, - [day], - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - _i21.Future editDays(List<_i14.Day>? days) => (super.noSuchMethod( - Invocation.method( - #editDays, - [days], - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - _i21.Future deleteDay(int? dayId) => (super.noSuchMethod( - Invocation.method( - #deleteDay, - [dayId], - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - _i21.Future<_i15.Slot> addSlot(_i15.Slot? slot) => (super.noSuchMethod( - Invocation.method( - #addSlot, - [slot], - ), - returnValue: _i21.Future<_i15.Slot>.value(_FakeSlot_15( - this, - Invocation.method( - #addSlot, - [slot], - ), - )), - ) as _i21.Future<_i15.Slot>); - - @override - _i21.Future deleteSlot(int? slotId) => (super.noSuchMethod( - Invocation.method( - #deleteSlot, - [slotId], - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - _i21.Future editSlot(_i15.Slot? workoutSet) => (super.noSuchMethod( - Invocation.method( - #editSlot, - [workoutSet], - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - _i21.Future editSlots(List<_i15.Slot>? slots) => (super.noSuchMethod( - Invocation.method( - #editSlots, - [slots], - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - _i21.Future deleteSlotEntry(int? id) => (super.noSuchMethod( - Invocation.method( - #deleteSlotEntry, - [id], - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - String getConfigUrl(_i17.ConfigType? type) => (super.noSuchMethod( - Invocation.method( - #getConfigUrl, - [type], - ), - returnValue: _i25.dummyValue( - this, - Invocation.method( - #getConfigUrl, - [type], - ), - ), - ) as String); - - @override - _i21.Future<_i16.BaseConfig> editConfig( - _i16.BaseConfig? config, - _i17.ConfigType? type, - ) => - (super.noSuchMethod( - Invocation.method( - #editConfig, - [ - config, - type, - ], - ), - returnValue: _i21.Future<_i16.BaseConfig>.value(_FakeBaseConfig_16( - this, - Invocation.method( - #editConfig, - [ - config, - type, - ], - ), - )), - ) as _i21.Future<_i16.BaseConfig>); - - @override - _i21.Future<_i16.BaseConfig> addConfig( - _i16.BaseConfig? config, - _i17.ConfigType? type, - ) => - (super.noSuchMethod( - Invocation.method( - #addConfig, - [ - config, - type, - ], - ), - returnValue: _i21.Future<_i16.BaseConfig>.value(_FakeBaseConfig_16( - this, - Invocation.method( - #addConfig, - [ - config, - type, - ], - ), - )), - ) as _i21.Future<_i16.BaseConfig>); - - @override - _i21.Future deleteConfig( - int? id, - _i17.ConfigType? type, - ) => - (super.noSuchMethod( - Invocation.method( - #deleteConfig, - [ - id, - type, - ], - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - _i21.Future handleConfig( - _i17.SlotEntry? entry, - String? input, - _i17.ConfigType? type, - ) => - (super.noSuchMethod( - Invocation.method( - #handleConfig, - [ - entry, - input, - type, - ], - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - _i21.Future fetchComputedSettings(_i15.Slot? slot) => (super.noSuchMethod( - Invocation.method( - #fetchComputedSettings, - [slot], - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - _i21.Future<_i17.SlotEntry> addSetting(_i17.SlotEntry? workoutSetting) => (super.noSuchMethod( - Invocation.method( - #addSetting, - [workoutSetting], - ), - returnValue: _i21.Future<_i17.SlotEntry>.value(_FakeSlotEntry_17( - this, - Invocation.method( - #addSetting, - [workoutSetting], - ), - )), - ) as _i21.Future<_i17.SlotEntry>); - - @override - _i21.Future fetchSessionData() => (super.noSuchMethod( - Invocation.method( - #fetchSessionData, - [], - ), - returnValue: _i21.Future.value(), - ) as _i21.Future); - - @override - _i21.Future<_i18.WorkoutSession> addSession(_i18.WorkoutSession? session) => (super.noSuchMethod( - Invocation.method( - #addSession, - [session], - ), - returnValue: _i21.Future<_i18.WorkoutSession>.value(_FakeWorkoutSession_18( - this, - Invocation.method( - #addSession, - [session], - ), - )), - ) as _i21.Future<_i18.WorkoutSession>); - - @override - _i21.Future<_i19.Log> addLog(_i19.Log? log) => (super.noSuchMethod( - Invocation.method( - #addLog, - [log], - ), - returnValue: _i21.Future<_i19.Log>.value(_FakeLog_19( - this, - Invocation.method( - #addLog, - [log], - ), - )), - ) as _i21.Future<_i19.Log>); - - @override - _i21.Future deleteLog(_i19.Log? log) => (super.noSuchMethod( - Invocation.method( - #deleteLog, - [log], - ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); - - @override - void addListener(_i22.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #addListener, - [listener], - ), - returnValueForMissingStub: null, - ); - - @override - void removeListener(_i22.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #removeListener, - [listener], - ), - returnValueForMissingStub: null, - ); - - @override - void dispose() => super.noSuchMethod( - Invocation.method( - #dispose, - [], - ), - returnValueForMissingStub: null, - ); - - @override - void notifyListeners() => super.noSuchMethod( - Invocation.method( - #notifyListeners, - [], - ), - returnValueForMissingStub: null, - ); -}