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