Skip to content

Commit

Permalink
feat: openfoodfacts#2501 - added "origins" in edit product page
Browse files Browse the repository at this point in the history
Impacted files:
* `app_en.arb`: added 2 labels for "origins"
* `app_fr.arb`: added 2 labels for "origins"
* `edit_product_page.dart`: added an item for "origins"
* `product_query.dart`: added field "origins" to the list of the product fields we retrieve
* `pubspec.lock`: wtf
* `pubspec.yaml`: upgraded to `openfoodfacts: ^1.22.0`, which has new product field "origins"
* `simple_input_page_helpers.dart`: implementation for "origins" of a simple input page item
  • Loading branch information
monsieurtanuki committed Jul 11, 2022
1 parent b16d6d6 commit 8e9881b
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 2 deletions.
8 changes: 8 additions & 0 deletions packages/smooth_app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,14 @@
"@edit_product_form_item_stores_hint": {
"description": "Product edition - Stores - input textfield hint"
},
"edit_product_form_item_origins_title": "Origins",
"@edit_product_form_item_origins_title": {
"description": "Product edition - Origins - Title"
},
"edit_product_form_item_origins_hint": "Spain",
"@edit_product_form_item_origins_hint": {
"description": "Product edition - Origins - input textfield hint"
},
"edit_product_form_item_countries_title": "Country",
"@edit_product_form_item_countries_title": {
"description": "Product edition - Countries - Title"
Expand Down
8 changes: 8 additions & 0 deletions packages/smooth_app/lib/l10n/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,14 @@
"@edit_product_form_item_stores_hint": {
"description": "Product edition - Stores - input textfield hint"
},
"edit_product_form_item_origins_title": "Origines",
"@edit_product_form_item_origins_title": {
"description": "Product edition - Origins - Title"
},
"edit_product_form_item_origins_hint": "Espagne",
"@edit_product_form_item_origins_hint": {
"description": "Product edition - Origins - input textfield hint"
},
"edit_product_form_item_countries_title": "Pays",
"@edit_product_form_item_countries_title": {
"description": "Product edition - Countries - Title"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ class _EditProductPageState extends State<EditProductPage> {
},
),
_getSimpleListTileItem(SimpleInputPageStoreHelper()),
_getSimpleListTileItem(SimpleInputPageOriginHelper()),
_getSimpleListTileItem(SimpleInputPageEmbCodeHelper()),
_getSimpleListTileItem(SimpleInputPageCountryHelper()),
_getSimpleListTileItem(SimpleInputPageCategoryHelper()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,27 @@ class SimpleInputPageStoreHelper extends AbstractSimpleInputPageHelper {
Widget? getIcon() => const Icon(Icons.shopping_cart);
}

/// Implementation for "Origins" of an [AbstractSimpleInputPageHelper].
class SimpleInputPageOriginHelper extends AbstractSimpleInputPageHelper {
@override
List<String> initTerms() => splitString(product.origins);

@override
void changeProduct(final Product changedProduct) =>
changedProduct.origins = terms.join(_separator);

@override
String getTitle(final AppLocalizations appLocalizations) =>
appLocalizations.edit_product_form_item_origins_title;

@override
String getAddHint(final AppLocalizations appLocalizations) =>
appLocalizations.edit_product_form_item_origins_hint;

@override
TagType? getTagType() => null;
}

/// Implementation for "Emb Code" of an [AbstractSimpleInputPageHelper].
class SimpleInputPageEmbCodeHelper extends AbstractSimpleInputPageHelper {
@override
Expand Down
1 change: 1 addition & 0 deletions packages/smooth_app/lib/query/product_query.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,6 @@ abstract class ProductQuery {
ProductField.COUNTRIES_TAGS,
ProductField.COUNTRIES_TAGS_IN_LANGUAGES,
ProductField.EMB_CODES,
ProductField.ORIGINS,
];
}
2 changes: 1 addition & 1 deletion packages/smooth_app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ packages:
name: openfoodfacts
url: "https://pub.dartlang.org"
source: hosted
version: "1.21.0"
version: "1.22.0"
openfoodfacts_flutter_lints:
dependency: "direct dev"
description:
Expand Down
2 changes: 1 addition & 1 deletion packages/smooth_app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dependencies:
url: 'https://github.com/M123-dev/matomo-tracker.git'
ref: 'fix-event-sending'
modal_bottom_sheet: ^2.1.0
openfoodfacts: ^1.21.0
openfoodfacts: ^1.22.0
# openfoodfacts:
# path: ../../../openfoodfacts-dart
package_info_plus: ^1.4.2
Expand Down

0 comments on commit 8e9881b

Please sign in to comment.