Don't dismiss keyboard on command input appear
This commit is contained in:
parent
7745f1accb
commit
49b08e5118
|
@ -4,7 +4,8 @@
|
||||||
[status-im.components.react :refer [view
|
[status-im.components.react :refer [view
|
||||||
icon
|
icon
|
||||||
touchable-highlight
|
touchable-highlight
|
||||||
text-input]]
|
text-input
|
||||||
|
dismiss-keyboard!]]
|
||||||
[status-im.chat.views.suggestions :refer [suggestions-view]]
|
[status-im.chat.views.suggestions :refer [suggestions-view]]
|
||||||
[status-im.chat.views.content-suggestions :refer [content-suggestions-view]]
|
[status-im.chat.views.content-suggestions :refer [content-suggestions-view]]
|
||||||
[status-im.chat.views.command :as command]
|
[status-im.chat.views.command :as command]
|
||||||
|
@ -14,7 +15,9 @@
|
||||||
(defn set-input-message [message]
|
(defn set-input-message [message]
|
||||||
(dispatch [:set-chat-input-text message]))
|
(dispatch [:set-chat-input-text message]))
|
||||||
|
|
||||||
(defn send []
|
(defn send [dismiss-keyboard]
|
||||||
|
(when dismiss-keyboard
|
||||||
|
(dismiss-keyboard!))
|
||||||
(dispatch [:send-chat-msg]))
|
(dispatch [:send-chat-msg]))
|
||||||
|
|
||||||
(defn message-valid? [staged-commands message]
|
(defn message-valid? [staged-commands message]
|
||||||
|
@ -22,9 +25,9 @@
|
||||||
(not= "!" message))
|
(not= "!" message))
|
||||||
(pos? (count staged-commands))))
|
(pos? (count staged-commands))))
|
||||||
|
|
||||||
(defn try-send [staged-commands message]
|
(defn try-send [staged-commands message dismiss-keyboard]
|
||||||
(when (message-valid? staged-commands message)
|
(when (message-valid? staged-commands message)
|
||||||
(send)))
|
(send dismiss-keyboard)))
|
||||||
|
|
||||||
(defn plain-message-input-view [{:keys [command input-options validator]}]
|
(defn plain-message-input-view [{:keys [command input-options validator]}]
|
||||||
(let [input-message (subscribe [:get-chat-input-text])
|
(let [input-message (subscribe [:get-chat-input-text])
|
||||||
|
@ -32,6 +35,7 @@
|
||||||
staged-commands (subscribe [:get-chat-staged-commands])
|
staged-commands (subscribe [:get-chat-staged-commands])
|
||||||
typing-command? (subscribe [:typing-command?])]
|
typing-command? (subscribe [:typing-command?])]
|
||||||
(fn [{:keys [command input-options validator]}]
|
(fn [{:keys [command input-options validator]}]
|
||||||
|
(let [dismiss-keyboard (not (or command @typing-command?))]
|
||||||
[view st/input-container
|
[view st/input-container
|
||||||
(if command
|
(if command
|
||||||
[content-suggestions-view]
|
[content-suggestions-view]
|
||||||
|
@ -47,6 +51,7 @@
|
||||||
[icon :list st/list-icon])]])
|
[icon :list st/list-icon])]])
|
||||||
[text-input (merge {:style (if command st-command/command-input st/message-input) ;; st-command/command-input
|
[text-input (merge {:style (if command st-command/command-input st/message-input) ;; st-command/command-input
|
||||||
:autoFocus false
|
:autoFocus false
|
||||||
|
:blurOnSubmit dismiss-keyboard
|
||||||
:onChangeText (fn [text]
|
:onChangeText (fn [text]
|
||||||
((if command
|
((if command
|
||||||
command/set-input-message
|
command/set-input-message
|
||||||
|
@ -56,7 +61,8 @@
|
||||||
(if command
|
(if command
|
||||||
(command/try-send @input-command validator)
|
(command/try-send @input-command validator)
|
||||||
(try-send @staged-commands
|
(try-send @staged-commands
|
||||||
@input-message)))}
|
@input-message
|
||||||
|
dismiss-keyboard)))}
|
||||||
input-options)
|
input-options)
|
||||||
(if command
|
(if command
|
||||||
@input-command
|
@input-command
|
||||||
|
@ -72,6 +78,8 @@
|
||||||
[view st-command/cancel-container
|
[view st-command/cancel-container
|
||||||
[icon :close-gray st-command/cancel-icon]]])
|
[icon :close-gray st-command/cancel-icon]]])
|
||||||
(when (message-valid? @staged-commands @input-message)
|
(when (message-valid? @staged-commands @input-message)
|
||||||
[touchable-highlight {:on-press send}
|
[touchable-highlight {:on-press #(try-send @staged-commands
|
||||||
|
@input-message
|
||||||
|
dismiss-keyboard)}
|
||||||
[view st/send-container
|
[view st/send-container
|
||||||
[icon :send st/send-icon]]]))]])))
|
[icon :send st/send-icon]]]))]]))))
|
||||||
|
|
Loading…
Reference in New Issue