mirror of
https://github.com/status-im/status-mobile.git
synced 2025-02-10 15:46:35 +00:00
[ISSUE # 2233] Fixed crash when showing QR code
This commit is contained in:
parent
4c4cf7a5e4
commit
0273043265
@ -2,8 +2,9 @@
|
|||||||
(:require [status-im.ui.screens.navigation :as navigation]))
|
(:require [status-im.ui.screens.navigation :as navigation]))
|
||||||
|
|
||||||
(defmethod navigation/preload-data! :qr-code-view
|
(defmethod navigation/preload-data! :qr-code-view
|
||||||
[{:accounts/keys [current-account-id] :as db} [_ _ {:keys [contact qr-source amount?]}]]
|
[{:accounts/keys [current-account-id] :as db} [_ _ {:keys [contact qr-source qr-value amount?]}]]
|
||||||
(assoc db :qr-modal {:contact (or contact
|
(assoc db :qr-modal {:contact (or contact
|
||||||
(get-in db [:accounts/accounts current-account-id]))
|
(get-in db [:accounts/accounts current-account-id]))
|
||||||
:qr-source qr-source
|
:qr-source qr-source
|
||||||
|
:qr-value qr-value
|
||||||
:amount? amount?}))
|
:amount? amount?}))
|
||||||
|
@ -11,8 +11,8 @@
|
|||||||
(:require-macros [status-im.utils.views :refer [defview letsubs]]))
|
(:require-macros [status-im.utils.views :refer [defview letsubs]]))
|
||||||
|
|
||||||
(defview qr-code-view []
|
(defview qr-code-view []
|
||||||
(letsubs [{:keys [photo-path address name] :as contact} [:get-in [:qr-modal :contact]]
|
(letsubs [{:keys [photo-path address name]} [:get-in [:qr-modal :contact]]
|
||||||
{:keys [qr-source amount? dimensions]} [:get :qr-modal]
|
{:keys [qr-source qr-value amount? dimensions]} [:get :qr-modal]
|
||||||
{:keys [amount]} [:get :contacts/click-params]]
|
{:keys [amount]} [:get :contacts/click-params]]
|
||||||
[react/view styles/wallet-qr-code
|
[react/view styles/wallet-qr-code
|
||||||
[status-bar {:type :modal}]
|
[status-bar {:type :modal}]
|
||||||
@ -35,15 +35,18 @@
|
|||||||
:height (.-height layout)}]))}
|
:height (.-height layout)}]))}
|
||||||
(when (:width dimensions)
|
(when (:width dimensions)
|
||||||
[react/view {:style (styles/qr-code-container dimensions)}
|
[react/view {:style (styles/qr-code-container dimensions)}
|
||||||
[qr-code {:value (eip67/generate-uri (get contact qr-source) (when amount? {:value amount}))
|
(when-let [value (eip67/generate-uri qr-value (when amount? {:value amount}))]
|
||||||
:size (- (min (:width dimensions)
|
[qr-code {:value value
|
||||||
(:height dimensions))
|
:size (- (min (:width dimensions)
|
||||||
80)}]])]
|
(:height dimensions))
|
||||||
|
80)}])])]
|
||||||
[react/view styles/footer
|
[react/view styles/footer
|
||||||
[react/view styles/wallet-info
|
(if (= :address qr-source)
|
||||||
[react/text {:style styles/wallet-name-text} (label :t/main-wallet)]
|
[react/view styles/wallet-info
|
||||||
[react/text {:style styles/wallet-address-text} address]]
|
[react/text {:style styles/wallet-name-text} (label :t/main-wallet)]
|
||||||
|
[react/text {:style styles/wallet-address-text} address]]
|
||||||
|
[react/view styles/wallet-info
|
||||||
|
[react/text {:style styles/wallet-name-text} (label :t/public-key)]])
|
||||||
[react/touchable-highlight {:onPress #(dispatch [:navigate-back])}
|
[react/touchable-highlight {:onPress #(dispatch [:navigate-back])}
|
||||||
[react/view styles/done-button
|
[react/view styles/done-button
|
||||||
[react/text {:style styles/done-button-text} (label :t/done)]]]]]))
|
[react/text {:style styles/done-button-text} (label :t/done)]]]]]))
|
||||||
|
@ -96,13 +96,14 @@
|
|||||||
nil
|
nil
|
||||||
styles/profile-info-item-button])])
|
styles/profile-info-item-button])])
|
||||||
|
|
||||||
(defn show-qr [contact qr-source]
|
(defn show-qr [contact qr-source qr-value]
|
||||||
#(dispatch [:navigate-to-modal :qr-code-view {:contact contact
|
#(dispatch [:navigate-to-modal :qr-code-view {:contact contact
|
||||||
:qr-source qr-source}]))
|
:qr-source qr-source
|
||||||
|
:qr-value qr-value}]))
|
||||||
|
|
||||||
(defn profile-options [contact k text]
|
(defn profile-options [contact k text]
|
||||||
(into []
|
(into []
|
||||||
(concat [{:value (show-qr contact k)
|
(concat [{:value (show-qr contact k text)
|
||||||
:text (label :t/show-qr)}]
|
:text (label :t/show-qr)}]
|
||||||
(when text
|
(when text
|
||||||
(share-options text)))))
|
(share-options text)))))
|
||||||
@ -199,7 +200,7 @@
|
|||||||
[common/separator]])
|
[common/separator]])
|
||||||
|
|
||||||
(defview my-profile []
|
(defview my-profile []
|
||||||
(letsubs [{:keys [status] :as current-account} [:get-current-account]]
|
(letsubs [{:keys [status public-key] :as current-account} [:get-current-account]]
|
||||||
[react/view styles/profile
|
[react/view styles/profile
|
||||||
[status-bar]
|
[status-bar]
|
||||||
[my-profile-toolbar]
|
[my-profile-toolbar]
|
||||||
@ -213,7 +214,7 @@
|
|||||||
[action-button {:label (label :t/show-qr)
|
[action-button {:label (label :t/show-qr)
|
||||||
:icon :icons/qr
|
:icon :icons/qr
|
||||||
:icon-opts {:color :blue}
|
:icon-opts {:color :blue}
|
||||||
:on-press (show-qr current-account :public-key)}]]
|
:on-press (show-qr current-account :public-key public-key)}]]
|
||||||
[common/form-spacer]
|
[common/form-spacer]
|
||||||
[react/view styles/profile-info-container
|
[react/view styles/profile-info-container
|
||||||
[my-profile-info current-account]
|
[my-profile-info current-account]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user