* Fix preview screen receiving wrong parameter * Fix input multiline style on iOS and counter label always showed * Fix icon metadata and wrong values passed to svg icons * Use quo/input in add contact sheet
This commit is contained in:
parent
495aee584e
commit
b6e2e8cba4
|
@ -13,37 +13,37 @@
|
||||||
(and (string? color)
|
(and (string? color)
|
||||||
(not (string/blank? color)))))
|
(not (string/blank? color)))))
|
||||||
|
|
||||||
|
(defn- image-icon-style
|
||||||
|
[{:keys [color no-color size container-style theme]}]
|
||||||
|
(cond-> {:width size
|
||||||
|
:height size}
|
||||||
|
(not no-color)
|
||||||
|
(assoc :tint-color
|
||||||
|
(if (and (string? color) (not (string/blank? color)))
|
||||||
|
color
|
||||||
|
(colors/theme-colors colors/neutral-100 colors/white theme)))
|
||||||
|
:always
|
||||||
|
(merge container-style)))
|
||||||
|
|
||||||
(defn memo-icon-fn
|
(defn memo-icon-fn
|
||||||
[{:keys [color color-2 no-color
|
[{:keys [color color-2 container-style size accessibility-label]
|
||||||
container-style size accessibility-label theme]
|
:or {accessibility-label :icon}
|
||||||
:or {accessibility-label :icon}}
|
:as props}
|
||||||
icon-name]
|
icon-name]
|
||||||
(let [size (or size 20)]
|
(let [size (or size 20)]
|
||||||
^{:key icon-name}
|
(with-meta
|
||||||
(if-let [svg-icon (icons.svg/get-icon icon-name size)]
|
(if-let [svg-icon (icons.svg/get-icon icon-name size)]
|
||||||
[svg-icon
|
[svg-icon
|
||||||
(cond-> {:size size
|
(cond-> {:size size
|
||||||
:accessibility-label accessibility-label
|
:accessibility-label accessibility-label
|
||||||
:style container-style}
|
:style container-style}
|
||||||
|
(and color (valid-color? color)) (assoc :color color)
|
||||||
(and color (valid-color? color))
|
(and color-2 (valid-color? color-2)) (assoc :color-2 color-2))]
|
||||||
(assoc :color color)
|
|
||||||
|
|
||||||
(and color-2 (valid-color? color-2))
|
|
||||||
(assoc :color-2 color-2))]
|
|
||||||
[rn/image
|
[rn/image
|
||||||
{:style
|
{:style (image-icon-style (assoc props :size size))
|
||||||
(merge {:width size
|
|
||||||
:height size}
|
|
||||||
|
|
||||||
(when (not no-color)
|
|
||||||
{:tint-color (if (and (string? color) (not (string/blank? color)))
|
|
||||||
color
|
|
||||||
(colors/theme-colors colors/neutral-100 colors/white theme))})
|
|
||||||
|
|
||||||
container-style)
|
|
||||||
:accessibility-label accessibility-label
|
:accessibility-label accessibility-label
|
||||||
:source (icons/icon-source (str (name icon-name) size))}])))
|
:source (icons/icon-source (str (name icon-name) size))}])
|
||||||
|
{:key icon-name})))
|
||||||
|
|
||||||
(def ^:private themed-icon (memoize (quo.theme/with-theme memo-icon-fn)))
|
(def ^:private themed-icon (memoize (quo.theme/with-theme memo-icon-fn)))
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,7 @@
|
||||||
:border-radius (if small? 10 12)
|
:border-radius (if small? 10 12)
|
||||||
:opacity (if disabled? 0.3 1)})
|
:opacity (if disabled? 0.3 1)})
|
||||||
|
|
||||||
|
|
||||||
(defn left-icon-container
|
(defn left-icon-container
|
||||||
[small?]
|
[small?]
|
||||||
{:margin-left (if small? 0 4)
|
{:margin-left (if small? 0 4)
|
||||||
|
@ -84,15 +85,21 @@
|
||||||
|
|
||||||
(defn input
|
(defn input
|
||||||
[colors-by-status small? multiple-lines? weight]
|
[colors-by-status small? multiple-lines? weight]
|
||||||
(let [base-props (assoc (text/text-style {:size :paragraph-1 :weight (or weight :regular)})
|
(let [padding (if small? 4 8)
|
||||||
|
base-props (assoc (text/text-style {:size :paragraph-1 :weight (or weight :regular)})
|
||||||
:flex 1
|
:flex 1
|
||||||
:padding-right 0
|
:padding-right 0
|
||||||
:padding-left (if small? 4 8)
|
:padding-left padding
|
||||||
:padding-vertical (if small? 4 8)
|
:padding-top padding
|
||||||
|
:padding-bottom padding
|
||||||
:color (:text colors-by-status))]
|
:color (:text colors-by-status))]
|
||||||
(if multiple-lines?
|
(if multiple-lines?
|
||||||
(assoc base-props :text-align-vertical :top)
|
(assoc base-props
|
||||||
(assoc base-props :height (if small? 30 38) :line-height nil))))
|
:text-align-vertical :top
|
||||||
|
:line-height 22)
|
||||||
|
(assoc base-props
|
||||||
|
:height (if small? 30 38)
|
||||||
|
:line-height nil))))
|
||||||
|
|
||||||
(defn right-icon-touchable-area
|
(defn right-icon-touchable-area
|
||||||
[small?]
|
[small?]
|
||||||
|
@ -108,7 +115,8 @@
|
||||||
(defn clear-icon
|
(defn clear-icon
|
||||||
[variant-colors]
|
[variant-colors]
|
||||||
{:size 20
|
{:size 20
|
||||||
:color (:clear-icon variant-colors)})
|
:color (:clear-icon variant-colors)
|
||||||
|
:color-2 colors/white})
|
||||||
|
|
||||||
(def texts-container
|
(def texts-container
|
||||||
{:flex-direction :row
|
{:flex-direction :row
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
(ns quo.components.inputs.input.view
|
(ns quo.components.inputs.input.view
|
||||||
(:require
|
(:require [oops.core :as oops]
|
||||||
[oops.core :as oops]
|
|
||||||
[quo.components.icon :as icon]
|
[quo.components.icon :as icon]
|
||||||
[quo.components.inputs.input.style :as style]
|
[quo.components.inputs.input.style :as style]
|
||||||
[quo.components.markdown.text :as text]
|
[quo.components.markdown.text :as text]
|
||||||
[quo.theme :as quo.theme]
|
[quo.theme :as quo.theme]
|
||||||
[react-native.core :as rn]
|
[react-native.core :as rn]
|
||||||
|
[react-native.platform :as platform]
|
||||||
[reagent.core :as reagent]))
|
[reagent.core :as reagent]))
|
||||||
|
|
||||||
(defn- label-&-counter
|
(defn- label-&-counter
|
||||||
[{:keys [label current-chars char-limit variant-colors]}]
|
[{:keys [label current-chars char-limit variant-colors]}]
|
||||||
(let [count-text (when char-limit (str current-chars "/" char-limit))]
|
|
||||||
[rn/view
|
[rn/view
|
||||||
{:accessibility-label :input-labels
|
{:accessibility-label :input-labels
|
||||||
:style style/texts-container}
|
:style style/texts-container}
|
||||||
|
@ -20,12 +19,14 @@
|
||||||
:weight :medium
|
:weight :medium
|
||||||
:size :paragraph-2}
|
:size :paragraph-2}
|
||||||
label]]
|
label]]
|
||||||
|
(when-let [count-text (some->> char-limit
|
||||||
|
(str current-chars "/"))]
|
||||||
[rn/view {:style style/counter-container}
|
[rn/view {:style style/counter-container}
|
||||||
[text/text
|
[text/text
|
||||||
{:style (style/counter-color current-chars char-limit variant-colors)
|
{:style (style/counter-color current-chars char-limit variant-colors)
|
||||||
:weight :regular
|
:weight :regular
|
||||||
:size :paragraph-2}
|
:size :paragraph-2}
|
||||||
count-text]]]))
|
count-text]])])
|
||||||
|
|
||||||
(defn- left-accessory
|
(defn- left-accessory
|
||||||
[{:keys [variant-colors small? icon-name]}]
|
[{:keys [variant-colors small? icon-name]}]
|
||||||
|
@ -56,16 +57,19 @@
|
||||||
(def ^:private custom-props
|
(def ^:private custom-props
|
||||||
"Custom properties that must be removed from properties map passed to InputText."
|
"Custom properties that must be removed from properties map passed to InputText."
|
||||||
[:type :blur? :theme :error? :right-icon :left-icon :disabled? :small? :button
|
[:type :blur? :theme :error? :right-icon :left-icon :disabled? :small? :button
|
||||||
:label :char-limit :on-char-limit-reach :icon-name :multiline? :on-focus :on-blur])
|
:label :char-limit :on-char-limit-reach :icon-name :multiline? :on-focus :on-blur
|
||||||
|
:container-style])
|
||||||
|
|
||||||
(defn- base-input
|
(defn- base-input
|
||||||
[{:keys [on-change-text on-char-limit-reach container-style weight]}]
|
[{:keys [on-change-text on-char-limit-reach weight]}]
|
||||||
(let [status (reagent/atom :default)
|
(let [status (reagent/atom :default)
|
||||||
internal-on-focus #(reset! status :focus)
|
internal-on-focus #(reset! status :focus)
|
||||||
internal-on-blur #(reset! status :default)
|
internal-on-blur #(reset! status :default)
|
||||||
multiple-lines? (reagent/atom false)
|
multiple-lines? (reagent/atom false)
|
||||||
set-multiple-lines! #(let [height (oops/oget % "nativeEvent.contentSize.height")]
|
set-multiple-lines! #(let [height (oops/oget % "nativeEvent.contentSize.height")
|
||||||
(if (> height 57)
|
;; In Android height comes with padding
|
||||||
|
min-height (if platform/android? 40 22)]
|
||||||
|
(if (> height min-height)
|
||||||
(reset! multiple-lines? true)
|
(reset! multiple-lines? true)
|
||||||
(reset! multiple-lines? false)))
|
(reset! multiple-lines? false)))
|
||||||
char-count (reagent/atom 0)
|
char-count (reagent/atom 0)
|
||||||
|
@ -76,7 +80,7 @@
|
||||||
(when (>= amount-chars char-limit)
|
(when (>= amount-chars char-limit)
|
||||||
(on-char-limit-reach amount-chars))))]
|
(on-char-limit-reach amount-chars))))]
|
||||||
(fn [{:keys [blur? theme error? right-icon left-icon disabled? small? button
|
(fn [{:keys [blur? theme error? right-icon left-icon disabled? small? button
|
||||||
label char-limit multiline? clearable? on-focus on-blur]
|
label char-limit multiline? clearable? on-focus on-blur container-style]
|
||||||
:as props}]
|
:as props}]
|
||||||
(let [status-kw (cond
|
(let [status-kw (cond
|
||||||
disabled? :disabled
|
disabled? :disabled
|
||||||
|
@ -92,8 +96,7 @@
|
||||||
:label label
|
:label label
|
||||||
:current-chars @char-count
|
:current-chars @char-count
|
||||||
:char-limit char-limit}])
|
:char-limit char-limit}])
|
||||||
[rn/view
|
[rn/view {:style (style/input-container colors-by-status small? disabled?)}
|
||||||
{:style (style/input-container colors-by-status small? disabled?)}
|
|
||||||
(when-let [{:keys [icon-name]} left-icon]
|
(when-let [{:keys [icon-name]} left-icon]
|
||||||
[left-accessory
|
[left-accessory
|
||||||
{:variant-colors variant-colors
|
{:variant-colors variant-colors
|
||||||
|
@ -160,7 +163,7 @@
|
||||||
- :icon-name - The name of an icon to display at the left of the input.
|
- :icon-name - The name of an icon to display at the left of the input.
|
||||||
- :error? - Boolean to specify it this input marks an error.
|
- :error? - Boolean to specify it this input marks an error.
|
||||||
- :disabled? - Boolean to specify if this input is disabled or not.
|
- :disabled? - Boolean to specify if this input is disabled or not.
|
||||||
- :clearable? - Booolean to specify if this input has a clear button at the end.
|
- :clearable? - Boolean to specify if this input has a clear button at the end.
|
||||||
- :on-clear - Function executed when the clear button is pressed.
|
- :on-clear - Function executed when the clear button is pressed.
|
||||||
- :button - Map containing `:on-press` & `:text` keys, if provided renders a button
|
- :button - Map containing `:on-press` & `:text` keys, if provided renders a button
|
||||||
- :label - A string to set as label for this input.
|
- :label - A string to set as label for this input.
|
||||||
|
|
|
@ -1,28 +1,16 @@
|
||||||
(ns status-im2.contexts.add-new-contact.style
|
(ns status-im2.contexts.add-new-contact.style
|
||||||
(:require
|
(:require [quo.foundations.colors :as colors]
|
||||||
[quo.foundations.colors :as colors]
|
|
||||||
[quo.foundations.typography :as typography]
|
|
||||||
[react-native.platform :as platform]
|
|
||||||
[react-native.safe-area :as safe-area]))
|
[react-native.safe-area :as safe-area]))
|
||||||
|
|
||||||
(defn container-outer
|
(defn container-outer
|
||||||
[]
|
[]
|
||||||
{:style {:flex 1
|
{:flex 1
|
||||||
:background-color (colors/theme-colors colors/white colors/neutral-95)
|
:background-color (colors/theme-colors colors/white colors/neutral-95)
|
||||||
:justify-content :space-between
|
:justify-content :space-between
|
||||||
:align-items :center
|
:align-items :center
|
||||||
:padding-vertical 16
|
:padding-horizontal 20})
|
||||||
:padding-horizontal 20
|
|
||||||
|
|
||||||
:border-radius 20}})
|
(def container-inner {:align-items :flex-start})
|
||||||
|
|
||||||
(def container-inner
|
|
||||||
{:style {:flex-direction :column
|
|
||||||
:align-items :flex-start}})
|
|
||||||
|
|
||||||
(def container-text-input
|
|
||||||
{:style {:flex-direction :row
|
|
||||||
:justify-content :space-between}})
|
|
||||||
|
|
||||||
(def container-invalid
|
(def container-invalid
|
||||||
{:style {:flex-direction :row
|
{:style {:flex-direction :row
|
||||||
|
@ -35,27 +23,21 @@
|
||||||
:weight :semi-bold
|
:weight :semi-bold
|
||||||
:style {:margin-top 32
|
:style {:margin-top 32
|
||||||
:margin-bottom 6
|
:margin-bottom 6
|
||||||
:color (colors/theme-colors
|
:color (colors/theme-colors colors/neutral-100 colors/white)}})
|
||||||
colors/neutral-100
|
|
||||||
colors/white)}})
|
|
||||||
|
|
||||||
(defn text-subtitle
|
(defn text-subtitle
|
||||||
[]
|
[]
|
||||||
{:size :paragraph-1
|
{:size :paragraph-1
|
||||||
:weight :regular
|
:weight :regular
|
||||||
:style {:margin-bottom 20
|
:style {:margin-bottom 20
|
||||||
:color (colors/theme-colors
|
:color (colors/theme-colors colors/neutral-100 colors/white)}})
|
||||||
colors/neutral-100
|
|
||||||
colors/white)}})
|
|
||||||
|
|
||||||
(defn text-description
|
(defn text-description
|
||||||
[]
|
[]
|
||||||
{:size :paragraph-2
|
{:size :paragraph-2
|
||||||
:weight :medium
|
:weight :medium
|
||||||
:style {:margin-bottom 6
|
:style {:margin-bottom 6
|
||||||
:color (colors/theme-colors
|
:color (colors/theme-colors colors/neutral-50 colors/neutral-40)}})
|
||||||
colors/neutral-50
|
|
||||||
colors/neutral-40)}})
|
|
||||||
|
|
||||||
(def icon-invalid
|
(def icon-invalid
|
||||||
{:size 16
|
{:size 16
|
||||||
|
@ -67,46 +49,14 @@
|
||||||
:style {:margin-left 4
|
:style {:margin-left 4
|
||||||
:color colors/danger-50}})
|
:color colors/danger-50}})
|
||||||
|
|
||||||
(defn text-input-container
|
(def input-and-scan-container
|
||||||
[invalid?]
|
{:flex-direction :row
|
||||||
{:style {:padding-top 1
|
:align-items :flex-start})
|
||||||
:padding-left 12
|
|
||||||
:padding-right 7
|
|
||||||
:padding-bottom 7
|
|
||||||
:margin-right 10
|
|
||||||
:flex 1
|
|
||||||
:flex-direction :row
|
|
||||||
:background-color (colors/theme-colors
|
|
||||||
colors/white
|
|
||||||
colors/neutral-95)
|
|
||||||
:border-width 1
|
|
||||||
:border-radius 12
|
|
||||||
:border-color (if invalid?
|
|
||||||
colors/danger-50-opa-40
|
|
||||||
(colors/theme-colors
|
|
||||||
colors/neutral-20
|
|
||||||
colors/neutral-80))}})
|
|
||||||
|
|
||||||
(defn text-input
|
(def scan-button-container
|
||||||
[]
|
{:margin-left 12
|
||||||
{:accessibility-label :enter-contact-code-input
|
:height 66
|
||||||
:auto-capitalize :none
|
:justify-content :flex-end})
|
||||||
:placeholder-text-color (colors/theme-colors
|
|
||||||
colors/neutral-40
|
|
||||||
colors/neutral-50)
|
|
||||||
:multiline true
|
|
||||||
:style
|
|
||||||
(merge typography/monospace
|
|
||||||
typography/paragraph-1
|
|
||||||
{:flex 1
|
|
||||||
:margin-right 5
|
|
||||||
:margin-top (if platform/android?
|
|
||||||
4
|
|
||||||
0)
|
|
||||||
:padding 0
|
|
||||||
:color (colors/theme-colors
|
|
||||||
colors/black
|
|
||||||
colors/white)})})
|
|
||||||
|
|
||||||
(def found-user
|
(def found-user
|
||||||
{:padding-top 16
|
{:padding-top 16
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
(ns status-im2.contexts.add-new-contact.views
|
(ns status-im2.contexts.add-new-contact.views
|
||||||
(:require
|
(:require [clojure.string :as string]
|
||||||
[clojure.string :as string]
|
|
||||||
[quo.core :as quo]
|
[quo.core :as quo]
|
||||||
[react-native.clipboard :as clipboard]
|
[react-native.clipboard :as clipboard]
|
||||||
[react-native.core :as rn]
|
[react-native.core :as rn]
|
||||||
|
@ -38,81 +37,93 @@
|
||||||
:style (style/found-user-key)}
|
:style (style/found-user-key)}
|
||||||
(address/get-shortened-compressed-key compressed-key)]]]])))
|
(address/get-shortened-compressed-key compressed-key)]]]])))
|
||||||
|
|
||||||
(defn new-contact
|
(defn- header
|
||||||
[]
|
[]
|
||||||
(let [clipboard (reagent/atom nil)
|
[:<>
|
||||||
default-value (reagent/atom nil)]
|
|
||||||
(fn []
|
|
||||||
(clipboard/get-string #(reset! clipboard %))
|
|
||||||
(let [{:keys [input scanned public-key ens state msg]}
|
|
||||||
(rf/sub [:contacts/new-identity])
|
|
||||||
customization-color (rf/sub [:profile/customization-color])
|
|
||||||
invalid? (= state :invalid)
|
|
||||||
show-paste-button? (and (not (string/blank? @clipboard))
|
|
||||||
(string/blank? @default-value)
|
|
||||||
(string/blank? input))]
|
|
||||||
[rn/keyboard-avoiding-view
|
|
||||||
{:style {:flex 1}}
|
|
||||||
[rn/touchable-without-feedback
|
|
||||||
{:on-press rn/dismiss-keyboard!}
|
|
||||||
[rn/view (style/container-outer)
|
|
||||||
[rn/view style/container-inner
|
|
||||||
[quo/button
|
[quo/button
|
||||||
{:type :grey
|
{:type :grey
|
||||||
:icon-only? true
|
:icon-only? true
|
||||||
:accessibility-label :new-contact-close-button
|
:accessibility-label :new-contact-close-button
|
||||||
:size 32
|
:size 32
|
||||||
:on-press
|
:on-press #(rf/dispatch [:navigate-back])}
|
||||||
(fn []
|
:i/close]
|
||||||
(reset! clipboard nil)
|
[quo/text (style/text-title) (i18n/label :t/add-a-contact)]
|
||||||
(reset! default-value nil)
|
[quo/text (style/text-subtitle) (i18n/label :t/find-your-friends)]])
|
||||||
(rf/dispatch [:contacts/clear-new-identity])
|
|
||||||
(rf/dispatch [:navigate-back]))} :i/close]
|
(defn- search-input
|
||||||
[quo/text (style/text-title)
|
[]
|
||||||
(i18n/label :t/add-a-contact)]
|
(reagent/with-let [input-value (reagent/atom nil)
|
||||||
[quo/text (style/text-subtitle)
|
input-ref (atom nil)
|
||||||
(i18n/label :t/find-your-friends)]
|
clear-input (fn []
|
||||||
[quo/text (style/text-description)
|
(reset! input-value nil)
|
||||||
(i18n/label :t/ens-or-chat-key)]
|
(rf/dispatch [:contacts/clear-new-identity]))
|
||||||
[rn/view style/container-text-input
|
paste-on-input #(clipboard/get-string
|
||||||
[rn/view (style/text-input-container invalid?)
|
(fn [clipboard-text]
|
||||||
[rn/text-input
|
(reset! input-value clipboard-text)
|
||||||
(merge (style/text-input)
|
(rf/dispatch [:contacts/set-new-identity clipboard-text nil])))]
|
||||||
{:default-value (or scanned @default-value input)
|
(let [{:keys [scanned]} (rf/sub [:contacts/new-identity])
|
||||||
:placeholder (i18n/label :t/type-some-chat-key)
|
empty-input? (and (string/blank? @input-value)
|
||||||
:on-change-text (fn [v]
|
(string/blank? scanned))]
|
||||||
(reset! default-value v)
|
[rn/view {:style style/input-and-scan-container}
|
||||||
(debounce/debounce-and-dispatch
|
[quo/input
|
||||||
[:contacts/set-new-identity v nil]
|
{:accessibility-label :enter-contact-code-input
|
||||||
600))
|
:ref #(reset! input-ref %)
|
||||||
|
:container-style {:flex 1}
|
||||||
|
:auto-capitalize :none
|
||||||
|
:multiline? true
|
||||||
:blur-on-submit true
|
:blur-on-submit true
|
||||||
:return-key-type :done})]
|
:return-key-type :done
|
||||||
(when show-paste-button?
|
:label (i18n/label :t/ens-or-chat-key)
|
||||||
[quo/button
|
:placeholder (i18n/label :t/type-some-chat-key)
|
||||||
{:type :outline
|
:clearable? (not empty-input?)
|
||||||
:size 24
|
:on-clear clear-input
|
||||||
:container-style {:margin-top 6}
|
:button (when empty-input?
|
||||||
:on-press
|
{:on-press paste-on-input
|
||||||
(fn []
|
:text (i18n/label :t/paste)})
|
||||||
(reset! default-value @clipboard)
|
;; NOTE: `scanned` has priority over `@input-value`, we clean it when the input
|
||||||
(rf/dispatch
|
;; is updated so that it's `nil` and `@input-value` is shown.
|
||||||
[:contacts/set-new-identity @clipboard nil]))}
|
;; To fastly clean it, we use `dispatch-sync`.
|
||||||
(i18n/label :t/paste)])]
|
;; This call could be avoided if `::qr-scanner/scan-code` were able to receive a
|
||||||
|
;; callback function, not only a re-frame event as callback.
|
||||||
|
:value (or scanned @input-value)
|
||||||
|
:on-change-text (fn [new-text]
|
||||||
|
(reset! input-value new-text)
|
||||||
|
(as-> [:contacts/set-new-identity new-text nil] $
|
||||||
|
(if (string/blank? scanned)
|
||||||
|
(debounce/debounce-and-dispatch $ 600)
|
||||||
|
(rf/dispatch-sync $))))}]
|
||||||
|
[rn/view {:style style/scan-button-container}
|
||||||
[quo/button
|
[quo/button
|
||||||
{:type :outline
|
{:type :outline
|
||||||
:icon-only? true
|
:icon-only? true
|
||||||
:size 40
|
:size 40
|
||||||
:on-press #(rf/dispatch
|
:on-press #(rf/dispatch [::qr-scanner/scan-code
|
||||||
[::qr-scanner/scan-code
|
|
||||||
{:handler :contacts/qr-code-scanned}])}
|
{:handler :contacts/qr-code-scanned}])}
|
||||||
:i/scan]]
|
:i/scan]]])
|
||||||
(when invalid?
|
(finally
|
||||||
|
(rf/dispatch [:contacts/clear-new-identity]))))
|
||||||
|
|
||||||
|
(defn- invalid-text
|
||||||
|
[message]
|
||||||
[rn/view style/container-invalid
|
[rn/view style/container-invalid
|
||||||
[quo/icon :i/alert style/icon-invalid]
|
[quo/icon :i/alert style/icon-invalid]
|
||||||
[quo/text style/text-invalid
|
[quo/text style/text-invalid
|
||||||
(i18n/label (or msg :t/invalid-ens-or-key))]])
|
(i18n/label (or message :t/invalid-ens-or-key))]])
|
||||||
(when (= state :valid)
|
|
||||||
[found-contact public-key])]
|
(defn new-contact
|
||||||
|
[]
|
||||||
|
(let [{:keys [public-key ens state msg]} (rf/sub [:contacts/new-identity])
|
||||||
|
customization-color (rf/sub [:profile/customization-color])]
|
||||||
|
[rn/keyboard-avoiding-view {:style {:flex 1}}
|
||||||
|
[rn/touchable-without-feedback {:on-press rn/dismiss-keyboard!}
|
||||||
|
[rn/view {:style (style/container-outer)}
|
||||||
|
[rn/view {:style style/container-inner}
|
||||||
|
[header]
|
||||||
|
[search-input]
|
||||||
|
(case state
|
||||||
|
:invalid [invalid-text msg]
|
||||||
|
:valid [found-contact public-key]
|
||||||
|
nil)]
|
||||||
[quo/button
|
[quo/button
|
||||||
{:type :primary
|
{:type :primary
|
||||||
:customization-color customization-color
|
:customization-color customization-color
|
||||||
|
@ -121,11 +132,9 @@
|
||||||
:accessibility-label :new-contact-button
|
:accessibility-label :new-contact-button
|
||||||
:icon-left :i/profile
|
:icon-left :i/profile
|
||||||
:disabled? (not= state :valid)
|
:disabled? (not= state :valid)
|
||||||
:on-press
|
:on-press (fn []
|
||||||
(fn []
|
|
||||||
(reset! clipboard nil)
|
|
||||||
(reset! default-value nil)
|
|
||||||
(rf/dispatch [:contacts/clear-new-identity])
|
|
||||||
(rf/dispatch [:navigate-back])
|
(rf/dispatch [:navigate-back])
|
||||||
(rf/dispatch [:chat.ui/show-profile public-key ens]))}
|
(rf/dispatch [:chat.ui/show-profile public-key ens])
|
||||||
(i18n/label :t/view-profile)]]]]))))
|
(js/setTimeout #(rf/dispatch [:contacts/clear-new-identity])
|
||||||
|
600))}
|
||||||
|
(i18n/label :t/view-profile)]]]]))
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
:type :boolean}
|
:type :boolean}
|
||||||
{:key :small?
|
{:key :small?
|
||||||
:type :boolean}
|
:type :boolean}
|
||||||
{:key :multiline
|
{:key :multiline?
|
||||||
:type :boolean}
|
:type :boolean}
|
||||||
{:key :button
|
{:key :button
|
||||||
:type :boolean}
|
:type :boolean}
|
||||||
|
@ -53,7 +53,8 @@
|
||||||
(fn []
|
(fn []
|
||||||
(let [blank-label? (string/blank? (:label @state))]
|
(let [blank-label? (string/blank? (:label @state))]
|
||||||
[preview/preview-container
|
[preview/preview-container
|
||||||
{:state state
|
{:component-container-style {:margin-bottom 200}
|
||||||
|
:state state
|
||||||
:descriptor descriptor
|
:descriptor descriptor
|
||||||
:blur? (:blur? @state)
|
:blur? (:blur? @state)
|
||||||
:show-blur-background? true}
|
:show-blur-background? true}
|
||||||
|
|
|
@ -81,3 +81,5 @@
|
||||||
(def dispatch re-frame/dispatch)
|
(def dispatch re-frame/dispatch)
|
||||||
|
|
||||||
(def reg-fx re-frame/reg-fx)
|
(def reg-fx re-frame/reg-fx)
|
||||||
|
|
||||||
|
(def dispatch-sync re-frame/dispatch-sync)
|
||||||
|
|
Loading…
Reference in New Issue