diff --git a/src/status_im/components/react.cljs b/src/status_im/components/react.cljs index cef7e03e7e..841e932fcf 100644 --- a/src/status_im/components/react.cljs +++ b/src/status_im/components/react.cljs @@ -3,7 +3,7 @@ [status-im.components.styles :as st] [status-im.utils.utils :as u :refer [get-react-property get-class adapt-class]] - [status-im.utils.platform :refer [platform-specific]])) + [status-im.utils.platform :refer [platform-specific ios?]])) (def react-native (js/require "react-native")) (def native-modules (.-NativeModules react-native)) @@ -30,7 +30,7 @@ (def list-view-class (get-class "ListView")) (def scroll-view (get-class "ScrollView")) (def web-view (get-class "WebView")) -(def keyboard-avoiding-view (get-class "KeyboardAvoidingView")) +(def keyboard-avoiding-view-class (get-class "KeyboardAvoidingView")) (def text-class (get-class "Text")) (def text-input-class (get-class "TextInput")) @@ -151,3 +151,11 @@ (def http-bridge (js/require "react-native-http-bridge")) + +;; KeyboardAvoidingView + +(defn keyboard-avoiding-view [props & children] + (let [view-element (if ios? + [keyboard-avoiding-view-class (merge {:behavior :padding} props)] + [view props])] + (vec (concat view-element children)))) diff --git a/src/status_im/new_group/screen_private.cljs b/src/status_im/new_group/screen_private.cljs index db7fb04898..dc60f8899b 100644 --- a/src/status_im/new_group/screen_private.cljs +++ b/src/status_im/new_group/screen_private.cljs @@ -55,8 +55,7 @@ type [:get :group-type]] (let [save-btn-enabled? (and (s/valid? ::v/name group-name) (not= group-name (:name group)))] - [(if ios? keyboard-avoiding-view view) (merge {:behavior :padding} - st/group-container) + [keyboard-avoiding-view {:style st/group-container} [group-toolbar type true] [group-name-view] [view st/list-view-container diff --git a/src/status_im/new_group/views/chat_group_settings.cljs b/src/status_im/new_group/views/chat_group_settings.cljs index 962f33ab7d..0687edecda 100644 --- a/src/status_im/new_group/views/chat_group_settings.cljs +++ b/src/status_im/new_group/views/chat_group_settings.cljs @@ -63,8 +63,7 @@ type [:get :group-type]] (let [save-btn-enabled? (and (s/valid? ::v/name new-chat-name) (not= new-chat-name chat-name))] - [(if ios? keyboard-avoiding-view view) (merge {:behavior :padding} - st/group-container) + [keyboard-avoiding-view {:style st/group-container} [view {:flex 1} [group-toolbar type true] [scroll-view diff --git a/src/status_im/new_group/views/contact_toggle_list.cljs b/src/status_im/new_group/views/contact_toggle_list.cljs index 607099cd75..9ff57dfc15 100644 --- a/src/status_im/new_group/views/contact_toggle_list.cljs +++ b/src/status_im/new_group/views/contact_toggle_list.cljs @@ -57,8 +57,7 @@ [contacts [:all-added-group-contacts-filtered] selected-contacts-count [:selected-contacts-count] group-type [:get :group-type]] - [(if ios? keyboard-avoiding-view view) (merge {:behavior :padding} - st/group-container) + [keyboard-avoiding-view {:style st/group-container} [status-bar] [toggle-list-toolbar (label (if (= group-type :contact-group) @@ -73,8 +72,7 @@ [contacts [:all-group-not-added-contacts-filtered] group [:get-contact-group] selected-contacts-count [:selected-contacts-count]] - [(if ios? keyboard-avoiding-view view) (merge {:behavior :padding} - st/group-container) + [keyboard-avoiding-view {:style st/group-container} [status-bar] [toggle-list-toolbar (:name group) selected-contacts-count] [toggle-list contacts group-toggle-contact] @@ -87,8 +85,7 @@ [contacts [:contacts-filtered :all-new-contacts] chat-name [:chat :name] selected-contacts-count [:selected-participants-count]] - [(if ios? keyboard-avoiding-view view) (merge {:behavior :padding} - st/group-container) + [keyboard-avoiding-view {:style st/group-container} [status-bar] [toggle-list-toolbar chat-name selected-contacts-count] [toggle-list contacts group-toggle-participant] @@ -96,5 +93,3 @@ [sticky-button (label :t/save) #(do (dispatch [:add-new-participants]) (dispatch [:navigate-back]))])]) - - diff --git a/src/status_im/profile/edit/screen.cljs b/src/status_im/profile/edit/screen.cljs index c6b3d17533..d628b9bbe8 100644 --- a/src/status_im/profile/edit/screen.cljs +++ b/src/status_im/profile/edit/screen.cljs @@ -90,8 +90,7 @@ profile-edit-data-changed? (or (not= (:name current-account) (:name changed-account)) (not= (:status current-account) (:status changed-account)) (not= (:photo-path current-account) (:photo-path changed-account)))] - [(if ios? keyboard-avoiding-view view) (merge {:behavior :padding} - st/profile) + [keyboard-avoiding-view {:style st/profile} [status-bar] [edit-my-profile-toolbartoolbar] [view st/edit-my-profile-form diff --git a/src/status_im/transactions/handlers.cljs b/src/status_im/transactions/handlers.cljs index bf9f20721f..064df8ca6c 100644 --- a/src/status_im/transactions/handlers.cljs +++ b/src/status_im/transactions/handlers.cljs @@ -155,8 +155,7 @@ (dispatch [::check-completed-transaction! {:message-id message-id}])) (dispatch [::remove-transaction id])) - (when (or (= modal :pending-transactions) - (= modal :transaction-details)) + (when (#{:pending-transactions :transaction-details} modal) (dispatch [:navigate-to-modal :confirmation-success]))))))) (register-handler ::add-transactions-hash diff --git a/src/status_im/transactions/screens/pending-transactions.cljs b/src/status_im/transactions/screens/pending-transactions.cljs index 8eb52088c5..1f028df30e 100644 --- a/src/status_im/transactions/screens/pending-transactions.cljs +++ b/src/status_im/transactions/screens/pending-transactions.cljs @@ -47,7 +47,7 @@ confirmed? [:get-in [:transactions-list-ui-props :confirmed?]]] {:component-did-update #(when-not (seq transactions) (rf/dispatch [:navigate-back])) :component-will-unmount #(rf/dispatch [:set-in [:transactions-list-ui-props :confirmed?] false])} - [(if platform/ios? rn/keyboard-avoiding-view rn/view) (merge {:behavior :padding} st/transactions-screen) + [rn/keyboard-avoiding-view {:style st/transactions-screen} [status-bar/status-bar {:type (if platform/ios? :transparent :main)}] [toolbar-view transactions] [rn/view {:style st/transactions-screen-content-container} diff --git a/src/status_im/transactions/screens/transaction-details.cljs b/src/status_im/transactions/screens/transaction-details.cljs index ed019f4c92..fd3a6a212d 100644 --- a/src/status_im/transactions/screens/transaction-details.cljs +++ b/src/status_im/transactions/screens/transaction-details.cljs @@ -50,7 +50,7 @@ confirmed? [:get-in [:transaction-details-ui-props :confirmed?]]] {:component-did-update #(when-not transaction (rf/dispatch [:navigate-to-modal :pending-transactions])) :component-will-unmount #(rf/dispatch [:set-in [:transaction-details-ui-props :confirmed?] false])} - [(if platform/ios? rn/keyboard-avoiding-view rn/view) (merge {:behavior :padding} st/transactions-screen) + [rn/keyboard-avoiding-view {:style st/transactions-screen} [status-bar/status-bar {:type (if platform/ios? :transparent :main)}] [toolbar-view] [rn/scroll-view st/details-screen-content-container