Andrey Shovkoplyas 2017-05-04 13:57:40 +03:00 committed by Roman Volosovskyi
parent bdd2c3aa14
commit 52c10562dc
1 changed files with 12 additions and 8 deletions

View File

@ -3,20 +3,24 @@
[status-im.components.animation :as anim] [status-im.components.animation :as anim]
[status-im.chat.views.input.utils :as input-utils] [status-im.chat.views.input.utils :as input-utils]
[re-frame.core :refer [dispatch]] [re-frame.core :refer [dispatch]]
[taoensso.timbre :as log])) [taoensso.timbre :as log]
[status-im.utils.platform :as p]
[status-im.components.toolbar-new.styles :as toolbar-st]))
;; todo bad name. Ideas? ;; todo bad name. Ideas?
(defn enough-dy [gesture] (defn enough-dy [gesture]
(> (Math/abs (.-dy gesture)) 10)) (> (Math/abs (.-dy gesture)) 10))
(defn on-move [response-height layout-height] (defn on-move [response-height layout-height]
(let [margin-top (+ (get-in p/platform-specific [:component-styles :status-bar :main :height])
(/ (:height toolbar-st/toolbar) 2))]
(fn [_ gesture] (fn [_ gesture]
(when (enough-dy gesture) (when (enough-dy gesture)
(let [to-value (- @layout-height (.-moveY gesture))] (let [to-value (+ (- @layout-height (.-moveY gesture)) margin-top)]
(when (> to-value input-utils/min-height) (when (> to-value input-utils/min-height)
(dispatch [:set :expandable-view-height-to-value to-value]) (dispatch [:set :expandable-view-height-to-value to-value])
(anim/start (anim/start
(anim/spring response-height {:toValue to-value}))))))) (anim/spring response-height {:toValue to-value}))))))))
(defn on-release [response-height handler-name key] (defn on-release [response-height handler-name key]
(fn [_ gesture] (fn [_ gesture]