From 31f41e2d04ccbd8c339eb8efbd08584a4487c0c8 Mon Sep 17 00:00:00 2001 From: kwingram25 Date: Wed, 25 Apr 2018 21:37:32 -0700 Subject: [PATCH] ui: new event fx for sign later in chat --- .../ui/screens/wallet/send/events.cljs | 15 ++++++++++++--- .../ui/screens/wallet/send/views.cljs | 2 +- src/status_im/utils/utils.cljs | 18 ++++++++++++++---- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/status_im/ui/screens/wallet/send/events.cljs b/src/status_im/ui/screens/wallet/send/events.cljs index f568cfe3f9..ad2adb2f3f 100644 --- a/src/status_im/ui/screens/wallet/send/events.cljs +++ b/src/status_im/ui/screens/wallet/send/events.cljs @@ -40,8 +40,12 @@ (re-frame/reg-fx ::show-transaction-moved - (fn [] - (utils/show-popup (i18n/label :t/transaction-moved-title) (i18n/label :t/transaction-moved-text)))) + (fn [modal?] + (utils/show-popup + (i18n/label :t/transaction-moved-title) + (i18n/label :t/transaction-moved-text) + (when modal? + #(re-frame/dispatch [:navigate-back]))))) (re-frame/reg-fx ::show-transaction-error @@ -93,6 +97,11 @@ (doseq [result results] (dispatch-transaction-completed result)))) +(handlers/register-handler-fx + :sign-later-from-chat + (fn [_ _] + {::show-transaction-moved true})) + ;;TRANSACTION QUEUED signal from status-go (handlers/register-handler-fx :sign-request-queued @@ -140,7 +149,7 @@ ;;SIGN LATER {:db (assoc-in new-db' [:wallet :send-transaction :waiting-signal?] false) :dispatch [:navigate-back] - ::show-transaction-moved nil} + ::show-transaction-moved false} ;;SIGN NOW {:db new-db' ::accept-transaction {:id id diff --git a/src/status_im/ui/screens/wallet/send/views.cljs b/src/status_im/ui/screens/wallet/send/views.cljs index 884923c2c7..abd8959ecc 100644 --- a/src/status_im/ui/screens/wallet/send/views.cljs +++ b/src/status_im/ui/screens/wallet/send/views.cljs @@ -29,7 +29,7 @@ (i18n/label :t/sign-later-title) (i18n/label :t/sign-later-text) #(re-frame/dispatch (if from-chat? - [:navigate-back] + [:sign-later-from-chat] [:wallet/sign-transaction true])))) (defview sign-panel [message?] diff --git a/src/status_im/utils/utils.cljs b/src/status_im/utils/utils.cljs index 103e249cd0..4b099fce3f 100644 --- a/src/status_im/utils/utils.cljs +++ b/src/status_im/utils/utils.cljs @@ -2,10 +2,20 @@ (:require [status-im.i18n :as i18n] [status-im.react-native.js-dependencies :as rn-dependencies])) -(defn show-popup [title content] - (.alert (.-Alert rn-dependencies/react-native) - title - content)) +(defn show-popup + ([title content] + (show-popup title content nil)) + ([title content on-dismiss] + (.alert (.-Alert rn-dependencies/react-native) + title + content + (clj->js + (vector (merge {:text "OK" + :style "cancel" + :accessibility-label :cancel-button} + (when on-dismiss {:onPress on-dismiss})))) + (when on-dismiss + (clj->js {:cancelable false}))))) (defn show-confirmation ([title content on-accept]