diff --git a/src/status_im/chat/handlers.cljs b/src/status_im/chat/handlers.cljs index 00f079e6bf..6d9e484fd2 100644 --- a/src/status_im/chat/handlers.cljs +++ b/src/status_im/chat/handlers.cljs @@ -168,8 +168,7 @@ (fn [{:keys [current-chat-id chats]} [_ height]] (let [{:keys [staged-scroll-view staged-scroll-height]} (get chats current-chat-id)] (when staged-scroll-view - (let [y (if (and (> staged-scroll-height 0) - (< staged-scroll-height height)) + (let [y (if (< 0 staged-scroll-height height) (- height staged-scroll-height) 0)] (.scrollTo staged-scroll-view (clj->js {:x 0 :y y})))))))) diff --git a/src/status_im/chat/styles/response.cljs b/src/status_im/chat/styles/response.cljs index ebd8d14a11..835d4906ff 100644 --- a/src/status_im/chat/styles/response.cljs +++ b/src/status_im/chat/styles/response.cljs @@ -49,13 +49,13 @@ :opacity 0.69 :color color-white}) -(defn response-view [keyboard-height height staged-commands] +(defn response-view [height input-margin staged-commands] {:flexDirection :column :position :absolute :elevation (if (seq staged-commands) 5 4) :left 0 :right 0 - :bottom keyboard-height + :bottom input-margin :height height :backgroundColor color-white}) diff --git a/src/status_im/chat/subs.cljs b/src/status_im/chat/subs.cljs index 63cb2dafbf..17468771d1 100644 --- a/src/status_im/chat/subs.cljs +++ b/src/status_im/chat/subs.cljs @@ -251,19 +251,11 @@ (register-sub :input-margin (fn [] (let [kb-height (subscribe [:get :keyboard-height]) - command (subscribe [:get-chat-command]) focused (subscribe [:get :focused]) mode (subscribe [:kb-mode])] (reaction - (cond (or ios? - (and (not @focused) - (= :on-send (keyword (:suggestions-trigger @command))) - (pos? @kb-height))) - @kb-height - - (and @focused (= :pan @mode) (pos? @kb-height)) - 20 - + (cond ios? @kb-height + (and @focused (= :pan @mode) (pos? @kb-height)) 20 :else 0))))) (register-sub :max-layout-height diff --git a/src/status_im/chat/views/response.cljs b/src/status_im/chat/views/response.cljs index 9256281d56..b496391457 100644 --- a/src/status_im/chat/views/response.cljs +++ b/src/status_im/chat/views/response.cljs @@ -23,7 +23,8 @@ [status-im.utils.platform :refer [ios?]] [status-im.components.webview-bridge :refer [webview-bridge]] [status-im.i18n :refer [label]] - [status-im.utils.datetime :as dt])) + [status-im.utils.datetime :as dt] + [taoensso.timbre :as log])) (defn drag-icon [] [view st/drag-container @@ -52,7 +53,7 @@ (dt/format-date "HH:mm" added))])]) (defn request-info [response-height] - (let [layout-height (subscribe [:get :layout-height]) + (let [layout-height (subscribe [:max-layout-height :default]) pan-responder (resp/pan-responder response-height layout-height :fix-response-height) @@ -74,19 +75,21 @@ (defn container-animation-logic [{:keys [to-value val animate?]}] (when-let [to-value @to-value] - (when-not (= to-value (.-_value val)) - (if (or (nil? @animate?) @animate?) - (anim/start (anim/timing val {:toValue to-value - :duration 300})) - (anim/set-value val to-value))))) + (let [max-layout-height (subscribe [:max-layout-height :default]) + to-value (min to-value (max 0 @max-layout-height))] + (when-not (= to-value (.-_value val)) + (if (or (nil? @animate?) @animate?) + (anim/start (anim/timing val {:toValue to-value + :duration 300})) + (anim/set-value val to-value)))))) (defn container [response-height & children] (let [;; todo to-response-height, cur-response-height must be specific ;; for each chat to-response-height (subscribe [:response-height :default]) + input-margin (subscribe [:input-margin]) changed (subscribe [:animations :response-height-changed]) animate? (subscribe [:animate?]) - keyboard-height (subscribe [:get :keyboard-height]) staged-commands (subscribe [:get-chat-staged-commands]) context {:to-value to-response-height :val response-height @@ -101,8 +104,8 @@ (fn [response-height & children] @to-response-height @changed (into [animated-view {:style (st/response-view - (if ios? @keyboard-height 0) response-height + @input-margin @staged-commands)}] children))}))) diff --git a/src/status_im/chat/views/suggestions.cljs b/src/status_im/chat/views/suggestions.cljs index 6491e1ba31..c4b1837012 100644 --- a/src/status_im/chat/views/suggestions.cljs +++ b/src/status_im/chat/views/suggestions.cljs @@ -101,10 +101,12 @@ (defn container-animation-logic [{:keys [to-value val animate?]}] (when-let [to-value @to-value] - (when-not (= to-value (.-_value val)) - (if (or (nil? @animate?) @animate?) - (anim/start (anim/spring val {:toValue to-value})) - (anim/set-value val to-value))))) + (let [max-layout-height (subscribe [:max-layout-height :default]) + to-value (min to-value (max 0 @max-layout-height))] + (when-not (= to-value (.-_value val)) + (if (or (nil? @animate?) @animate?) + (anim/start (anim/spring val {:toValue to-value})) + (anim/set-value val to-value)))))) (defn container [h & elements] (let [;; todo to-response-height, cur-response-height must be specific