Skip to content

Commit cb4bce7

Browse files
committed
Show ingredient images
1 parent a3a0475 commit cb4bce7

30 files changed

+1047
-550
lines changed

lib/models/body_weight/weight_entry.g.dart

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/models/exercises/category.g.dart

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/models/exercises/exercise.g.dart

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/models/exercises/image.g.dart

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/models/measurements/measurement_category.g.dart

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/models/measurements/measurement_entry.g.dart

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/models/nutrition/image.dart

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* This file is part of wger Workout Manager <https://github.com/wger-project>.
3+
* Copyright (C) 2020, 2021 wger Team
4+
*
5+
* wger Workout Manager is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Affero General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Affero General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Affero General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
import 'package:json_annotation/json_annotation.dart';
19+
20+
part 'image.g.dart';
21+
22+
@JsonSerializable()
23+
class IngredientImage {
24+
@JsonKey(required: true)
25+
final int id;
26+
27+
/// Barcode of the product
28+
@JsonKey(required: true)
29+
final String uuid;
30+
31+
/// Name of the product
32+
@JsonKey(required: true, name: 'ingredient_id')
33+
final String ingredientId;
34+
35+
@JsonKey(required: true)
36+
final String image;
37+
38+
/// Size in bytes
39+
@JsonKey(required: true)
40+
final int size;
41+
42+
const IngredientImage(
43+
{required this.id,
44+
required this.uuid,
45+
required this.ingredientId,
46+
required this.image,
47+
required this.size});
48+
49+
// Boilerplate
50+
factory IngredientImage.fromJson(Map<String, dynamic> json) => _$IngredientImageFromJson(json);
51+
Map<String, dynamic> toJson() => _$IngredientImageToJson(this);
52+
}

lib/models/nutrition/ingredient.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818
import 'package:json_annotation/json_annotation.dart';
1919
import 'package:wger/helpers/json.dart';
20+
import 'package:wger/models/nutrition/image.dart';
2021

2122
part 'ingredient.g.dart';
2223

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

71-
const Ingredient({
72+
IngredientImage? image;
73+
74+
Ingredient({
7275
required this.id,
7376
required this.code,
7477
required this.name,
@@ -81,6 +84,7 @@ class Ingredient {
8184
required this.fatSaturated,
8285
required this.fibres,
8386
required this.sodium,
87+
this.image,
8488
});
8589

8690
// Boilerplate

lib/models/nutrition/ingredient.g.dart

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/models/nutrition/ingredient_weight_unit.g.dart

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)