mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
Merge branch 'master' into feature/material-3
# Conflicts: # lib/widgets/nutrition/meal.dart # lib/widgets/workouts/day.dart
This commit is contained in:
@@ -40,4 +40,4 @@ Iterable<Color> generateChartColors(int nrOfItems) sync* {
|
||||
for (final color in colors) {
|
||||
yield color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,6 +88,7 @@ const LANGUAGE_SHORT_ENGLISH = 'en';
|
||||
///
|
||||
/// Values taken from exercises/models/image.py
|
||||
enum EXERCISE_IMAGE_ART_STYLE {
|
||||
// ignore: unused_field
|
||||
_, // 0 is not used
|
||||
LINE_ART,
|
||||
THREE_D,
|
||||
|
||||
@@ -18,8 +18,7 @@ WeightEntry _$WeightEntryFromJson(Map<String, dynamic> json) {
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$WeightEntryToJson(WeightEntry instance) =>
|
||||
<String, dynamic>{
|
||||
Map<String, dynamic> _$WeightEntryToJson(WeightEntry instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'weight': numToString(instance.weight),
|
||||
'date': toDate(instance.date),
|
||||
|
||||
@@ -24,26 +24,18 @@ ExerciseBase _$ExerciseBaseFromJson(Map<String, dynamic> json) {
|
||||
return ExerciseBase(
|
||||
id: json['id'] as int?,
|
||||
uuid: json['uuid'] as String?,
|
||||
created: json['created'] == null
|
||||
? null
|
||||
: DateTime.parse(json['created'] as String),
|
||||
lastUpdate: json['last_update'] == null
|
||||
? null
|
||||
: DateTime.parse(json['last_update'] as String),
|
||||
created: json['created'] == null ? null : DateTime.parse(json['created'] as String),
|
||||
lastUpdate: json['last_update'] == null ? null : DateTime.parse(json['last_update'] as String),
|
||||
variationId: json['variations'] as int?,
|
||||
)
|
||||
..categoryId = json['category'] as int
|
||||
..musclesIds =
|
||||
(json['muscles'] as List<dynamic>).map((e) => e as int).toList()
|
||||
..musclesSecondaryIds = (json['muscles_secondary'] as List<dynamic>)
|
||||
.map((e) => e as int)
|
||||
.toList()
|
||||
..equipmentIds =
|
||||
(json['equipment'] as List<dynamic>).map((e) => e as int).toList();
|
||||
..musclesIds = (json['muscles'] as List<dynamic>).map((e) => e as int).toList()
|
||||
..musclesSecondaryIds =
|
||||
(json['muscles_secondary'] as List<dynamic>).map((e) => e as int).toList()
|
||||
..equipmentIds = (json['equipment'] as List<dynamic>).map((e) => e as int).toList();
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$ExerciseBaseToJson(ExerciseBase instance) =>
|
||||
<String, dynamic>{
|
||||
Map<String, dynamic> _$ExerciseBaseToJson(ExerciseBase instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'uuid': instance.uuid,
|
||||
'variations': instance.variationId,
|
||||
|
||||
@@ -17,8 +17,7 @@ ExerciseCategory _$ExerciseCategoryFromJson(Map<String, dynamic> json) {
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$ExerciseCategoryToJson(ExerciseCategory instance) =>
|
||||
<String, dynamic>{
|
||||
Map<String, dynamic> _$ExerciseCategoryToJson(ExerciseCategory instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'name': instance.name,
|
||||
};
|
||||
|
||||
@@ -20,8 +20,7 @@ ExerciseImage _$ExerciseImageFromJson(Map<String, dynamic> json) {
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$ExerciseImageToJson(ExerciseImage instance) =>
|
||||
<String, dynamic>{
|
||||
Map<String, dynamic> _$ExerciseImageToJson(ExerciseImage instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'uuid': instance.uuid,
|
||||
'exercise_base': instance.exerciseBaseId,
|
||||
|
||||
@@ -22,17 +22,14 @@ Translation _$TranslationFromJson(Map<String, dynamic> json) {
|
||||
return Translation(
|
||||
id: json['id'] as int?,
|
||||
uuid: json['uuid'] as String?,
|
||||
created: json['created'] == null
|
||||
? null
|
||||
: DateTime.parse(json['created'] as String),
|
||||
created: json['created'] == null ? null : DateTime.parse(json['created'] as String),
|
||||
name: json['name'] as String,
|
||||
description: json['description'] as String,
|
||||
baseId: json['exercise_base'] as int?,
|
||||
)..languageId = json['language'] as int;
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$TranslationToJson(Translation instance) =>
|
||||
<String, dynamic>{
|
||||
Map<String, dynamic> _$TranslationToJson(Translation instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'uuid': instance.uuid,
|
||||
'language': instance.languageId,
|
||||
|
||||
@@ -22,9 +22,7 @@ MeasurementCategory _$MeasurementCategoryFromJson(Map<String, dynamic> json) {
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$MeasurementCategoryToJson(
|
||||
MeasurementCategory instance) =>
|
||||
<String, dynamic>{
|
||||
Map<String, dynamic> _$MeasurementCategoryToJson(MeasurementCategory instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'name': instance.name,
|
||||
'unit': instance.unit,
|
||||
|
||||
@@ -20,8 +20,7 @@ MeasurementEntry _$MeasurementEntryFromJson(Map<String, dynamic> json) {
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$MeasurementEntryToJson(MeasurementEntry instance) =>
|
||||
<String, dynamic>{
|
||||
Map<String, dynamic> _$MeasurementEntryToJson(MeasurementEntry instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'category': instance.category,
|
||||
'date': toDate(instance.date),
|
||||
|
||||
@@ -38,8 +38,7 @@ IngredientImage _$IngredientImageFromJson(Map<String, dynamic> json) {
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$IngredientImageToJson(IngredientImage instance) =>
|
||||
<String, dynamic>{
|
||||
Map<String, dynamic> _$IngredientImageToJson(IngredientImage instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'uuid': instance.uuid,
|
||||
'ingredient_id': instance.ingredientId,
|
||||
|
||||
@@ -43,8 +43,7 @@ Ingredient _$IngredientFromJson(Map<String, dynamic> json) {
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$IngredientToJson(Ingredient instance) =>
|
||||
<String, dynamic>{
|
||||
Map<String, dynamic> _$IngredientToJson(Ingredient instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'code': instance.code,
|
||||
'name': instance.name,
|
||||
|
||||
@@ -13,16 +13,14 @@ IngredientWeightUnit _$IngredientWeightUnitFromJson(Map<String, dynamic> json) {
|
||||
);
|
||||
return IngredientWeightUnit(
|
||||
id: json['id'] as int,
|
||||
weightUnit:
|
||||
WeightUnit.fromJson(json['weight_unit'] as Map<String, dynamic>),
|
||||
weightUnit: WeightUnit.fromJson(json['weight_unit'] as Map<String, dynamic>),
|
||||
ingredient: Ingredient.fromJson(json['ingredient'] as Map<String, dynamic>),
|
||||
grams: json['grams'] as int,
|
||||
amount: (json['amount'] as num).toDouble(),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$IngredientWeightUnitToJson(
|
||||
IngredientWeightUnit instance) =>
|
||||
Map<String, dynamic> _$IngredientWeightUnitToJson(IngredientWeightUnit instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'weight_unit': instance.weightUnit,
|
||||
|
||||
@@ -9,14 +9,7 @@ part of 'log.dart';
|
||||
Log _$LogFromJson(Map<String, dynamic> json) {
|
||||
$checkKeys(
|
||||
json,
|
||||
requiredKeys: const [
|
||||
'id',
|
||||
'plan',
|
||||
'datetime',
|
||||
'ingredient',
|
||||
'weight_unit',
|
||||
'amount'
|
||||
],
|
||||
requiredKeys: const ['id', 'plan', 'datetime', 'ingredient', 'weight_unit', 'amount'],
|
||||
);
|
||||
return Log(
|
||||
id: json['id'] as int?,
|
||||
|
||||
@@ -18,8 +18,7 @@ NutritionalPlan _$NutritionalPlanFromJson(Map<String, dynamic> json) {
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$NutritionalPlanToJson(NutritionalPlan instance) =>
|
||||
<String, dynamic>{
|
||||
Map<String, dynamic> _$NutritionalPlanToJson(NutritionalPlan instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'description': instance.description,
|
||||
'creation_date': toDate(instance.creationDate),
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'dart:ui';
|
||||
|
||||
class NutritionalValues {
|
||||
double energy = 0;
|
||||
double protein = 0;
|
||||
|
||||
@@ -17,8 +17,7 @@ WeightUnit _$WeightUnitFromJson(Map<String, dynamic> json) {
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$WeightUnitToJson(WeightUnit instance) =>
|
||||
<String, dynamic>{
|
||||
Map<String, dynamic> _$WeightUnitToJson(WeightUnit instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'name': instance.name,
|
||||
};
|
||||
|
||||
@@ -9,12 +9,7 @@ part of 'profile.dart';
|
||||
Profile _$ProfileFromJson(Map<String, dynamic> json) {
|
||||
$checkKeys(
|
||||
json,
|
||||
requiredKeys: const [
|
||||
'username',
|
||||
'email_verified',
|
||||
'is_trustworthy',
|
||||
'email'
|
||||
],
|
||||
requiredKeys: const ['username', 'email_verified', 'is_trustworthy', 'email'],
|
||||
);
|
||||
return Profile(
|
||||
username: json['username'] as String,
|
||||
|
||||
@@ -17,8 +17,7 @@ RepetitionUnit _$RepetitionUnitFromJson(Map<String, dynamic> json) {
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$RepetitionUnitToJson(RepetitionUnit instance) =>
|
||||
<String, dynamic>{
|
||||
Map<String, dynamic> _$RepetitionUnitToJson(RepetitionUnit instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'name': instance.name,
|
||||
};
|
||||
|
||||
@@ -9,14 +9,7 @@ part of 'session.dart';
|
||||
WorkoutSession _$WorkoutSessionFromJson(Map<String, dynamic> json) {
|
||||
$checkKeys(
|
||||
json,
|
||||
requiredKeys: const [
|
||||
'id',
|
||||
'workout',
|
||||
'date',
|
||||
'impression',
|
||||
'time_start',
|
||||
'time_end'
|
||||
],
|
||||
requiredKeys: const ['id', 'workout', 'date', 'impression', 'time_start', 'time_end'],
|
||||
);
|
||||
return WorkoutSession()
|
||||
..id = json['id'] as int?
|
||||
@@ -28,8 +21,7 @@ WorkoutSession _$WorkoutSessionFromJson(Map<String, dynamic> json) {
|
||||
..timeEnd = stringToTime(json['time_end'] as String?);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$WorkoutSessionToJson(WorkoutSession instance) =>
|
||||
<String, dynamic>{
|
||||
Map<String, dynamic> _$WorkoutSessionToJson(WorkoutSession instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'workout': instance.workoutId,
|
||||
'date': toDate(instance.date),
|
||||
|
||||
@@ -17,8 +17,7 @@ WeightUnit _$WeightUnitFromJson(Map<String, dynamic> json) {
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$WeightUnitToJson(WeightUnit instance) =>
|
||||
<String, dynamic>{
|
||||
Map<String, dynamic> _$WeightUnitToJson(WeightUnit instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'name': instance.name,
|
||||
};
|
||||
|
||||
@@ -19,8 +19,7 @@ WorkoutPlan _$WorkoutPlanFromJson(Map<String, dynamic> json) {
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$WorkoutPlanToJson(WorkoutPlan instance) =>
|
||||
<String, dynamic>{
|
||||
Map<String, dynamic> _$WorkoutPlanToJson(WorkoutPlan instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'creation_date': instance.creationDate.toIso8601String(),
|
||||
'name': instance.name,
|
||||
|
||||
@@ -103,7 +103,7 @@ class GalleryProvider extends WgerBaseProvider with ChangeNotifier {
|
||||
}
|
||||
|
||||
Future<void> deleteImage(gallery.Image image) async {
|
||||
var response = await deleteRequest(_galleryUrlPath, image.id!);
|
||||
final response = await deleteRequest(_galleryUrlPath, image.id!);
|
||||
images.removeWhere((element) => element.id == image.id);
|
||||
|
||||
notifyListeners();
|
||||
|
||||
@@ -187,17 +187,19 @@ class _AuthCardState extends State<AuthCard> {
|
||||
_isLoading = false;
|
||||
});
|
||||
} on WgerHttpException catch (error) {
|
||||
showHttpExceptionErrorDialog(error, context);
|
||||
if (mounted) {
|
||||
showHttpExceptionErrorDialog(error, context);
|
||||
}
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
} catch (error) {
|
||||
if (mounted) {
|
||||
showErrorDialog(error, context);
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,7 +251,7 @@ class _AuthCardState extends State<AuthCard> {
|
||||
if (value == null || value.isEmpty) {
|
||||
return AppLocalizations.of(context).invalidUsername;
|
||||
}
|
||||
if (!RegExp(r'^[\w.@+-]+$').hasMatch(value!)) {
|
||||
if (!RegExp(r'^[\w.@+-]+$').hasMatch(value)) {
|
||||
return AppLocalizations.of(context).usernameValidChars;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,8 +49,8 @@ class _AddExerciseDropdownButtonState extends State<AddExerciseDropdownButton> {
|
||||
items: widget.items
|
||||
.map(
|
||||
(item) => DropdownMenuItem<String>(
|
||||
child: Text(item),
|
||||
value: item,
|
||||
child: Text(item),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
|
||||
@@ -49,7 +49,9 @@ mixin ExerciseImagePickerMixin {
|
||||
}
|
||||
|
||||
if (!isFileValid) {
|
||||
showDialog(context: context, builder: (context) => Text(errorMessage));
|
||||
if (context.mounted) {
|
||||
showDialog(context: context, builder: (context) => Text(errorMessage));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import 'package:wger/widgets/user/forms.dart';
|
||||
class MainAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
final String _title;
|
||||
|
||||
MainAppBar(this._title);
|
||||
const MainAppBar(this._title);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -116,7 +116,7 @@ class MainAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
class EmptyAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
final String _title;
|
||||
|
||||
EmptyAppBar(this._title);
|
||||
const EmptyAppBar(this._title);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@@ -13,7 +13,7 @@ class TextPrompt extends StatelessWidget {
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 12),
|
||||
padding: const EdgeInsets.only(top: 12),
|
||||
child: Text(AppLocalizations.of(context).textPromptSubheading),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -25,7 +25,7 @@ import 'package:wger/screens/add_exercise_screen.dart';
|
||||
import 'filter_modal.dart';
|
||||
|
||||
class FilterRow extends StatefulWidget {
|
||||
FilterRow({Key? key}) : super(key: key);
|
||||
const FilterRow({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_FilterRowState createState() => _FilterRowState();
|
||||
@@ -89,8 +89,8 @@ class _FilterRowState extends State<FilterRow> {
|
||||
itemBuilder: (context) {
|
||||
return [
|
||||
PopupMenuItem<ExerciseMoreOption>(
|
||||
child: Text(AppLocalizations.of(context).contributeExercise),
|
||||
value: ExerciseMoreOption.ADD_EXERCISE,
|
||||
child: Text(AppLocalizations.of(context).contributeExercise),
|
||||
)
|
||||
];
|
||||
},
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:video_player/video_player.dart';
|
||||
import 'package:wger/models/exercises/video.dart';
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@ import 'charts.dart';
|
||||
import 'forms.dart';
|
||||
|
||||
class CategoriesCard extends StatelessWidget {
|
||||
MeasurementCategory currentCategory;
|
||||
double? elevation;
|
||||
final MeasurementCategory currentCategory;
|
||||
final double? elevation;
|
||||
|
||||
CategoriesCard(this.currentCategory, {this.elevation});
|
||||
const CategoriesCard(this.currentCategory, {this.elevation});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/exceptions/http_exception.dart';
|
||||
@@ -110,11 +109,17 @@ class MeasurementCategoryForm extends StatelessWidget {
|
||||
: await Provider.of<MeasurementProvider>(context, listen: false).editCategory(
|
||||
categoryData['id'], categoryData['name'], categoryData['unit']);
|
||||
} on WgerHttpException catch (error) {
|
||||
showHttpExceptionErrorDialog(error, context);
|
||||
if (context.mounted) {
|
||||
showHttpExceptionErrorDialog(error, context);
|
||||
}
|
||||
} catch (error) {
|
||||
showErrorDialog(error, context);
|
||||
if (context.mounted) {
|
||||
showErrorDialog(error, context);
|
||||
}
|
||||
}
|
||||
if (context.mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
@@ -272,11 +277,17 @@ class MeasurementEntryForm extends StatelessWidget {
|
||||
_entryData['date'],
|
||||
);
|
||||
} on WgerHttpException catch (error) {
|
||||
showHttpExceptionErrorDialog(error, context);
|
||||
if (context.mounted) {
|
||||
showHttpExceptionErrorDialog(error, context);
|
||||
}
|
||||
} catch (error) {
|
||||
showErrorDialog(error, context);
|
||||
if (context.mounted) {
|
||||
showErrorDialog(error, context);
|
||||
}
|
||||
}
|
||||
if (context.mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
@@ -192,8 +192,8 @@ class MealItemForm extends StatelessWidget {
|
||||
),
|
||||
if (_listMealItems.isNotEmpty) const SizedBox(height: 10.0),
|
||||
Container(
|
||||
child: Text(AppLocalizations.of(context).recentlyUsedIngredients),
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Text(AppLocalizations.of(context).recentlyUsedIngredients),
|
||||
),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
@@ -320,8 +320,8 @@ class IngredientLogForm extends StatelessWidget {
|
||||
),
|
||||
if (diaryEntries.isNotEmpty) const SizedBox(height: 10.0),
|
||||
Container(
|
||||
child: Text(AppLocalizations.of(context).recentlyUsedIngredients),
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Text(AppLocalizations.of(context).recentlyUsedIngredients),
|
||||
),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
@@ -394,22 +394,30 @@ class PlanForm extends StatelessWidget {
|
||||
try {
|
||||
if (_plan.id != null) {
|
||||
await Provider.of<NutritionPlansProvider>(context, listen: false).editPlan(_plan);
|
||||
Navigator.of(context).pop();
|
||||
if (context.mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
} else {
|
||||
_plan = await Provider.of<NutritionPlansProvider>(context, listen: false)
|
||||
.addPlan(_plan);
|
||||
Navigator.of(context).pushReplacementNamed(
|
||||
NutritionalPlanScreen.routeName,
|
||||
arguments: _plan,
|
||||
);
|
||||
if (context.mounted) {
|
||||
Navigator.of(context).pushReplacementNamed(
|
||||
NutritionalPlanScreen.routeName,
|
||||
arguments: _plan,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Saving was successful, reset the data
|
||||
_descriptionController.clear();
|
||||
} on WgerHttpException catch (error) {
|
||||
showHttpExceptionErrorDialog(error, context);
|
||||
if (context.mounted) {
|
||||
showHttpExceptionErrorDialog(error, context);
|
||||
}
|
||||
} catch (error) {
|
||||
showErrorDialog(error, context);
|
||||
if (context.mounted) {
|
||||
showErrorDialog(error, context);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
|
||||
@@ -32,7 +32,7 @@ class NutritionalPlansList extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return RefreshIndicator(
|
||||
onRefresh: () => _nutritionProvider.fetchAndSetAllPlansSparse(),
|
||||
child: _nutritionProvider.items.length == 0
|
||||
child: _nutritionProvider.items.isEmpty
|
||||
? TextPrompt()
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
|
||||
@@ -16,15 +16,12 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'dart:developer';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
//import 'package:flutter_barcode_scanner/flutter_barcode_scanner.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:flutter_typeahead/flutter_typeahead.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:flutter_zxing/flutter_zxing.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/helpers/consts.dart';
|
||||
import 'package:wger/helpers/platform.dart';
|
||||
@@ -32,8 +29,6 @@ import 'package:wger/helpers/ui.dart';
|
||||
import 'package:wger/providers/nutrition.dart';
|
||||
import 'package:wger/widgets/core/core.dart';
|
||||
|
||||
import 'package:flutter_zxing/flutter_zxing.dart';
|
||||
|
||||
class ScanReader extends StatelessWidget {
|
||||
String? scannedr;
|
||||
|
||||
@@ -212,10 +207,12 @@ class _IngredientTypeaheadState extends State<IngredientTypeahead> {
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
showErrorDialog(e, context);
|
||||
// Need to pop back since reader scan is a widget
|
||||
// otherwise returns null when back button is pressed
|
||||
return Navigator.pop(context);
|
||||
if (context.mounted) {
|
||||
showErrorDialog(e, context);
|
||||
// Need to pop back since reader scan is a widget
|
||||
// otherwise returns null when back button is pressed
|
||||
return Navigator.pop(context);
|
||||
}
|
||||
}
|
||||
},
|
||||
icon: const FaIcon(FontAwesomeIcons.barcode),
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/models/user/profile.dart';
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/exceptions/http_exception.dart';
|
||||
@@ -120,11 +119,17 @@ class WeightForm extends StatelessWidget {
|
||||
: await Provider.of<BodyWeightProvider>(context, listen: false)
|
||||
.editEntry(_weightEntry);
|
||||
} on WgerHttpException catch (error) {
|
||||
showHttpExceptionErrorDialog(error, context);
|
||||
if (context.mounted) {
|
||||
showHttpExceptionErrorDialog(error, context);
|
||||
}
|
||||
} catch (error) {
|
||||
showErrorDialog(error, context);
|
||||
if (context.mounted) {
|
||||
showErrorDialog(error, context);
|
||||
}
|
||||
}
|
||||
if (context.mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
@@ -224,19 +224,19 @@ class _WorkoutDayWidgetState extends State<WorkoutDayWidget> {
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
buildDefaultDragHandles: false,
|
||||
onReorder: (_oldIndex, _newIndex) async {
|
||||
int _startIndex = 0;
|
||||
if (_oldIndex < _newIndex) {
|
||||
_newIndex -= 1;
|
||||
_startIndex = _oldIndex;
|
||||
onReorder: (oldIndex, newIndex) async {
|
||||
int startIndex = 0;
|
||||
if (oldIndex < newIndex) {
|
||||
newIndex -= 1;
|
||||
startIndex = oldIndex;
|
||||
} else {
|
||||
_startIndex = _newIndex;
|
||||
startIndex = newIndex;
|
||||
}
|
||||
setState(() {
|
||||
_sets.insert(_newIndex, _sets.removeAt(_oldIndex));
|
||||
_sets.insert(newIndex, _sets.removeAt(oldIndex));
|
||||
});
|
||||
_sets = await Provider.of<WorkoutPlansProvider>(context, listen: false)
|
||||
.reorderSets(_sets, _startIndex);
|
||||
.reorderSets(_sets, startIndex);
|
||||
},
|
||||
children: [
|
||||
for (var i = 0; i < widget._day.sets.length; i++) getSetRow(widget._day.sets[i], i),
|
||||
|
||||
@@ -103,15 +103,19 @@ class WorkoutForm extends StatelessWidget {
|
||||
// Save to DB
|
||||
if (_plan.id != null) {
|
||||
await Provider.of<WorkoutPlansProvider>(context, listen: false).editWorkout(_plan);
|
||||
Navigator.of(context).pop();
|
||||
if (context.mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
} else {
|
||||
final WorkoutPlan newPlan =
|
||||
await Provider.of<WorkoutPlansProvider>(context, listen: false)
|
||||
.addWorkout(_plan);
|
||||
Navigator.of(context).pushReplacementNamed(
|
||||
WorkoutPlanScreen.routeName,
|
||||
arguments: newPlan,
|
||||
);
|
||||
if (context.mounted) {
|
||||
Navigator.of(context).pushReplacementNamed(
|
||||
WorkoutPlanScreen.routeName,
|
||||
arguments: newPlan,
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
@@ -541,7 +545,9 @@ class _SetFormWidgetState extends State<SetFormWidget> {
|
||||
widget._day.sets.add(widget._set);
|
||||
|
||||
// Close the bottom sheet
|
||||
Navigator.of(context).pop();
|
||||
if (context.mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
@@ -496,10 +496,14 @@ class _LogPageState extends State<LogPage> {
|
||||
);
|
||||
_isSaving = false;
|
||||
} on WgerHttpException catch (error) {
|
||||
showHttpExceptionErrorDialog(error, context);
|
||||
if (mounted) {
|
||||
showHttpExceptionErrorDialog(error, context);
|
||||
}
|
||||
_isSaving = false;
|
||||
} catch (error) {
|
||||
showErrorDialog(error, context);
|
||||
if (mounted) {
|
||||
showErrorDialog(error, context);
|
||||
}
|
||||
_isSaving = false;
|
||||
}
|
||||
},
|
||||
@@ -897,11 +901,17 @@ class _SessionPageState extends State<SessionPage> {
|
||||
try {
|
||||
await Provider.of<WorkoutPlansProvider>(context, listen: false)
|
||||
.addSession(_session);
|
||||
Navigator.of(context).pop();
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
} on WgerHttpException catch (error) {
|
||||
showHttpExceptionErrorDialog(error, context);
|
||||
if (mounted) {
|
||||
showHttpExceptionErrorDialog(error, context);
|
||||
}
|
||||
} catch (error) {
|
||||
showErrorDialog(error, context);
|
||||
if (mounted) {
|
||||
showErrorDialog(error, context);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
|
||||
@@ -46,6 +46,13 @@ class _WorkoutLogsState extends State<WorkoutLogs> {
|
||||
return Column(
|
||||
children: [
|
||||
ToggleButtons(
|
||||
renderBorder: false,
|
||||
onPressed: (int index) {
|
||||
if (index == 0) {
|
||||
widget._changeMode(WorkoutScreenMode.workout);
|
||||
}
|
||||
},
|
||||
isSelected: const [false, true],
|
||||
children: const <Widget>[
|
||||
Icon(
|
||||
Icons.table_chart_outlined,
|
||||
@@ -54,13 +61,6 @@ class _WorkoutLogsState extends State<WorkoutLogs> {
|
||||
Icons.show_chart,
|
||||
),
|
||||
],
|
||||
renderBorder: false,
|
||||
onPressed: (int index) {
|
||||
if (index == 0) {
|
||||
widget._changeMode(WorkoutScreenMode.workout);
|
||||
}
|
||||
},
|
||||
isSelected: const [false, true],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
|
||||
@@ -33,7 +33,7 @@ class WorkoutPlansList extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return RefreshIndicator(
|
||||
onRefresh: () => _workoutProvider.fetchAndSetAllPlansSparse(),
|
||||
child: _workoutProvider.items.length == 0
|
||||
child: _workoutProvider.items.isEmpty
|
||||
? TextPrompt()
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
|
||||
Reference in New Issue
Block a user