validation messages styles
This commit is contained in:
parent
7c3c3d8008
commit
4e5838391c
|
@ -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)))
|
||||||
|
|
|
@ -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))
|
||||||
|
|
|
@ -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])]))
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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"))
|
||||||
|
|
|
@ -136,4 +136,6 @@
|
||||||
;users
|
;users
|
||||||
:add-account "Add account"
|
:add-account "Add account"
|
||||||
|
|
||||||
|
;validation
|
||||||
|
:invalid-phone "Invalid phone number"
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue