mirror of
https://github.com/status-im/status-react.git
synced 2025-01-15 21:44:33 +00:00
adding error for a field defined with range that is out of range on extensions
Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
parent
f3aa376d16
commit
287e097471
@ -1,8 +1,12 @@
|
|||||||
(ns status-im.extensions.capacities.components
|
(ns status-im.extensions.capacities.components
|
||||||
(:require [status-im.ui.components.react :as react]
|
(:require
|
||||||
|
[clojure.string :as string]
|
||||||
|
[reagent.core :as reagent]
|
||||||
|
[status-im.ui.components.react :as react]
|
||||||
[status-im.chat.commands.impl.transactions :as transactions]
|
[status-im.chat.commands.impl.transactions :as transactions]
|
||||||
[status-im.ui.components.button.view :as button]
|
[status-im.ui.components.button.view :as button]
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
|
[status-im.i18n :as i18n]
|
||||||
[status-im.utils.platform :as platform]
|
[status-im.utils.platform :as platform]
|
||||||
[status-im.ui.components.list.views :as list]
|
[status-im.ui.components.list.views :as list]
|
||||||
[status-im.ui.components.checkbox.view :as checkbox]
|
[status-im.ui.components.checkbox.view :as checkbox]
|
||||||
@ -25,10 +29,17 @@
|
|||||||
(js/clearTimeout id))
|
(js/clearTimeout id))
|
||||||
(reset! current (js/setTimeout #(on-input-change-text on-change value) delay)))
|
(reset! current (js/setTimeout #(on-input-change-text on-change value) delay)))
|
||||||
|
|
||||||
(defn input [{:keys [keyboard-type style error on-change change-delay placeholder placeholder-text-color selection-color
|
(defn- in-range [n start end]
|
||||||
|
(or (string/blank? n) (and (nil? start) (nil? end)) (and (< n end) (> n start))))
|
||||||
|
|
||||||
|
(defn input [{:keys [keyboard-type style error min max on-change change-delay placeholder placeholder-text-color selection-color
|
||||||
auto-focus on-submit default-value]}]
|
auto-focus on-submit default-value]}]
|
||||||
|
|
||||||
|
(let [input-range (reagent/atom nil)]
|
||||||
|
(fn []
|
||||||
[react/view
|
[react/view
|
||||||
[react/text-input (merge {:placeholder placeholder}
|
[react/text-input (merge {:placeholder placeholder}
|
||||||
|
{:on-change-text #(reset! input-range %)}
|
||||||
(when placeholder-text-color {:placeholder-text-color placeholder-text-color})
|
(when placeholder-text-color {:placeholder-text-color placeholder-text-color})
|
||||||
(when selection-color {:selection-color selection-color})
|
(when selection-color {:selection-color selection-color})
|
||||||
(when style {:style style})
|
(when style {:style style})
|
||||||
@ -43,8 +54,12 @@
|
|||||||
(let [current (atom nil)]
|
(let [current (atom nil)]
|
||||||
#(on-input-change-text-delay current on-change % change-delay))
|
#(on-input-change-text-delay current on-change % change-delay))
|
||||||
#(on-input-change-text on-change %))}))]
|
#(on-input-change-text on-change %))}))]
|
||||||
|
|
||||||
|
(when-not (in-range @input-range, min, max)
|
||||||
|
[tooltip/tooltip (i18n/label :t/invalid-range {:min min :max max}) styles/error])
|
||||||
|
|
||||||
(when error
|
(when error
|
||||||
[tooltip/tooltip error (styles/error error)])])
|
[tooltip/tooltip error (styles/error error)])])))
|
||||||
|
|
||||||
(defn touchable-opacity [{:keys [style on-press]} & children]
|
(defn touchable-opacity [{:keys [style on-press]} & children]
|
||||||
(into [react/touchable-opacity (merge (when on-press {:on-press #(on-press {})})
|
(into [react/touchable-opacity (merge (when on-press {:on-press #(on-press {})})
|
||||||
@ -139,7 +154,7 @@
|
|||||||
'image {:data image :properties {:uri :string :source :string}}
|
'image {:data image :properties {:uri :string :source :string}}
|
||||||
'input {:data input :properties {:on-change :event :error :string :placeholder :string :keyboard-type :keyword
|
'input {:data input :properties {:on-change :event :error :string :placeholder :string :keyboard-type :keyword
|
||||||
:change-delay? :number :placeholder-text-color :any :selection-color :any
|
:change-delay? :number :placeholder-text-color :any :selection-color :any
|
||||||
:auto-focus? :boolean :on-submit :event :default-value :any}}
|
:auto-focus? :boolean :min :number :max :number :on-submit :event :default-value :any}}
|
||||||
'button {:data button :properties {:enabled :boolean :disabled :boolean :on-click :event}}
|
'button {:data button :properties {:enabled :boolean :disabled :boolean :on-click :event}}
|
||||||
'link {:data link :properties {:uri :string :text? :string :open-in? {:one-of #{:device :status}}}}
|
'link {:data link :properties {:uri :string :text? :string :open-in? {:one-of #{:device :status}}}}
|
||||||
'list {:data flat-list :properties {:data :vector :item-view :view :key? :keyword}}
|
'list {:data flat-list :properties {:data :vector :item-view :view :key? :keyword}}
|
||||||
|
@ -1023,6 +1023,7 @@
|
|||||||
"chaos-unicorn-day": "Chaos Unicorn Day",
|
"chaos-unicorn-day": "Chaos Unicorn Day",
|
||||||
"chaos-unicorn-day-details": "\uD83E\uDD84\uD83E\uDD84\uD83E\uDD84\uD83E\uDD84\uD83E\uDD84\uD83E\uDD84\uD83E\uDD84\uD83D\uDE80!",
|
"chaos-unicorn-day-details": "\uD83E\uDD84\uD83E\uDD84\uD83E\uDD84\uD83E\uDD84\uD83E\uDD84\uD83E\uDD84\uD83E\uDD84\uD83D\uDE80!",
|
||||||
"invalid-format": "Invalid format\nMust be {{format}}",
|
"invalid-format": "Invalid format\nMust be {{format}}",
|
||||||
|
"invalid-range": "Invalid format, must be between {{min}} and {{max}}",
|
||||||
"mailserver-format": "enode://{enode-id}:{password}@{ip-address}:{port}",
|
"mailserver-format": "enode://{enode-id}:{password}@{ip-address}:{port}",
|
||||||
"bootnode-format": "enode://{enode-id}@{ip-address}:{port}",
|
"bootnode-format": "enode://{enode-id}@{ip-address}:{port}",
|
||||||
"fetch-messages": "↓ Fetch messages",
|
"fetch-messages": "↓ Fetch messages",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user