diff --git a/packages/smooth_app/lib/pages/product/edit_ingredients_page.dart b/packages/smooth_app/lib/pages/product/edit_ingredients_page.dart index 21b3df3991a..f51b5035a73 100644 --- a/packages/smooth_app/lib/pages/product/edit_ingredients_page.dart +++ b/packages/smooth_app/lib/pages/product/edit_ingredients_page.dart @@ -43,14 +43,12 @@ class _EditIngredientsPageState extends State { } Future _onSubmitField() async { - final User user = ProductQuery.getUser(); - setState(() { _updatingIngredients = true; }); try { - await _updateIngredientsText(_controller.text, user); + await _updateIngredientsText(_controller.text); } catch (error) { final AppLocalizations appLocalizations = AppLocalizations.of(context)!; _showError(appLocalizations.ingredients_editing_error); @@ -144,7 +142,7 @@ class _EditIngredientsPageState extends State { } } - Future _updateIngredientsText(String ingredientsText, User user) async { + Future _updateIngredientsText(String ingredientsText) async { widget.product.ingredientsText = ingredientsText; final LocalDatabase localDatabase = context.read(); final bool savedAndRefreshed = await ProductRefresher().saveAndRefresh( diff --git a/packages/smooth_app/lib/pages/product/edit_product_page.dart b/packages/smooth_app/lib/pages/product/edit_product_page.dart index 3ed49ab438f..cd51c5d6d1d 100644 --- a/packages/smooth_app/lib/pages/product/edit_product_page.dart +++ b/packages/smooth_app/lib/pages/product/edit_product_page.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:openfoodfacts/model/Product.dart'; import 'package:smooth_app/helpers/product_cards_helper.dart'; +import 'package:smooth_app/pages/product/edit_ingredients_page.dart'; import 'package:smooth_app/pages/product/nutrition_page_loaded.dart'; import 'package:smooth_app/pages/product/ordered_nutrients_cache.dart'; @@ -62,6 +63,19 @@ class _EditProductPageState extends State { ), _ListTitleItem( title: appLocalizations.edit_product_form_item_ingredients_title, + onTap: () async { + final bool? refreshed = await Navigator.push( + context, + MaterialPageRoute( + builder: (BuildContext context) => EditIngredientsPage( + product: widget.product, + ), + ), + ); + if (refreshed ?? false) { + _changes++; + } + }, ), _ListTitleItem( title: appLocalizations.edit_product_form_item_packaging_title, diff --git a/packages/smooth_app/lib/pages/product/new_product_page.dart b/packages/smooth_app/lib/pages/product/new_product_page.dart index 79f7c2d6b52..320edc0573d 100644 --- a/packages/smooth_app/lib/pages/product/new_product_page.dart +++ b/packages/smooth_app/lib/pages/product/new_product_page.dart @@ -305,8 +305,8 @@ class _ProductPageState extends State { EditProductPage(_product), ), ); - if (refreshed ?? false) { - setState(() {}); + if (refreshed == true) { + await _refreshProduct(context); } }, ),