validation errors position
This commit is contained in:
parent
4e5838391c
commit
3718541b8c
|
@ -41,10 +41,16 @@
|
||||||
(defn get-minimum-height
|
(defn get-minimum-height
|
||||||
[{:keys [current-chat-id] :as db}]
|
[{:keys [current-chat-id] :as db}]
|
||||||
(let [path [:chats current-chat-id :command-input :command :type]
|
(let [path [:chats current-chat-id :command-input :command :type]
|
||||||
type (get-in db path)]
|
type (get-in db path)
|
||||||
(if (= :response type)
|
errors (get-in db [:validation-errors current-chat-id])
|
||||||
minimum-suggestion-height
|
custom-errors (get-in db [:custom-validation-errors current-chat-id])
|
||||||
input-height)))
|
validation-height (if (or (seq errors) (seq custom-errors))
|
||||||
|
request-info-height
|
||||||
|
0)]
|
||||||
|
(+ validation-height
|
||||||
|
(if (= :response type)
|
||||||
|
minimum-suggestion-height
|
||||||
|
input-height))))
|
||||||
|
|
||||||
(register-handler :animate-show-response
|
(register-handler :animate-show-response
|
||||||
;[(after #(dispatch [:command-edit-mode]))]
|
;[(after #(dispatch [:command-edit-mode]))]
|
||||||
|
|
|
@ -183,5 +183,6 @@
|
||||||
|
|
||||||
|
|
||||||
(register-handler ::set-validation-error
|
(register-handler ::set-validation-error
|
||||||
|
(after #(dispatch [:fix-response-height]))
|
||||||
(fn [db [_ chat-id error]]
|
(fn [db [_ chat-id error]]
|
||||||
(assoc-in db [:validation-errors chat-id] [error])))
|
(assoc-in db [:validation-errors chat-id] [error])))
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
(ns status-im.chat.styles.command-validation
|
(ns status-im.chat.styles.command-validation
|
||||||
(:require [status-im.components.styles :as st]))
|
(:require [status-im.components.styles :as st]
|
||||||
|
[status-im.chat.constants :as constants]))
|
||||||
|
|
||||||
(def messages-container
|
(def messages-container
|
||||||
{:background-color :red
|
{:background-color :red
|
||||||
:height 61
|
:height constants/request-info-height
|
||||||
:padding-left 16
|
:padding-left 16
|
||||||
:padding-top 14})
|
:padding-top 14})
|
||||||
|
|
||||||
|
|
|
@ -20,12 +20,11 @@
|
||||||
[validation-messages [:validation-errors]
|
[validation-messages [:validation-errors]
|
||||||
custom-errors [:custom-validation-errors]
|
custom-errors [:custom-validation-errors]
|
||||||
command? [:command?]]
|
command? [:command?]]
|
||||||
(when (and command?
|
[c/view
|
||||||
(or (seq validation-messages)
|
(cond (seq custom-errors)
|
||||||
(seq custom-errors)))
|
(vec (concat [c/view] custom-errors))
|
||||||
[c/scroll-view
|
|
||||||
(cond (seq custom-errors)
|
|
||||||
(vec (concat [c/view] custom-errors))
|
|
||||||
|
|
||||||
(seq validation-messages)
|
(seq validation-messages)
|
||||||
[messages-list validation-messages])]))
|
[messages-list validation-messages]
|
||||||
|
|
||||||
|
:else nil)])
|
||||||
|
|
|
@ -11,8 +11,7 @@
|
||||||
[status-im.chat.views.command :as command]
|
[status-im.chat.views.command :as command]
|
||||||
[status-im.chat.styles.message-input :as st]
|
[status-im.chat.styles.message-input :as st]
|
||||||
[status-im.chat.styles.plain-message :as st-message]
|
[status-im.chat.styles.plain-message :as st-message]
|
||||||
[status-im.chat.styles.response :as st-response]
|
[status-im.chat.styles.response :as st-response]))
|
||||||
[status-im.chat.views.command-validation :as cv]))
|
|
||||||
|
|
||||||
(defn send-button [{:keys [on-press accessibility-label]}]
|
(defn send-button [{:keys [on-press accessibility-label]}]
|
||||||
[touchable-highlight {:on-press on-press
|
[touchable-highlight {:on-press on-press
|
||||||
|
@ -56,7 +55,6 @@
|
||||||
input-command [:get-chat-command-content]
|
input-command [:get-chat-command-content]
|
||||||
valid-plain-message? [:valid-plain-message?]]
|
valid-plain-message? [:valid-plain-message?]]
|
||||||
[view st/input-container
|
[view st/input-container
|
||||||
[cv/validation-messages]
|
|
||||||
[view st/input-view
|
[view st/input-view
|
||||||
[plain-message/commands-button]
|
[plain-message/commands-button]
|
||||||
[message-input-container
|
[message-input-container
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
[status-im.chat.styles.dragdown :as ddst]
|
[status-im.chat.styles.dragdown :as ddst]
|
||||||
[status-im.components.animation :as anim]
|
[status-im.components.animation :as anim]
|
||||||
[status-im.chat.suggestions-responder :as resp]
|
[status-im.chat.suggestions-responder :as resp]
|
||||||
[status-im.chat.constants :as c]))
|
[status-im.chat.constants :as c]
|
||||||
|
[status-im.chat.views.command-validation :as cv]))
|
||||||
|
|
||||||
(defn drag-icon []
|
(defn drag-icon []
|
||||||
[view st/drag-container
|
[view st/drag-container
|
||||||
|
@ -83,8 +84,7 @@
|
||||||
|
|
||||||
(defview placeholder []
|
(defview placeholder []
|
||||||
[suggestions [:get-content-suggestions]]
|
[suggestions [:get-content-suggestions]]
|
||||||
(when (seq suggestions)
|
[view st/input-placeholder])
|
||||||
[view st/input-placeholder]))
|
|
||||||
|
|
||||||
(defview response-suggestions-view []
|
(defview response-suggestions-view []
|
||||||
[suggestions [:get-content-suggestions]]
|
[suggestions [:get-content-suggestions]]
|
||||||
|
@ -95,4 +95,5 @@
|
||||||
[container response-height
|
[container response-height
|
||||||
[request-info response-height]
|
[request-info response-height]
|
||||||
[response-suggestions-view]
|
[response-suggestions-view]
|
||||||
|
[cv/validation-messages]
|
||||||
[placeholder]]))
|
[placeholder]]))
|
||||||
|
|
|
@ -11,4 +11,4 @@
|
||||||
(defn register-handler
|
(defn register-handler
|
||||||
([name handler] (register-handler name nil handler))
|
([name handler] (register-handler name nil handler))
|
||||||
([name middleware handler]
|
([name middleware handler]
|
||||||
(re-core/register-handler name [debug middleware] handler)))
|
(re-core/register-handler name [#_debug middleware] handler)))
|
||||||
|
|
Loading…
Reference in New Issue