|
22 | 22 | [status-im.utils.identicon :as identicon]
|
23 | 23 | [status-im.ui.components.keyboard-avoid-presentation :as kb-presentation]
|
24 | 24 | [status-im.ui.components.animation :as animation]
|
25 |
| - [status-im.ui.screens.chat.photos :as photos]) |
| 25 | + [status-im.ui.screens.chat.photos :as photos] |
| 26 | + [status-im.utils.db :as utils.db]) |
26 | 27 | (:require-macros [status-im.utils.views :as views]))
|
27 | 28 |
|
28 | 29 | (defn- render-row [row]
|
|
45 | 46 | icon])
|
46 | 47 |
|
47 | 48 | (defn- input-icon
|
48 |
| - [state new-contact? entered-nickname] |
| 49 | + [state new-contact? entered-nickname blocked?] |
49 | 50 | (let [icon (if new-contact? :main-icons/add :main-icons/arrow-right)]
|
50 |
| - (case state |
51 |
| - :searching |
| 51 | + (cond |
| 52 | + (= state :searching) |
52 | 53 | [icon-wrapper colors/gray
|
53 | 54 | [react/activity-indicator {:color colors/white-persist}]]
|
54 | 55 |
|
55 |
| - :valid |
| 56 | + (and (= state :valid) (not blocked?)) |
56 | 57 | [react/touchable-highlight
|
57 | 58 | {:on-press #(debounce/dispatch-and-chill [:contact.ui/contact-code-submitted new-contact? entered-nickname] 3000)}
|
58 | 59 | [icon-wrapper colors/blue
|
59 | 60 | [icons/icon icon {:color colors/white-persist}]]]
|
60 | 61 |
|
| 62 | + :else |
61 | 63 | [icon-wrapper colors/gray
|
62 | 64 | [icons/icon icon {:color colors/white-persist}]])))
|
63 | 65 |
|
|
251 | 253 | :return-key-type :done
|
252 | 254 | :auto-correct false}])
|
253 | 255 |
|
254 |
| -(views/defview new-contact [] |
255 |
| - (views/letsubs [{:keys [state ens-name public-key error]} [:contacts/new-identity] |
256 |
| - entered-nickname (reagent/atom "")] |
| 256 | +(defn new-contact [] |
| 257 | + (let [{:keys [state ens-name public-key error]} @(re-frame/subscribe [:contacts/new-identity]) |
| 258 | + entered-nickname (reagent/atom "") |
| 259 | + blocked? (and |
| 260 | + (utils.db/valid-public-key? (or public-key "")) |
| 261 | + @(re-frame/subscribe [:contacts/contact-blocked? public-key]))] |
257 | 262 | [react/view {:style {:flex 1}}
|
258 | 263 | [topbar/topbar
|
259 | 264 | {:title (i18n/label :t/new-contact)
|
|
284 | 289 | :return-key-type :go}]]
|
285 | 290 | [react/view {:justify-content :center
|
286 | 291 | :align-items :center}
|
287 |
| - [input-icon state true @entered-nickname]]] |
| 292 | + [input-icon state true @entered-nickname blocked?]]] |
288 | 293 | [react/view {:min-height 30 :justify-content :flex-end :margin-bottom 16}
|
289 | 294 | [quo/text {:style {:margin-horizontal 16}
|
290 | 295 | :size :small
|
|
0 commit comments