validation messages styles

Former-commit-id: 4e5838391c
This commit is contained in:
Roman Volosovskyi 2016-07-08 11:30:42 +03:00
parent f5ff014b9d
commit 69b1aaebe1
6 changed files with 41 additions and 18 deletions

View File

@ -5,7 +5,8 @@
[status-im.models.commands :as commands] [status-im.models.commands :as commands]
[clojure.string :as str] [clojure.string :as str]
[status-im.commands.utils :as cu] [status-im.commands.utils :as cu]
[status-im.utils.phone-number :as pn])) [status-im.utils.phone-number :as pn]
[status-im.i18n :as i18n]))
(def command-prefix "c ") (def command-prefix "c ")
@ -168,8 +169,8 @@
(dispatch [::finish-command-staging chat-id]) (dispatch [::finish-command-staging chat-id])
(dispatch [::set-validation-error (dispatch [::set-validation-error
chat-id chat-id
{:title "Phobe number" {:title (i18n/label :t/phone-number)
:description "Wrong phone number"}])))}) :description (i18n/label :t/invalid-phone)}])))})
(defn validator [name] (defn validator [name]
(validation-handlers (keyword name))) (validation-handlers (keyword name)))

View File

@ -1 +1,16 @@
(ns status-im.chat.styles.command-validation) (ns status-im.chat.styles.command-validation
(:require [status-im.components.styles :as st]))
(def messages-container
{:background-color :red
:height 61
:padding-left 16
:padding-top 14})
(def title
{:color :white
:font-size 12
:font-family st/font})
(def description
(assoc title :opacity 0.69))

View File

@ -4,27 +4,28 @@
[status-im.chat.styles.command-validation :as st] [status-im.chat.styles.command-validation :as st]
[status-im.utils.listview :as lw])) [status-im.utils.listview :as lw]))
(defn error [{:keys [title description]}] (defn message [{:keys [title description]}]
(c/list-item (c/list-item
[c/view [c/view
[c/text title] [c/text st/title title]
[c/text description]])) [c/text st/description description]]))
(defn errors-list [errors] (defn messages-list [errors]
[c/list-view {:renderRow error [c/list-view {:renderRow message
:keyboardShouldPersistTaps true :keyboardShouldPersistTaps true
:dataSource (lw/to-datasource errors)}]) :dataSource (lw/to-datasource errors)
:style st/messages-container}])
(defview errors [] (defview validation-messages []
[errors [:validation-errors] [validation-messages [:validation-errors]
custom-errors [:custom-validation-errors] custom-errors [:custom-validation-errors]
command? [:command?]] command? [:command?]]
(when (and command? (when (and command?
(or (seq errors) (or (seq validation-messages)
(seq custom-errors))) (seq custom-errors)))
[c/scroll-view {:background-color :red} [c/scroll-view
(cond (seq custom-errors) (cond (seq custom-errors)
(vec (concat [c/view] custom-errors)) (vec (concat [c/view] custom-errors))
(seq errors) (seq validation-messages)
[errors-list errors])])) [messages-list validation-messages])]))

View File

@ -56,7 +56,7 @@
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/errors] [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

View File

@ -17,7 +17,11 @@
(def app-registry (get-react-property "AppRegistry")) (def app-registry (get-react-property "AppRegistry"))
(def navigator (get-class "Navigator")) (def navigator (get-class "Navigator"))
(def text (get-class "Text")) (def text-class (get-class "Text"))
(defn text
([s] [text-class s])
([{:keys [style] :as opts} s]
[text-class (if style opts {:style opts}) s]))
(def view (get-class "View")) (def view (get-class "View"))
(def image (get-class "Image")) (def image (get-class "Image"))
(def touchable-highlight-class (get-class "TouchableHighlight")) (def touchable-highlight-class (get-class "TouchableHighlight"))

View File

@ -136,4 +136,6 @@
;users ;users
:add-account "Add account" :add-account "Add account"
;validation
:invalid-phone "Invalid phone number"
}) })