parent
6beda2ace2
commit
36bddaff1f
|
@ -50,12 +50,7 @@
|
|||
(fn [db _]
|
||||
(dispatch [:animate-cancel-command]))))
|
||||
|
||||
(defn animate-set-chat-command-content [db _]
|
||||
(when (commands/get-chat-command-to-msg-id db)
|
||||
(dispatch [:animate-response-resize])))
|
||||
|
||||
(register-handler :set-chat-command-content
|
||||
(after animate-set-chat-command-content)
|
||||
(fn [{:keys [current-chat-id] :as db} [_ content]]
|
||||
(as-> db db
|
||||
(commands/set-chat-command-content db content)
|
||||
|
|
|
@ -22,20 +22,6 @@
|
|||
:to-response-height zero-height
|
||||
:messages-offset 0)))
|
||||
|
||||
(animation-handler :finish-animate-response-resize
|
||||
(fn [db _]
|
||||
(let [fixed (:to-response-height db)]
|
||||
(assoc db :response-height-current fixed
|
||||
:response-resize? false))))
|
||||
|
||||
(animation-handler :set-response-height
|
||||
(fn [db [_ value]]
|
||||
(assoc db :response-height-current value)))
|
||||
|
||||
(animation-handler :animate-response-resize
|
||||
(fn [db _]
|
||||
(assoc db :response-resize? true)))
|
||||
|
||||
(defn get-response-height [db]
|
||||
(let [command (commands/get-chat-command db)
|
||||
text (commands/get-chat-command-content db)
|
||||
|
@ -51,10 +37,8 @@
|
|||
(assoc-in db [:animations :to-response-height] (get-response-height db)))
|
||||
|
||||
(register-handler :animate-show-response
|
||||
(after #(dispatch [:animate-response-resize]))
|
||||
(fn [db _]
|
||||
(-> db
|
||||
(assoc-in [:animations :response-height-current] zero-height)
|
||||
(assoc-in [:animations :command?] true)
|
||||
(assoc-in [:animations :messages-offset] request-info-height)
|
||||
(update-response-height))))
|
||||
|
@ -65,19 +49,12 @@
|
|||
(if (not= height prev-height)
|
||||
(let [db (assoc db :response-height-max height)]
|
||||
(if (= prev-height (:to-response-height db))
|
||||
(assoc db :to-response-height height
|
||||
:response-height-current height)
|
||||
(assoc db :to-response-height height)
|
||||
db))
|
||||
db))))
|
||||
|
||||
(animation-handler :on-drag-response
|
||||
(fn [db [_ dy]]
|
||||
(let [fixed (:to-response-height db)]
|
||||
(assoc db :response-height-current (- fixed dy)
|
||||
:response-resize? false))))
|
||||
|
||||
(register-handler :fix-response-height
|
||||
(fn [db [_ dy vy current]]
|
||||
(fn [db [_ vy current]]
|
||||
(let [max-height (get-in db [:animations :response-height-max])
|
||||
;; todo magic value
|
||||
middle 270
|
||||
|
|
|
@ -34,24 +34,27 @@
|
|||
;; TODO stub data: request message info
|
||||
"By ???, MMM 1st at HH:mm"]])
|
||||
|
||||
;; todo bad name. Ideas?
|
||||
(defn enough-dy [gesture]
|
||||
(> (Math/abs (.-dy gesture)) 10))
|
||||
|
||||
(defn pan-responder [response-height kb-height orientation]
|
||||
(drag/create-pan-responder
|
||||
{:on-move (fn [_ gesture]
|
||||
(when (> (Math/abs (.-dy gesture)) 10)
|
||||
(when (enough-dy gesture)
|
||||
(let [w (react/get-dimensions "window")
|
||||
p (if (= :portrait @orientation)
|
||||
prop (if (= :portrait @orientation)
|
||||
:height
|
||||
:width)
|
||||
to-value (- (p w)
|
||||
@kb-height
|
||||
(.-moveY gesture))]
|
||||
to-value (- (prop w) @kb-height (.-moveY gesture))]
|
||||
(anim/start
|
||||
(anim/spring response-height {:toValue to-value})))))
|
||||
:on-release (fn [_ gesture]
|
||||
(when (> (Math/abs (.-dy gesture)) 10)
|
||||
(when (enough-dy gesture)
|
||||
(dispatch [:fix-response-height
|
||||
(.-dy gesture)
|
||||
(.-vy gesture)
|
||||
;; todo access to "private" property
|
||||
;; better to find another way...
|
||||
(.-_value response-height)])))}))
|
||||
|
||||
(defn request-info [response-height]
|
||||
|
|
|
@ -38,10 +38,8 @@
|
|||
:phone-number ""}
|
||||
:disable-group-creation false
|
||||
:animations {:to-response-height 0.1
|
||||
:response-height-current nil
|
||||
:command? false
|
||||
:messages-offset 0
|
||||
:response-resize? false}})
|
||||
:messages-offset 0}})
|
||||
|
||||
(def protocol-initialized-path [:protocol-initialized])
|
||||
(defn chat-input-text-path [chat-id]
|
||||
|
|
Loading…
Reference in New Issue