Paste button (#15002)

* Paste button

* Lint fix

* str -> string

* Removing of redundant stuff

* Style fixes

* Style fixes

* Style fixes (android)

* Style fixes (android)

* The last style fix

* Styles

* Lint fix
This commit is contained in:
Alexander 2023-02-21 13:42:22 +01:00 committed by GitHub
parent c4aef97a6d
commit 888bf12856
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 57 additions and 32 deletions

View File

@ -74,26 +74,15 @@
:style {:margin-left 4 :style {:margin-left 4
:color colors/danger-50}}) :color colors/danger-50}})
(defn text-input (defn text-input-container
[error?] [error?]
{:accessibility-label :enter-contact-code-input {:style {:padding-top 1
:auto-capitalize :none
:placeholder-text-color (colors/theme-colors
colors/neutral-40
colors/neutral-50)
:multiline true
:style
(merge typography/monospace
typography/paragraph-1
{:padding-top 8
:padding-left 12 :padding-left 12
:padding-right 12 :padding-right 7
:padding-bottom 8 :padding-bottom 7
:margin-right 10 :margin-right 10
:flex 1 :flex 1
:color (colors/theme-colors :flex-direction :row
colors/black
colors/white)
:background-color (colors/theme-colors :background-color (colors/theme-colors
colors/white colors/white
colors/neutral-95) colors/neutral-95)
@ -103,7 +92,33 @@
colors/danger-50-opa-40 colors/danger-50-opa-40
(colors/theme-colors (colors/theme-colors
colors/neutral-20 colors/neutral-20
colors/neutral-80))})}) colors/neutral-80))}})
(defn text-input
[]
{:accessibility-label :enter-contact-code-input
:auto-capitalize :none
: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 button-paste
{:type :outline
:size 24
:style {:margin-top 6}})
(defn button-close (defn button-close
[] []

View File

@ -1,12 +1,15 @@
(ns status-im2.contexts.add-new-contact.views (ns status-im2.contexts.add-new-contact.views
(:require [quo2.core :as quo] (:require
[react-native.core :as rn] [clojure.string :as string]
[status-im.react-native.resources :as resources] [quo2.core :as quo]
[status-im.qr-scanner.core :as qr-scanner] [react-native.core :as rn]
[status-im2.contexts.add-new-contact.style :as style] [react-native.clipboard :as clipboard]
[utils.debounce :as debounce] [status-im.react-native.resources :as resources]
[utils.i18n :as i18n] [status-im.qr-scanner.core :as qr-scanner]
[utils.re-frame :as rf])) [status-im2.contexts.add-new-contact.style :as style]
[utils.debounce :as debounce]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
(defn new-contact (defn new-contact
[] []
@ -34,13 +37,20 @@
[quo/text (style/text-description) [quo/text (style/text-description)
(i18n/label :t/ens-or-chat-key)] (i18n/label :t/ens-or-chat-key)]
[rn/view style/container-text-input [rn/view style/container-text-input
[rn/text-input [rn/view (style/text-input-container error?)
(merge (style/text-input error?) [rn/text-input
{:default-value input (merge (style/text-input)
:placeholder (i18n/label :t/type-some-chat-key) {:default-value input
:on-change-text #(debounce/debounce-and-dispatch :placeholder (i18n/label :t/type-some-chat-key)
[:contacts/set-new-identity %] :on-change-text #(debounce/debounce-and-dispatch
600)})] [:contacts/set-new-identity %]
600)})]
(when (string/blank? input)
[quo/button
(merge style/button-paste
{:on-press (fn []
(clipboard/get-string #(rf/dispatch [:contacts/set-new-identity %])))})
(i18n/label :t/paste)])]
[quo/button [quo/button
(merge style/button-qr (merge style/button-qr
{:on-press #(rf/dispatch [::qr-scanner/scan-code {:on-press #(rf/dispatch [::qr-scanner/scan-code