Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions integration_test/5_nutritional_plan.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import 'package:wger/providers/nutrition.dart';
import 'package:wger/screens/nutritional_plan_screen.dart';
import 'package:wger/theme/theme.dart';

import '../test/other/base_provider_test.mocks.dart';
import '../test/utils.dart';
import '../test/user/provider_test.mocks.dart';

Widget createNutritionalPlanScreen({locale = 'en'}) {
var mockBaseProvider = MockWgerBaseProvider();

final key = GlobalKey<NavigatorState>();
final client = MockClient();

final muesli = Ingredient(
id: 1,
Expand Down Expand Up @@ -96,7 +96,7 @@ Widget createNutritionalPlanScreen({locale = 'en'}) {
return MultiProvider(
providers: [
ChangeNotifierProvider<NutritionPlansProvider>(
create: (context) => NutritionPlansProvider(testAuthProvider, [], client),
create: (context) => NutritionPlansProvider(mockBaseProvider, []),
),
ChangeNotifierProvider<BodyWeightProvider>(
create: (context) => BodyWeightProvider(mockBaseProvider),
Expand Down
9 changes: 6 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,12 @@ class MyApp extends StatelessWidget {
previous ?? WorkoutPlansProvider(WgerBaseProvider(auth), exercises, []),
),
ChangeNotifierProxyProvider<AuthProvider, NutritionPlansProvider>(
create: (context) =>
NutritionPlansProvider(Provider.of<AuthProvider>(context, listen: false), []),
update: (context, auth, previous) => previous ?? NutritionPlansProvider(auth, []),
create: (context) => NutritionPlansProvider(
WgerBaseProvider(Provider.of<AuthProvider>(context, listen: false)),
[],
),
update: (context, auth, previous) =>
previous ?? NutritionPlansProvider(WgerBaseProvider(auth), []),
),
ChangeNotifierProxyProvider<AuthProvider, MeasurementProvider>(
create: (context) => MeasurementProvider(
Expand Down
52 changes: 52 additions & 0 deletions lib/models/nutrition/image.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* This file is part of wger Workout Manager <https://github.com/wger-project>.
* 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.
*
* This program 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 <http://www.gnu.org/licenses/>.
*/
import 'package:json_annotation/json_annotation.dart';

part 'image.g.dart';

@JsonSerializable()
class IngredientImage {
@JsonKey(required: true)
final int id;

/// Barcode of the product
@JsonKey(required: true)
final String uuid;

/// Name of the product
@JsonKey(required: true, name: 'ingredient_id')
final String ingredientId;

@JsonKey(required: true)
final String image;

/// Size in bytes
@JsonKey(required: true)
final int size;

const IngredientImage(
{required this.id,
required this.uuid,
required this.ingredientId,
required this.image,
required this.size});

// Boilerplate
factory IngredientImage.fromJson(Map<String, dynamic> json) => _$IngredientImageFromJson(json);
Map<String, dynamic> toJson() => _$IngredientImageToJson(this);
}
29 changes: 29 additions & 0 deletions lib/models/nutrition/image.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion lib/models/nutrition/ingredient.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
import 'package:json_annotation/json_annotation.dart';
import 'package:wger/helpers/json.dart';
import 'package:wger/models/nutrition/image.dart';

part 'ingredient.g.dart';

Expand Down Expand Up @@ -68,7 +69,9 @@ class Ingredient {
@JsonKey(required: true, fromJson: stringToNum, toJson: numToString)
final num sodium;

const Ingredient({
IngredientImage? image;

Ingredient({
required this.id,
required this.code,
required this.name,
Expand All @@ -81,6 +84,7 @@ class Ingredient {
required this.fatSaturated,
required this.fibres,
required this.sodium,
this.image,
});

// Boilerplate
Expand Down
4 changes: 4 additions & 0 deletions lib/models/nutrition/ingredient.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion lib/providers/measurement.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class MeasurementProvider with ChangeNotifier {
List<MeasurementCategory> _categories = [];

MeasurementProvider(this.baseProvider);
//: super(auth, client);

List<MeasurementCategory> get categories => _categories;

Expand Down
Loading