Keep the keyboard open after message sending

This commit is contained in:
virvar 2016-06-15 11:39:38 +03:00
parent 7459b63251
commit b216d7624a
2 changed files with 9 additions and 20 deletions

View File

@ -6,8 +6,7 @@
animated-view animated-view
icon icon
touchable-highlight touchable-highlight
text-input text-input]]
dismiss-keyboard!]]
[status-im.components.animation :as anim] [status-im.components.animation :as anim]
[status-im.chat.views.plain-message :as plain-message] [status-im.chat.views.plain-message :as plain-message]
[status-im.chat.views.command :as command] [status-im.chat.views.command :as command]
@ -61,8 +60,7 @@
staged-commands [:get-chat-staged-commands] staged-commands [:get-chat-staged-commands]
typing-command? [:typing-command?] typing-command? [:typing-command?]
commands-input-is-switching? [:animations :commands-input-is-switching?]] commands-input-is-switching? [:animations :commands-input-is-switching?]]
(let [dismiss-keyboard (not (or command typing-command?)) (let [response? (and command to-msg-id)
response? (and command to-msg-id)
message-input? (or (not command) commands-input-is-switching?) message-input? (or (not command) commands-input-is-switching?)
animation? commands-input-is-switching?] animation? commands-input-is-switching?]
[text-input (merge {:style (cond [text-input (merge {:style (cond
@ -72,7 +70,7 @@
:ref (fn [input] :ref (fn [input]
(dispatch [:set-message-input input])) (dispatch [:set-message-input input]))
:autoFocus false :autoFocus false
:blurOnSubmit dismiss-keyboard :blurOnSubmit false
:onChangeText (fn [text] :onChangeText (fn [text]
(when-not animation? (when-not animation?
((if message-input? ((if message-input?
@ -82,8 +80,7 @@
:onSubmitEditing #(when-not animation? :onSubmitEditing #(when-not animation?
(if message-input? (if message-input?
(plain-message/try-send staged-commands (plain-message/try-send staged-commands
input-message input-message)
dismiss-keyboard)
(command/try-send input-command validator)))} (command/try-send input-command validator)))}
(when command (when command
{:accessibility-label :command-input}) {:accessibility-label :command-input})
@ -100,8 +97,7 @@
staged-commands [:get-chat-staged-commands] staged-commands [:get-chat-staged-commands]
typing-command? [:typing-command?] typing-command? [:typing-command?]
commands-input-is-switching? [:animations :commands-input-is-switching?]] commands-input-is-switching? [:animations :commands-input-is-switching?]]
(let [dismiss-keyboard (not (or command typing-command?)) (let [response? (and command to-msg-id)
response? (and command to-msg-id)
message-input? (or (not command) commands-input-is-switching?)] message-input? (or (not command) commands-input-is-switching?)]
[view st/input-container [view st/input-container
[view st/input-view [view st/input-view
@ -117,8 +113,7 @@
(if message-input? (if message-input?
(when (plain-message/message-valid? staged-commands input-message) (when (plain-message/message-valid? staged-commands input-message)
[send-button {:on-press #(plain-message/try-send staged-commands [send-button {:on-press #(plain-message/try-send staged-commands
input-message input-message)
dismiss-keyboard)
:accessibility-label :send-message}]) :accessibility-label :send-message}])
(if (command/valid? input-command validator) (if (command/valid? input-command validator)
[send-button {:on-press command/send-command [send-button {:on-press command/send-command

View File

@ -5,8 +5,7 @@
[status-im.components.react :refer [view [status-im.components.react :refer [view
animated-view animated-view
icon icon
touchable-highlight touchable-highlight]]
dismiss-keyboard!]]
[status-im.components.animation :as anim] [status-im.components.animation :as anim]
[status-im.chat.styles.plain-message :as st] [status-im.chat.styles.plain-message :as st]
[status-im.constants :refer [response-input-hiding-duration]])) [status-im.constants :refer [response-input-hiding-duration]]))
@ -14,19 +13,14 @@
(defn set-input-message [message] (defn set-input-message [message]
(dispatch [:set-chat-input-text message])) (dispatch [:set-chat-input-text message]))
(defn send [dismiss-keyboard]
(when dismiss-keyboard
(dismiss-keyboard!))
(dispatch [:send-chat-msg]))
(defn message-valid? [staged-commands message] (defn message-valid? [staged-commands message]
(or (and (pos? (count message)) (or (and (pos? (count message))
(not= "!" message)) (not= "!" message))
(pos? (count staged-commands)))) (pos? (count staged-commands))))
(defn try-send [staged-commands message dismiss-keyboard] (defn try-send [staged-commands message]
(when (message-valid? staged-commands message) (when (message-valid? staged-commands message)
(send dismiss-keyboard))) (dispatch [:send-chat-msg])))
(defn prepare-message-input [message-input] (defn prepare-message-input [message-input]
(when message-input (when message-input