From a1b18f300b7f431aebc01c7ca5aa380452784f10 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Ba=C3=B1obre=20Dopico?= <bytes4life@proton.me>
Date: Tue, 15 Aug 2023 19:40:04 +0200
Subject: [PATCH] Show messages on errors reading payment QRs

---
 assets/translations/en.json                          | 2 ++
 assets/translations/gl.json                          | 4 +++-
 lib/ui/widgets/first_screen/contact_search_page.dart | 8 ++++++++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/assets/translations/en.json b/assets/translations/en.json
index cc5d4914..099fce9c 100644
--- a/assets/translations/en.json
+++ b/assets/translations/en.json
@@ -217,6 +217,8 @@
   "wallet_copied": "Walled copied to clipboard",
   "link_export": "Export to Link",
   "share_export_subject": "Äž1nkgo Wallet Export",
+  "qr_invalid_payment": "QR invalid payment information",
+  "cant_find_qr_contact": "Can't find QR provided contact",
   "qr_scanner_cancel": "CANCEL",
   "qr_scanner_flash_on": "FLASH ON",
   "qr_scanner_flash_off": "FLASH OFF",
diff --git a/assets/translations/gl.json b/assets/translations/gl.json
index 7c3d7af6..ed35fdb4 100644
--- a/assets/translations/gl.json
+++ b/assets/translations/gl.json
@@ -198,5 +198,7 @@
   "share_export_subject": "A miña carteira Ğ1nkgo",
   "share_export_button": "PARTILLAR",
   "share_export_desc": "A túa carteira exportouse localmente. ¿Queres compartila contigo mesmo por mail/chat/etc. para súa custodia?",
-  "pay_with_nfc_tooltip": "Para recibir un pago, só tes que manter este dispositivo preto da outra carteira compatible con NFC."
+  "pay_with_nfc_tooltip": "Para recibir un pago, só tes que manter este dispositivo preto da outra carteira compatible con NFC.",
+  "qr_invalid_payment": "Información de pagamento inválida no QR",
+  "cant_find_qr_contact": "Non se pode atopar o contacto proporcionado polo QR"
 }
diff --git a/lib/ui/widgets/first_screen/contact_search_page.dart b/lib/ui/widgets/first_screen/contact_search_page.dart
index f935d880..1bdb118a 100644
--- a/lib/ui/widgets/first_screen/contact_search_page.dart
+++ b/lib/ui/widgets/first_screen/contact_search_page.dart
@@ -252,6 +252,10 @@ class _ContactSearchPageState extends State<ContactSearchPage> {
       logger('Scanned $pay');
       _searchTerm = extractPublicKey(pay.contact!.pubKey);
       await _search();
+    } else {
+      ScaffoldMessenger.of(context).showSnackBar(
+        SnackBar(content: Text(tr('qr_invalid_payment')))
+      );
     }
     logger('QR result length ${_results.length}');
     if (_results.length == 1 && pay != null) {
@@ -266,6 +270,10 @@ class _ContactSearchPageState extends State<ContactSearchPage> {
       if (pay.comment != null) {
         paymentCubit.setComment(pay.comment);
       }
+    } else if (_results.isEmpty) {
+      ScaffoldMessenger.of(context).showSnackBar(
+        SnackBar(content: Text(tr('cant_find_qr_contact')))
+      );
     }
   }
 
-- 
GitLab