From 1753ea0de05a1ea5dc1ea213006095e18cbdcce5 Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 15 Feb 2023 10:41:48 +0100 Subject: [PATCH] Allow user to add contact by scanning their QR code (with a fake QR code reader) (#15076) * Allow user to add contact by scanning their QR code * Newline * Small fix * Fix --- src/status_im2/contexts/add_new_contact/events.cljs | 8 ++++++++ src/status_im2/contexts/add_new_contact/views.cljs | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/status_im2/contexts/add_new_contact/events.cljs b/src/status_im2/contexts/add_new_contact/events.cljs index f664eb36fc..b876dca79c 100644 --- a/src/status_im2/contexts/add_new_contact/events.cljs +++ b/src/status_im2/contexts/add_new_contact/events.cljs @@ -6,6 +6,7 @@ [status-im.ethereum.ens :as ens] [status-im.ethereum.stateofus :as stateofus] [status-im.native-module.core :as status] + [status-im2.navigation.events :as navigation] [status-im2.utils.validators :as validators] [status-im.utils.utils :as utils])) @@ -109,3 +110,10 @@ {:events [:contacts/clear-new-identity :contacts/new-chat-focus]} [{:keys [db]}] {:db (dissoc db :contacts/new-identity)}) + +(rf/defn qr-code-scanned + {:events [:contacts/qr-code-scanned]} + [{:keys [db] :as cofx} input] + (rf/merge cofx + (set-new-identity input) + (navigation/navigate-back))) diff --git a/src/status_im2/contexts/add_new_contact/views.cljs b/src/status_im2/contexts/add_new_contact/views.cljs index fa8e53ee02..ddcd2ce5e8 100644 --- a/src/status_im2/contexts/add_new_contact/views.cljs +++ b/src/status_im2/contexts/add_new_contact/views.cljs @@ -2,6 +2,7 @@ (:require [quo2.core :as quo] [react-native.core :as rn] [status-im.react-native.resources :as resources] + [status-im.qr-scanner.core :as qr-scanner] [status-im2.contexts.add-new-contact.style :as style] [utils.debounce :as debounce] [utils.i18n :as i18n] @@ -42,7 +43,8 @@ 600)})] [quo/button (merge style/button-qr - {:on-press #(js/alert "TODO: to be implemented")}) + {:on-press #(rf/dispatch [::qr-scanner/scan-code + {:handler :contacts/qr-code-scanned}])}) :i/scan]] (when error? [rn/view style/container-error