parent
b92a4da70b
commit
997cc2f635
|
@ -52,14 +52,18 @@
|
||||||
(dispatch [:animate-cancel-command])
|
(dispatch [:animate-cancel-command])
|
||||||
(dispatch [:cancel-command])))))
|
(dispatch [: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)
|
||||||
(assoc-in db [:chats current-chat-id :input-text] nil)
|
(assoc-in db [:chats current-chat-id :input-text] nil)
|
||||||
(if (commands/get-chat-command-to-msg-id db)
|
(if (commands/get-chat-command-to-msg-id db)
|
||||||
(do (dispatch [:animate-response-resize])
|
(update-response-height db)
|
||||||
(update-response-height db))
|
|
||||||
db))))
|
db))))
|
||||||
|
|
||||||
(defn update-input-text
|
(defn update-input-text
|
||||||
|
@ -80,13 +84,6 @@
|
||||||
(fn [db [_ input]]
|
(fn [db [_ input]]
|
||||||
(assoc db :message-input input)))
|
(assoc db :message-input input)))
|
||||||
|
|
||||||
(register-handler :prepare-message-input
|
|
||||||
(u/side-effect!
|
|
||||||
(fn [db _]
|
|
||||||
(when-let [message-input (:message-input db)]
|
|
||||||
(.clear message-input)
|
|
||||||
(.focus message-input)))))
|
|
||||||
|
|
||||||
(register-handler :blur-message-input
|
(register-handler :blur-message-input
|
||||||
(u/side-effect!
|
(u/side-effect!
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
|
|
|
@ -56,7 +56,6 @@
|
||||||
(assoc-in db [:animations :to-response-height] (get-response-height db)))
|
(assoc-in db [:animations :to-response-height] (get-response-height db)))
|
||||||
|
|
||||||
(register-handler :finish-show-response
|
(register-handler :finish-show-response
|
||||||
(after #(dispatch [:prepare-message-input]))
|
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
(assoc-in db [:animations :commands-input-is-switching?] false)))
|
(assoc-in db [:animations :commands-input-is-switching?] false)))
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,20 @@
|
||||||
(when (message-valid? staged-commands message)
|
(when (message-valid? staged-commands message)
|
||||||
(send dismiss-keyboard)))
|
(send dismiss-keyboard)))
|
||||||
|
|
||||||
(defn commands-button-animation-logic [{:keys [to-value val]}]
|
(defn prepare-message-input [message-input]
|
||||||
|
(when message-input
|
||||||
|
(.clear message-input)
|
||||||
|
(.focus message-input)))
|
||||||
|
|
||||||
|
(defn commands-button-animation-callback [message-input]
|
||||||
|
(fn [arg to-value]
|
||||||
|
(when (.-finished arg)
|
||||||
|
(dispatch [:set-in [:animations ::message-input-buttons-scale-current] to-value])
|
||||||
|
(when (<= to-value 0.1)
|
||||||
|
(dispatch [:finish-show-response])
|
||||||
|
(prepare-message-input @message-input)))))
|
||||||
|
|
||||||
|
(defn button-animation-logic [{:keys [to-value val callback]}]
|
||||||
(fn [_]
|
(fn [_]
|
||||||
(let [to-scale @to-value
|
(let [to-scale @to-value
|
||||||
minimum 0.1
|
minimum 0.1
|
||||||
|
@ -37,21 +50,22 @@
|
||||||
:else to-scale)]
|
:else to-scale)]
|
||||||
(anim/start (anim/timing val {:toValue scale
|
(anim/start (anim/timing val {:toValue scale
|
||||||
:duration response-input-hiding-duration})
|
:duration response-input-hiding-duration})
|
||||||
(fn [arg]
|
(when callback
|
||||||
(when (.-finished arg)
|
(fn [arg]
|
||||||
(dispatch [:set-in [:animations ::message-input-buttons-scale-current] scale])
|
(callback arg to-scale)))))))
|
||||||
(when (= to-scale minimum)
|
|
||||||
(dispatch [:finish-show-response]))))))))
|
|
||||||
|
|
||||||
(defn commands-button []
|
(defn commands-button []
|
||||||
(let [typing-command? (subscribe [:typing-command?])
|
(let [typing-command? (subscribe [:typing-command?])
|
||||||
|
message-input (subscribe [:get :message-input])
|
||||||
animation? (subscribe [:get-in [:animations :commands-input-is-switching?]])
|
animation? (subscribe [:get-in [:animations :commands-input-is-switching?]])
|
||||||
to-scale (subscribe [:get-in [:animations :message-input-buttons-scale]])
|
to-scale (subscribe [:get-in [:animations :message-input-buttons-scale]])
|
||||||
cur-scale (subscribe [:get-in [:animations ::message-input-buttons-scale-current]])
|
cur-scale (subscribe [:get-in [:animations ::message-input-buttons-scale-current]])
|
||||||
buttons-scale (anim/create-value (or @cur-scale 1))
|
buttons-scale (anim/create-value (or @cur-scale 1))
|
||||||
|
anim-callback (commands-button-animation-callback message-input)
|
||||||
context {:to-value to-scale
|
context {:to-value to-scale
|
||||||
:val buttons-scale}
|
:val buttons-scale
|
||||||
on-update (commands-button-animation-logic context)]
|
:callback anim-callback}
|
||||||
|
on-update (button-animation-logic context)]
|
||||||
(r/create-class
|
(r/create-class
|
||||||
{:component-did-mount
|
{:component-did-mount
|
||||||
on-update
|
on-update
|
||||||
|
@ -76,7 +90,7 @@
|
||||||
buttons-scale (anim/create-value (or @cur-scale 1))
|
buttons-scale (anim/create-value (or @cur-scale 1))
|
||||||
context {:to-value to-scale
|
context {:to-value to-scale
|
||||||
:val buttons-scale}
|
:val buttons-scale}
|
||||||
on-update (commands-button-animation-logic context)]
|
on-update (button-animation-logic context)]
|
||||||
(r/create-class
|
(r/create-class
|
||||||
{:component-did-mount
|
{:component-did-mount
|
||||||
on-update
|
on-update
|
||||||
|
|
Loading…
Reference in New Issue