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
This commit is contained in:
Alexander 2023-02-15 10:41:48 +01:00 committed by GitHub
parent 8ff7a1630c
commit 1753ea0de0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -6,6 +6,7 @@
[status-im.ethereum.ens :as ens] [status-im.ethereum.ens :as ens]
[status-im.ethereum.stateofus :as stateofus] [status-im.ethereum.stateofus :as stateofus]
[status-im.native-module.core :as status] [status-im.native-module.core :as status]
[status-im2.navigation.events :as navigation]
[status-im2.utils.validators :as validators] [status-im2.utils.validators :as validators]
[status-im.utils.utils :as utils])) [status-im.utils.utils :as utils]))
@ -109,3 +110,10 @@
{:events [:contacts/clear-new-identity :contacts/new-chat-focus]} {:events [:contacts/clear-new-identity :contacts/new-chat-focus]}
[{:keys [db]}] [{:keys [db]}]
{:db (dissoc db :contacts/new-identity)}) {: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)))

View File

@ -2,6 +2,7 @@
(:require [quo2.core :as quo] (:require [quo2.core :as quo]
[react-native.core :as rn] [react-native.core :as rn]
[status-im.react-native.resources :as resources] [status-im.react-native.resources :as resources]
[status-im.qr-scanner.core :as qr-scanner]
[status-im2.contexts.add-new-contact.style :as style] [status-im2.contexts.add-new-contact.style :as style]
[utils.debounce :as debounce] [utils.debounce :as debounce]
[utils.i18n :as i18n] [utils.i18n :as i18n]
@ -42,7 +43,8 @@
600)})] 600)})]
[quo/button [quo/button
(merge style/button-qr (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]] :i/scan]]
(when error? (when error?
[rn/view style/container-error [rn/view style/container-error