From 0f2aaa35e38f1d595b9ee7575fb79cb50d947218 Mon Sep 17 00:00:00 2001 From: Daniel Regeci Date: Fri, 4 May 2018 21:49:23 +0700 Subject: [PATCH] [FIX #3683] Advanced option does not autoscroll the screen up Signed-off-by: Julien Eluard --- .../ui/screens/profile/user/views.cljs | 8 ++++++-- src/status_im/ui/screens/wallet/send/views.cljs | 17 +++++++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/status_im/ui/screens/profile/user/views.cljs b/src/status_im/ui/screens/profile/user/views.cljs index 64f56e1bb9..87dd5ce3a1 100644 --- a/src/status_im/ui/screens/profile/user/views.cljs +++ b/src/status_im/ui/screens/profile/user/views.cljs @@ -167,13 +167,17 @@ (letsubs [{:keys [public-key] :as current-account} [:get-current-account] editing? [:get :my-profile/editing?] changed-account [:get :my-profile/profile] - currency [:wallet/currency]] + currency [:wallet/currency] + scroll (atom nil)] (let [shown-account (merge current-account changed-account)] [react/view profile.components.styles/profile (if editing? [my-profile-edit-toolbar] [my-profile-toolbar]) - [react/scroll-view {:keyboard-should-persist-taps :handled} + [react/scroll-view {:ref #(reset! scroll %) + :keyboard-should-persist-taps :handled + :on-content-size-change #(when (and scroll @scroll) + (.scrollToEnd @scroll))} [react/view profile.components.styles/profile-form [profile.components/profile-header shown-account editing? true profile-icon-options :my-profile/update-name]] [react/view action-button.styles/actions-list diff --git a/src/status_im/ui/screens/wallet/send/views.cljs b/src/status_im/ui/screens/wallet/send/views.cljs index 22daaf6e89..09032b2db8 100644 --- a/src/status_im/ui/screens/wallet/send/views.cljs +++ b/src/status_im/ui/screens/wallet/send/views.cljs @@ -178,9 +178,11 @@ [react/text {:style styles/advanced-fees-details-text} (str (money/to-fixed gas) " * " (money/to-fixed (money/wei-> :gwei gas-price)) (i18n/label :t/gwei))]]]]) -(defn- advanced-options [advanced? transaction modal?] +(defn- advanced-options [advanced? transaction modal? scroll] [react/view {:style styles/advanced-wrapper} - [react/touchable-highlight {:on-press #(re-frame/dispatch [:wallet.send/toggle-advanced (not advanced?)])} + [react/touchable-highlight {:on-press (fn [] + (re-frame/dispatch [:wallet.send/toggle-advanced (not advanced?)]) + (when (and scroll @scroll) (utils/set-timeout #(.scrollToEnd @scroll) 350)))} [react/view {:style styles/advanced-button-wrapper} [react/view {:style styles/advanced-button :accessibility-label :advanced-button} @@ -205,11 +207,10 @@ (i18n/label :t/send-transaction)] [react/view components.styles/flex [common/network-info {:text-color :white}] - [react/scroll-view (merge {:keyboard-should-persist-taps :always - :on-content-size-change #(when (and scroll @scroll) - (.scrollToEnd @scroll))} - (when-not modal? - {:ref #(reset! scroll %)})) + [react/scroll-view {:keyboard-should-persist-taps :always + :ref #(reset! scroll %) + :on-content-size-change #(when (and (not modal?) scroll @scroll) + (.scrollToEnd @scroll))} [react/view styles/send-transaction-form [components/recipient-selector {:disabled? modal? :address to @@ -224,7 +225,7 @@ :max-length 21 :on-focus (fn [] (when (and scroll @scroll) (utils/set-timeout #(.scrollToEnd @scroll) 100))) :on-change-text (update-amount-fn timeout)}}] - [advanced-options advanced? transaction modal?]]] + [advanced-options advanced? transaction modal? scroll]]] (if signing? [signing-buttons #(re-frame/dispatch (if modal? [:wallet/cancel-signing-modal] [:wallet/discard-transaction]))