validation errors position

This commit is contained in:
Roman Volosovskyi 2016-07-08 12:26:46 +03:00
parent 4e5838391c
commit 3718541b8c
7 changed files with 27 additions and 21 deletions

View File

@ -41,10 +41,16 @@
(defn get-minimum-height
[{:keys [current-chat-id] :as db}]
(let [path [:chats current-chat-id :command-input :command :type]
type (get-in db path)]
type (get-in db path)
errors (get-in db [:validation-errors current-chat-id])
custom-errors (get-in db [:custom-validation-errors current-chat-id])
validation-height (if (or (seq errors) (seq custom-errors))
request-info-height
0)]
(+ validation-height
(if (= :response type)
minimum-suggestion-height
input-height)))
input-height))))
(register-handler :animate-show-response
;[(after #(dispatch [:command-edit-mode]))]

View File

@ -183,5 +183,6 @@
(register-handler ::set-validation-error
(after #(dispatch [:fix-response-height]))
(fn [db [_ chat-id error]]
(assoc-in db [:validation-errors chat-id] [error])))

View File

@ -1,9 +1,10 @@
(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
{:background-color :red
:height 61
:height constants/request-info-height
:padding-left 16
:padding-top 14})

View File

@ -20,12 +20,11 @@
[validation-messages [:validation-errors]
custom-errors [:custom-validation-errors]
command? [:command?]]
(when (and command?
(or (seq validation-messages)
(seq custom-errors)))
[c/scroll-view
[c/view
(cond (seq custom-errors)
(vec (concat [c/view] custom-errors))
(seq validation-messages)
[messages-list validation-messages])]))
[messages-list validation-messages]
:else nil)])

View File

@ -11,8 +11,7 @@
[status-im.chat.views.command :as command]
[status-im.chat.styles.message-input :as st]
[status-im.chat.styles.plain-message :as st-message]
[status-im.chat.styles.response :as st-response]
[status-im.chat.views.command-validation :as cv]))
[status-im.chat.styles.response :as st-response]))
(defn send-button [{:keys [on-press accessibility-label]}]
[touchable-highlight {:on-press on-press
@ -56,7 +55,6 @@
input-command [:get-chat-command-content]
valid-plain-message? [:valid-plain-message?]]
[view st/input-container
[cv/validation-messages]
[view st/input-view
[plain-message/commands-button]
[message-input-container

View File

@ -15,7 +15,8 @@
[status-im.chat.styles.dragdown :as ddst]
[status-im.components.animation :as anim]
[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 []
[view st/drag-container
@ -83,8 +84,7 @@
(defview placeholder []
[suggestions [:get-content-suggestions]]
(when (seq suggestions)
[view st/input-placeholder]))
[view st/input-placeholder])
(defview response-suggestions-view []
[suggestions [:get-content-suggestions]]
@ -95,4 +95,5 @@
[container response-height
[request-info response-height]
[response-suggestions-view]
[cv/validation-messages]
[placeholder]]))

View File

@ -11,4 +11,4 @@
(defn register-handler
([name handler] (register-handler name nil handler))
([name middleware handler]
(re-core/register-handler name [debug middleware] handler)))
(re-core/register-handler name [#_debug middleware] handler)))