From ce124413406f7884871af9e909191d0da0399dd9 Mon Sep 17 00:00:00 2001 From: Daniel Regeci Date: Thu, 17 May 2018 21:10:32 +0700 Subject: [PATCH] [FIX #4127] Sign In button is shown when recovering account (android) --- .../ui/screens/accounts/recover/events.cljs | 13 +++++++--- .../screens/accounts/recover/navigation.cljs | 2 +- .../ui/screens/accounts/recover/styles.cljs | 11 ++++++++ .../ui/screens/accounts/recover/views.cljs | 25 +++++++++++-------- 4 files changed, 37 insertions(+), 14 deletions(-) diff --git a/src/status_im/ui/screens/accounts/recover/events.cljs b/src/status_im/ui/screens/accounts/recover/events.cljs index d9c5c5c4cb..79ee18fba9 100644 --- a/src/status_im/ui/screens/accounts/recover/events.cljs +++ b/src/status_im/ui/screens/accounts/recover/events.cljs @@ -54,9 +54,16 @@ (-> db (accounts-events/add-account account) (assoc :dispatch [:login-account address password]) - (assoc :dispatch-later [{:ms 2000 :dispatch [:navigate-to :usage-data [:account-finalized false]]}])))))) + (assoc :dispatch-later [{:ms 2000 :dispatch [:account-recovered-navigate]}])))))) + +(handlers/register-handler-fx + :account-recovered-navigate + (fn [{:keys [db]}] + {:db (assoc-in db [:accounts/recover :processing] false) + :dispatch [:navigate-to :usage-data [:account-finalized false]]})) (handlers/register-handler-fx :recover-account - (fn [_ [_ masked-passphrase password]] - {::recover-account-fx [masked-passphrase password]})) + (fn [{:keys [db]} [_ masked-passphrase password]] + {:db (assoc-in db [:accounts/recover :processing] true) + ::recover-account-fx [masked-passphrase password]})) diff --git a/src/status_im/ui/screens/accounts/recover/navigation.cljs b/src/status_im/ui/screens/accounts/recover/navigation.cljs index 6b3b368064..b3ecb2acb4 100644 --- a/src/status_im/ui/screens/accounts/recover/navigation.cljs +++ b/src/status_im/ui/screens/accounts/recover/navigation.cljs @@ -3,4 +3,4 @@ (defmethod nav/preload-data! :recover [db] - (update db :accounts/recover dissoc :password :passphrase)) \ No newline at end of file + (update db :accounts/recover dissoc :password :passphrase :processing)) \ No newline at end of file diff --git a/src/status_im/ui/screens/accounts/recover/styles.cljs b/src/status_im/ui/screens/accounts/recover/styles.cljs index e4d1c62560..5e482590c4 100644 --- a/src/status_im/ui/screens/accounts/recover/styles.cljs +++ b/src/status_im/ui/screens/accounts/recover/styles.cljs @@ -9,3 +9,14 @@ {:flex-direction :row :margin-horizontal 12 :margin-vertical 15}) + +(def processing-view + {:flex 1 + :align-items :center + :justify-content :center}) + +(def sign-you-in + {:margin-top 16 + :font-size 13 + :letter-spacing -0.2 + :color colors/text-light-gray}) diff --git a/src/status_im/ui/screens/accounts/recover/views.cljs b/src/status_im/ui/screens/accounts/recover/views.cljs index a934a07477..f56665c80f 100644 --- a/src/status_im/ui/screens/accounts/recover/views.cljs +++ b/src/status_im/ui/screens/accounts/recover/views.cljs @@ -48,7 +48,7 @@ :error error}]])) (defview recover [] - (letsubs [{:keys [passphrase password]} [:get :accounts/recover]] + (letsubs [{:keys [passphrase password processing]} [:get :accounts/recover]] (let [valid-form? (and (spec/valid? ::recover.db/passphrase passphrase) (spec/valid? ::db/password password))] @@ -61,12 +61,17 @@ [passphrase-input (or passphrase "")] [password-input (or password "")]] [react/view {:flex 1}] - [react/view {:style styles/bottom-button-container} - [react/view {:style {:flex 1}}] - [components.common/bottom-button - {:forward? true - :label (i18n/label :t/sign-in) - :disabled? (not valid-form?) - :on-press (fn [_] - (let [masked-passphrase (security/mask-data (string/trim passphrase))] - (re-frame/dispatch [:recover-account masked-passphrase password])))}]]]))) + (if processing + [react/view styles/processing-view + [react/activity-indicator {:animating true}] + [react/text {:style styles/sign-you-in} + (i18n/label :t/sign-you-in)]] + [react/view {:style styles/bottom-button-container} + [react/view {:style {:flex 1}}] + [components.common/bottom-button + {:forward? true + :label (i18n/label :t/sign-in) + :disabled? (not valid-form?) + :on-press (fn [_] + (let [masked-passphrase (security/mask-data (string/trim passphrase))] + (re-frame/dispatch [:recover-account masked-passphrase password])))}]])])))