edit mode

Former-commit-id: d6040491fb
This commit is contained in:
Roman Volosovskyi 2016-06-21 12:46:02 +03:00
parent 36bddaff1f
commit 4f6ac06fa9
8 changed files with 29 additions and 14 deletions

View File

@ -86,7 +86,8 @@
(.blur message-input)))))
(register-handler :set-response-chat-command
(after #(dispatch [:animate-show-response]))
[(after #(dispatch [:command-edit-mode]))
(after #(dispatch [:animate-show-response]))]
(fn [db [_ to-msg-id command-key]]
(commands/set-response-chat-command db to-msg-id command-key)))
@ -248,11 +249,10 @@
(commands/unstage-command db staged-command)))
(register-handler :set-chat-command
(after #(dispatch [:animate-show-response]))
[(after #(dispatch [:command-edit-mode]))
(after #(dispatch [:animate-show-response]))]
(fn [db [_ command-key]]
(-> db
(commands/set-chat-command command-key)
(assoc-in [:animations :command?] true))))
(commands/set-chat-command db command-key)))
(register-handler :init-console-chat
(fn [db [_]]
@ -428,3 +428,13 @@
;((after leaving-message!))
((after delete-messages!))
((after delete-chat!))))
(defn edit-mode-handler [mode]
(fn [{:keys [current-chat-id] :as db} _]
(assoc-in db [:edit-mode current-chat-id] mode)))
(register-handler :command-edit-mode
(edit-mode-handler :command))
(register-handler :text-edit-mode
(edit-mode-handler :text))

View File

@ -16,9 +16,9 @@
(register-handler name [(path :animations) middleware] handler)))
(animation-handler :animate-cancel-command
(after #(dispatch [:text-edit-mode]))
(fn [db _]
(assoc db
:command? false
:to-response-height zero-height
:messages-offset 0)))
@ -37,9 +37,9 @@
(assoc-in db [:animations :to-response-height] (get-response-height db)))
(register-handler :animate-show-response
(after #(dispatch [:command-edit-mode]))
(fn [db _]
(-> db
(assoc-in [:animations :command?] true)
(assoc-in [:animations :messages-offset] request-info-height)
(update-response-height))))

View File

@ -259,7 +259,7 @@
[group-chat [:chat :group-chat]
show-actions-atom [:show-actions]
command [:get-chat-command]
command? [:animations :command?]
command? [:command?]
to-msg-id [:get-chat-command-to-msg-id]]
[view {:style st/chat-view
:onLayout (fn [event]

View File

@ -111,3 +111,9 @@
(let [command (reaction (commands/get-chat-command @db))
text (reaction (commands/get-chat-command-content @db))]
(reaction (get-content-suggestions @command @text)))))
(register-sub :command?
(fn [db ]
(->> (get-in @db [:edit-mode (:current-chat-id @db)])
(= :command)
(reaction))))

View File

@ -32,7 +32,7 @@
:onSubmitEditing command/send-command})
(defview message-input [input-options]
[command? [:animations :command?]
[command? [:command?]
input-message [:get-chat-input-text]
input-command [:get-chat-command-content]]
[text-input (merge
@ -46,7 +46,7 @@
(if command? input-command input-message)])
(defview plain-message-input-view [{:keys [input-options validator]}]
[command? [:animations :command?]
[command? [:command?]
input-command [:get-chat-command-content]
valid-plain-message? [:valid-plain-message?]
valid-command? [:valid-command? validator]]

View File

@ -18,7 +18,7 @@
(defview show-input []
[command [:get-chat-command]
command? [:animations :command?]]
command? [:command?]]
[plain-message-input-view
(when command?
(case (:command command)

View File

@ -36,7 +36,7 @@
:delay delay})))))
(defn commands-button []
(let [command? (subscribe [:animations :command?])
(let [command? (subscribe [:command?])
buttons-scale (anim/create-value (if @command? 1 0))
container-width (anim/create-value (if @command? 20 56))
context {:command? command?
@ -69,7 +69,7 @@
(anim/set-value width 0.1)))))))
(defn smile-button []
(let [command? (subscribe [:animations :command?])
(let [command? (subscribe [:command?])
buttons-scale (anim/create-value (if @command? 1 0))
container-width (anim/create-value (if @command? 0.1 56))
context {:command? command?

View File

@ -38,7 +38,6 @@
:phone-number ""}
:disable-group-creation false
:animations {:to-response-height 0.1
:command? false
:messages-offset 0}})
(def protocol-initialized-path [:protocol-initialized])