From 902debae6fc0040c13bf444f80696b63381d1e47 Mon Sep 17 00:00:00 2001 From: BhuvanAde Date: Tue, 14 Feb 2023 00:33:08 +0530 Subject: [PATCH] feat: added dialog if users click on unselect image button #2427 Signed-off-by: BhuvanAde --- packages/smooth_app/lib/l10n/app_en.arb | 7 ++++ .../pages/product/product_image_viewer.dart | 36 ++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/packages/smooth_app/lib/l10n/app_en.arb b/packages/smooth_app/lib/l10n/app_en.arb index b84c09df716..2e12bffee80 100644 --- a/packages/smooth_app/lib/l10n/app_en.arb +++ b/packages/smooth_app/lib/l10n/app_en.arb @@ -837,6 +837,12 @@ "ask_me_later_button_label": "Later", "@ask_me_later": { "description": "Button to ignore the camera permission request" + + }, + "are_you_sure": "Are you sure?", + "@are_you_sure": { + "description": "Are you sure?" + }, "knowledge_panel_text_source": "Go further on {sourceName}", "@knowledge_panel_text_source": { @@ -969,6 +975,7 @@ "@camera_mode_title": { "description": "Title for the mode for the camera/scanner" }, + "camera_mode_subtitle": "Only change this value, if you have some issues with the scanner (unable to decode barcodes). Tap to switch between the two modes.\nThe current one is: {mode}", "@camera_mode_subtitle": { "description": "SubTitle for the mode for the camera/scanner", diff --git a/packages/smooth_app/lib/pages/product/product_image_viewer.dart b/packages/smooth_app/lib/pages/product/product_image_viewer.dart index 0eedd1b3422..50611a24f5e 100644 --- a/packages/smooth_app/lib/pages/product/product_image_viewer.dart +++ b/packages/smooth_app/lib/pages/product/product_image_viewer.dart @@ -126,7 +126,41 @@ class _ProductImageViewerState extends State { child: Padding( padding: const EdgeInsets.symmetric(horizontal: SMALL_SPACE), - child: _getUnselectImageButton(appLocalizations), + child: (imageProvider == null) + ? Container() + : EditImageButton( + iconData: Icons.do_disturb_on, + label: appLocalizations + .edit_photo_unselect_button_label, + onPressed: () async { + final bool? confirmed = await showDialog( + context: context, + builder: (BuildContext context) { + return SmoothAlertDialog( + title: + appLocalizations.confirm_button_label, + body: Text( + appLocalizations.are_you_sure, + ), + close: true, + positiveAction: SmoothActionButton( + text: appLocalizations.yes, + onPressed: () => + Navigator.of(context).pop(true)), + negativeAction: SmoothActionButton( + text: appLocalizations.no, + onPressed: () => Navigator.of(context) + .pop(false))); + }, + ); + if (confirmed == true) { + await BackgroundTaskUnselect.addTask( + _barcode, + imageField: widget.imageField, + widget: this, + ); + } + }), ), ), Expanded(