-
-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 3897 - mutilingual gallery and swipeable images - read only (#3917
) New file: * `image_field_extension.dart`: moved code from `product_cards_helper.dart` Deleted files: * `product_image_unswipeable_view.dart` * `smooth_images_sliver_list.dart` * `smooth_images_view.dart` Impacted files: * `image_upload_card.dart`: minor refactoring * `language_selector.dart`: added an optional foreground color (use case: explicit white for images on a black background) * `new_crop_page.dart`: minor refactoring * `nutrition_page_loaded.dart: now using a new special case constructor of `ProductImageSwipeableView` instead of now deleted `ProductImageUnswipeableView` * `product_cards_helper.dart`: added language-related methods; refactored * `product_image_carousel.dart`: minor refactoring * `product_image_data.dart`: added language * `product_image_gallery_view.dart`: simplified the display of the 4 images; added the language selector on top; refactored the title * `product_image_swipeable_view.dart`: now handles the "mono imagefield" case; now manages languages; minor refactoring * `product_image_viewer.dart`: added the language selector; removed the irrelevant `Scaffold`
- Loading branch information
1 parent
9ed1cdc
commit 558034f
Showing
14 changed files
with
373 additions
and
371 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 0 additions & 54 deletions
54
packages/smooth_app/lib/generic_lib/widgets/images/smooth_images_sliver_list.dart
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
packages/smooth_app/lib/generic_lib/widgets/images/smooth_images_view.dart
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
packages/smooth_app/lib/helpers/image_field_extension.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; | ||
import 'package:openfoodfacts/openfoodfacts.dart'; | ||
|
||
extension ImageFieldSmoothieExtension on ImageField { | ||
static const List<ImageField> orderedMain = <ImageField>[ | ||
ImageField.FRONT, | ||
ImageField.INGREDIENTS, | ||
ImageField.NUTRITION, | ||
ImageField.PACKAGING, | ||
]; | ||
|
||
String? getImageFieldUrl(final Product product) { | ||
switch (this) { | ||
case ImageField.FRONT: | ||
return product.imageFrontUrl; | ||
case ImageField.INGREDIENTS: | ||
return product.imageIngredientsUrl; | ||
case ImageField.NUTRITION: | ||
return product.imageNutritionUrl; | ||
case ImageField.PACKAGING: | ||
return product.imagePackagingUrl; | ||
case ImageField.OTHER: | ||
return null; | ||
} | ||
} | ||
|
||
String getProductImageButtonText(final AppLocalizations appLocalizations) { | ||
switch (this) { | ||
case ImageField.FRONT: | ||
return appLocalizations.front_photo; | ||
case ImageField.INGREDIENTS: | ||
return appLocalizations.ingredients_photo; | ||
case ImageField.NUTRITION: | ||
return appLocalizations.nutrition_facts_photo; | ||
case ImageField.PACKAGING: | ||
return appLocalizations.packaging_information_photo; | ||
case ImageField.OTHER: | ||
return appLocalizations.more_photos; | ||
} | ||
} | ||
|
||
/// Returns a verbose description of the image field. | ||
String getImagePageTitle(final AppLocalizations appLocalizations) { | ||
switch (this) { | ||
case ImageField.FRONT: | ||
return appLocalizations.front_packaging_photo_title; | ||
case ImageField.INGREDIENTS: | ||
return appLocalizations.ingredients_photo_title; | ||
case ImageField.NUTRITION: | ||
return appLocalizations.nutritional_facts_photo_title; | ||
case ImageField.PACKAGING: | ||
return appLocalizations.recycling_photo_title; | ||
case ImageField.OTHER: | ||
return appLocalizations.other_interesting_photo_title; | ||
} | ||
} | ||
|
||
/// Returns a compact description of the image field. | ||
String getProductImageTitle(final AppLocalizations appLocalizations) { | ||
switch (this) { | ||
case ImageField.FRONT: | ||
return appLocalizations.product; | ||
case ImageField.INGREDIENTS: | ||
return appLocalizations.ingredients; | ||
case ImageField.NUTRITION: | ||
return appLocalizations.nutrition; | ||
case ImageField.PACKAGING: | ||
return appLocalizations.packaging_information; | ||
case ImageField.OTHER: | ||
return appLocalizations.more_photos; | ||
} | ||
} | ||
} |
Oops, something went wrong.