Skip to content

Commit ef24017

Browse files
committed
Removed hardcoded strings for ImageField
1 parent c4be499 commit ef24017

File tree

2 files changed

+7
-23
lines changed

2 files changed

+7
-23
lines changed

packages/smooth_app/lib/helpers/image_field_extension.dart

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,4 @@ extension ImageFieldSmoothieExtension on ImageField {
139139
ImageField.PACKAGING => product.imagePackagingUrl,
140140
ImageField.OTHER => null,
141141
};
142-
143-
String? getFieldId() => switch (this) {
144-
ImageField.FRONT => null,
145-
ImageField.INGREDIENTS => 'ingredients',
146-
ImageField.NUTRITION => 'nutrition_facts_table',
147-
ImageField.PACKAGING => 'environmental_score_packaging',
148-
ImageField.OTHER => null,
149-
};
150142
}

packages/smooth_app/lib/pages/product/product_image_swipeable_view.dart

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -135,26 +135,18 @@ class _ProductImageSwipeableViewState extends State<ProductImageSwipeableView>
135135
}
136136

137137
Widget _editButton(ImageField imageField) {
138-
final String? fieldId = imageField.getFieldId();
139-
140-
if (fieldId == null) {
141-
return EMPTY_WIDGET;
142-
}
143-
144138
const Icon icon = Icon(Icons.edit_note);
145-
146-
if (fieldId == 'ingredients') {
139+
140+
if (imageField == ImageField.INGREDIENTS) {
147141
return IconButton(
148142
icon: icon,
149143
onPressed: () async {
150-
await ProductFieldOcrIngredientEditor().edit(
151-
context: context,
152-
product: upToDateProduct
153-
);
144+
await ProductFieldOcrIngredientEditor()
145+
.edit(context: context, product: upToDateProduct);
154146
},
155147
);
156148
}
157-
if (fieldId == 'nutrition_facts_table') {
149+
if (imageField == ImageField.NUTRITION) {
158150
return IconButton(
159151
icon: icon,
160152
onPressed: () async {
@@ -166,7 +158,7 @@ class _ProductImageSwipeableViewState extends State<ProductImageSwipeableView>
166158
},
167159
);
168160
}
169-
if (fieldId == 'environmental_score_packaging') {
161+
if (imageField == ImageField.PACKAGING) {
170162
return IconButton(
171163
icon: icon,
172164
onPressed: () async {
@@ -180,7 +172,7 @@ class _ProductImageSwipeableViewState extends State<ProductImageSwipeableView>
180172

181173
return EMPTY_WIDGET;
182174
}
183-
175+
184176
Widget _lockedIcon(ImageField imageField) {
185177
if (widget.product.isImageLocked(imageField, _currentLanguage) != true) {
186178
return EMPTY_WIDGET;

0 commit comments

Comments
 (0)