Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Navigate to add basic details page #1811

Merged
merged 1 commit into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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