Skip to content

Commit

Permalink
fix: Navigate to add basic details page from the full edit mode and i…
Browse files Browse the repository at this point in the history
…n product addition screen (#1811)
  • Loading branch information
bhattabhi013 authored May 11, 2022
1 parent c43ad92 commit 3894610
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class _AddBasicDetailsPageState extends State<AddBasicDetailsPage> {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(
appLocalizations.basic_details_add_success)));
Navigator.pop(context);
Navigator.pop(context, true);
}),
],
),
Expand Down
54 changes: 53 additions & 1 deletion packages/smooth_app/lib/pages/product/add_new_product_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:smooth_app/generic_lib/buttons/smooth_action_button.dart';
import 'package:smooth_app/generic_lib/buttons/smooth_large_button_with_icon.dart';
import 'package:smooth_app/generic_lib/design_constants.dart';
import 'package:smooth_app/pages/image_crop_page.dart';
import 'package:smooth_app/pages/product/add_basic_details_page.dart';
import 'package:smooth_app/pages/product/confirm_and_upload_picture.dart';
import 'package:smooth_app/pages/product/nutrition_page_loaded.dart';
import 'package:smooth_app/pages/product/ordered_nutrients_cache.dart';
Expand Down Expand Up @@ -39,6 +40,7 @@ class _AddNewProductPageState extends State<AddNewProductPage> {
<ImageField, List<File>>{};

bool _nutritionFactsAdded = false;
bool _basicDetailsAdded = false;
bool _isProductLoaded = false;

@override
Expand Down Expand Up @@ -74,12 +76,13 @@ class _AddNewProductPageState extends State<AddNewProductPage> {
),
..._buildImageCaptureRows(context),
_buildNutritionInputButton(),
_buildaddInputDetailsButton()
],
),
),
Positioned(
child: Align(
alignment: Alignment.bottomRight,
alignment: Alignment.topRight,
child: SmoothActionButton(
text: appLocalizations.finish,
onPressed: () {
Expand Down Expand Up @@ -274,4 +277,53 @@ class _AddNewProductPageState extends State<AddNewProductPage> {
),
);
}

Widget _buildaddInputDetailsButton() {
if (_basicDetailsAdded) {
return Padding(
padding: _ROW_PADDING_TOP,
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
const SizedBox(
width: 50.0,
child: Icon(
Icons.check,
color: Colors.greenAccent,
),
),
Expanded(
child: Center(
child: Text(
AppLocalizations.of(context)!.basic_details_add_success,
style: Theme.of(context).textTheme.bodyText1),
),
),
],
));
}

return Padding(
padding: _ROW_PADDING_TOP,
child: SmoothLargeButtonWithIcon(
text: AppLocalizations.of(context)!.completed_basic_details_btn_text,
icon: Icons.edit,
onPressed: () async {
final bool result = await Navigator.push<bool>(
context,
MaterialPageRoute<bool>(
builder: (BuildContext context) => AddBasicDetailsPage(
Product(barcode: widget.barcode),
),
),
) ??
false;
setState(() {
_basicDetailsAdded = result;
});
},
),
);
}
}
10 changes: 10 additions & 0 deletions packages/smooth_app/lib/pages/product/edit_product_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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/add_basic_details_page.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';
Expand Down Expand Up @@ -52,6 +53,15 @@ class _EditProductPageState extends State<EditProductPage> {
title: appLocalizations.edit_product_form_item_details_title,
subtitle:
appLocalizations.edit_product_form_item_details_subtitle,
onTap: () async {
await Navigator.push<bool>(
context,
MaterialPageRoute<bool>(
builder: (BuildContext context) =>
AddBasicDetailsPage(widget.product),
),
);
},
),
_ListTitleItem(
title: appLocalizations.edit_product_form_item_photos_title,
Expand Down

0 comments on commit 3894610

Please sign in to comment.