-
-
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: 3987 - now KP opens the new packaging page (#3989)
New file: * `add_packaging_button.dart`: "Add (new) packaging" button for user contribution. Impacted file: * `knowledge_panel_action_card.dart`: now opens the new packaging page; refactoring
- Loading branch information
1 parent
76762b1
commit 72c55f6
Showing
2 changed files
with
84 additions
and
33 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
37 changes: 37 additions & 0 deletions
37
packages/smooth_app/lib/pages/product/add_packaging_button.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,37 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; | ||
import 'package:openfoodfacts/openfoodfacts.dart'; | ||
import 'package:smooth_app/helpers/product_cards_helper.dart'; | ||
import 'package:smooth_app/pages/product/common/product_refresher.dart'; | ||
import 'package:smooth_app/pages/product/edit_new_packagings.dart'; | ||
import 'package:smooth_app/pages/product/ocr_packaging_helper.dart'; | ||
|
||
/// "Add (new) packaging" button for user contribution. | ||
class AddPackagingButton extends StatelessWidget { | ||
const AddPackagingButton({ | ||
required this.product, | ||
}); | ||
|
||
final Product product; | ||
|
||
@override | ||
Widget build(BuildContext context) => addPanelButton( | ||
OcrPackagingHelper().getAddButtonLabel(AppLocalizations.of(context)), | ||
onPressed: () async { | ||
// ignore: use_build_context_synchronously | ||
if (!await ProductRefresher().checkIfLoggedIn(context)) { | ||
return; | ||
} | ||
// ignore: use_build_context_synchronously | ||
await Navigator.push<void>( | ||
context, | ||
MaterialPageRoute<void>( | ||
builder: (BuildContext context) => EditNewPackagings( | ||
product: product, | ||
), | ||
fullscreenDialog: true, | ||
), | ||
); | ||
}, | ||
); | ||
} |