parent
b0ecd68a97
commit
543d89ece3
|
@ -20,8 +20,7 @@
|
||||||
[status-im.utils.phone-number :refer [format-phone-number]]
|
[status-im.utils.phone-number :refer [format-phone-number]]
|
||||||
[status-im.utils.datetime :as time]
|
[status-im.utils.datetime :as time]
|
||||||
[status-im.chat.handlers.animation :refer [update-response-height
|
[status-im.chat.handlers.animation :refer [update-response-height
|
||||||
get-response-height
|
get-response-height]]))
|
||||||
init-response-dragging]]))
|
|
||||||
|
|
||||||
(def delta 1)
|
(def delta 1)
|
||||||
|
|
||||||
|
@ -273,9 +272,7 @@
|
||||||
(defn init-chat
|
(defn init-chat
|
||||||
([db] (init-chat db nil))
|
([db] (init-chat db nil))
|
||||||
([{:keys [messages current-chat-id] :as db} _]
|
([{:keys [messages current-chat-id] :as db} _]
|
||||||
(-> db
|
(assoc-in db [:chats current-chat-id :messages] messages)))
|
||||||
(assoc-in [:chats current-chat-id :messages] messages)
|
|
||||||
(init-response-dragging))))
|
|
||||||
|
|
||||||
(register-handler :init-chat
|
(register-handler :init-chat
|
||||||
(-> load-messages!
|
(-> load-messages!
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
(ns status-im.chat.handlers.animation
|
(ns status-im.chat.handlers.animation
|
||||||
(:require [re-frame.core :refer [register-handler after dispatch]]
|
(:require [re-frame.core :refer [register-handler after dispatch]]
|
||||||
[status-im.components.drag-drop :as drag]
|
|
||||||
[status-im.models.commands :as commands]
|
[status-im.models.commands :as commands]
|
||||||
[status-im.handlers.content-suggestions :refer [get-content-suggestions]]
|
[status-im.handlers.content-suggestions :refer [get-content-suggestions]]
|
||||||
[status-im.chat.styles.plain-input :refer [input-height]]
|
[status-im.chat.styles.plain-input :refer [input-height]]
|
||||||
|
@ -91,13 +90,3 @@
|
||||||
:else max-height)]
|
:else max-height)]
|
||||||
(dispatch [:animate-response-resize])
|
(dispatch [:animate-response-resize])
|
||||||
(assoc-in db [:animations :to-response-height] new-fixed))))
|
(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)))
|
|
||||||
|
|
|
@ -58,11 +58,17 @@
|
||||||
(dispatch [:cancel-command]))))))
|
(dispatch [:cancel-command]))))))
|
||||||
(anim/set-value val @current-value))))
|
(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]
|
(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?]])
|
commands-input-is-switching? (subscribe [:get-in [:animations :commands-input-is-switching?]])
|
||||||
response-resize? (subscribe [:get-in [:animations :response-resize?]])
|
response-resize? (subscribe [:get-in [:animations :response-resize?]])
|
||||||
|
|
||||||
to-response-height (subscribe [:get-in [:animations :to-response-height]])
|
to-response-height (subscribe [:get-in [:animations :to-response-height]])
|
||||||
cur-response-height (subscribe [:get-in [:animations :response-height-current]])
|
cur-response-height (subscribe [:get-in [:animations :response-height-current]])
|
||||||
response-height (anim/create-value (or @cur-response-height 0))
|
response-height (anim/create-value (or @cur-response-height 0))
|
||||||
|
@ -79,7 +85,7 @@
|
||||||
:reagent-render
|
:reagent-render
|
||||||
(fn [content]
|
(fn [content]
|
||||||
@to-response-height
|
@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?)
|
{:style (st/response-view (if (or @commands-input-is-switching? @response-resize?)
|
||||||
response-height
|
response-height
|
||||||
(or @cur-response-height 0)))})
|
(or @cur-response-height 0)))})
|
||||||
|
|
|
@ -35,11 +35,10 @@
|
||||||
:animations {;; mutable data
|
:animations {;; mutable data
|
||||||
:to-response-height nil
|
:to-response-height nil
|
||||||
:response-height-current nil
|
:response-height-current nil
|
||||||
:response-pan-responder nil
|
|
||||||
:message-input-offset 0
|
:message-input-offset 0
|
||||||
:message-input-buttons-scale 1
|
:message-input-buttons-scale 1
|
||||||
:commands-input-is-switching? false
|
|
||||||
:messages-offset 0
|
:messages-offset 0
|
||||||
|
:commands-input-is-switching? false
|
||||||
:response-resize? false}})
|
:response-resize? false}})
|
||||||
|
|
||||||
(def protocol-initialized-path [:protocol-initialized])
|
(def protocol-initialized-path [:protocol-initialized])
|
||||||
|
|
Loading…
Reference in New Issue