Move PanResponder to view

Former-commit-id: 161be555b5
This commit is contained in:
virvar 2016-06-06 09:12:55 +03:00
parent b0ecd68a97
commit 543d89ece3
4 changed files with 12 additions and 21 deletions

View File

@ -20,8 +20,7 @@
[status-im.utils.phone-number :refer [format-phone-number]]
[status-im.utils.datetime :as time]
[status-im.chat.handlers.animation :refer [update-response-height
get-response-height
init-response-dragging]]))
get-response-height]]))
(def delta 1)
@ -273,9 +272,7 @@
(defn init-chat
([db] (init-chat db nil))
([{:keys [messages current-chat-id] :as db} _]
(-> db
(assoc-in [:chats current-chat-id :messages] messages)
(init-response-dragging))))
(assoc-in db [:chats current-chat-id :messages] messages)))
(register-handler :init-chat
(-> load-messages!

View File

@ -1,6 +1,5 @@
(ns status-im.chat.handlers.animation
(:require [re-frame.core :refer [register-handler after dispatch]]
[status-im.components.drag-drop :as drag]
[status-im.models.commands :as commands]
[status-im.handlers.content-suggestions :refer [get-content-suggestions]]
[status-im.chat.styles.plain-input :refer [input-height]]
@ -91,13 +90,3 @@
:else max-height)]
(dispatch [:animate-response-resize])
(assoc-in db [:animations :to-response-height] new-fixed))))
(defn create-response-pan-responder []
(drag/create-pan-responder
{:on-move (fn [e gesture]
(dispatch [:on-drag-response (.-dy gesture)]))
:on-release (fn [e gesture]
(dispatch [:fix-response-height]))}))
(defn init-response-dragging [db]
(assoc-in db [:animations :response-pan-responder] (create-response-pan-responder)))

View File

@ -58,11 +58,17 @@
(dispatch [:cancel-command]))))))
(anim/set-value val @current-value))))
(defn create-response-pan-responder []
(drag/create-pan-responder
{:on-move (fn [e gesture]
(dispatch [:on-drag-response (.-dy gesture)]))
:on-release (fn [e gesture]
(dispatch [:fix-response-height]))}))
(defn inner-container [content]
(let [pan-responder (subscribe [:get-in [:animations :response-pan-responder]])
(let [pan-responder (create-response-pan-responder)
commands-input-is-switching? (subscribe [:get-in [:animations :commands-input-is-switching?]])
response-resize? (subscribe [:get-in [:animations :response-resize?]])
to-response-height (subscribe [:get-in [:animations :to-response-height]])
cur-response-height (subscribe [:get-in [:animations :response-height-current]])
response-height (anim/create-value (or @cur-response-height 0))
@ -79,7 +85,7 @@
:reagent-render
(fn [content]
@to-response-height
[animated-view (merge (drag/pan-handlers @pan-responder)
[animated-view (merge (drag/pan-handlers pan-responder)
{:style (st/response-view (if (or @commands-input-is-switching? @response-resize?)
response-height
(or @cur-response-height 0)))})

View File

@ -35,11 +35,10 @@
:animations {;; mutable data
:to-response-height nil
:response-height-current nil
:response-pan-responder nil
:message-input-offset 0
:message-input-buttons-scale 1
:commands-input-is-switching? false
:messages-offset 0
:commands-input-is-switching? false
:response-resize? false}})
(def protocol-initialized-path [:protocol-initialized])