forked from status-im/status-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[status-im#18817] Import private key: UI for key pair name
- Loading branch information
Showing
4 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
...ontexts/wallet/add_account/create_account/import_private_key/add_key_pair_name/style.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
(ns status-im.contexts.wallet.add-account.create-account.import-private-key.add-key-pair-name.style) | ||
|
||
(def top | ||
{:margin-top 2}) | ||
|
||
(def input | ||
{:padding-top 12 | ||
:padding-horizontal 20}) | ||
|
||
(def error | ||
{:padding-horizontal 20 | ||
:padding-vertical 8}) |
83 changes: 83 additions & 0 deletions
83
...contexts/wallet/add_account/create_account/import_private_key/add_key_pair_name/view.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
(ns status-im.contexts.wallet.add-account.create-account.import-private-key.add-key-pair-name.view | ||
(:require | ||
[quo.core :as quo] | ||
[react-native.core :as rn] | ||
[status-im.common.floating-button-page.view :as floating-button-page] | ||
[status-im.common.validation.general :as validators] | ||
[status-im.contexts.wallet.add-account.create-account.import-private-key.add-key-pair-name.style :as | ||
style] | ||
[utils.i18n :as i18n] | ||
[utils.re-frame :as rf])) | ||
|
||
|
||
(def keypair-name-max-length 15) | ||
(def keypair-name-min-length 5) | ||
|
||
(def error-messages | ||
{:too-long (i18n/label :t/key-name-error-length) | ||
:too-short (i18n/label :t/key-name-error-too-short {:count keypair-name-min-length}) | ||
:emoji (i18n/label :t/key-name-error-emoji) | ||
:special-char (i18n/label :t/key-name-error-special-char)}) | ||
|
||
(defn view | ||
[] | ||
(let [customization-color (rf/sub [:profile/customization-color]) | ||
[keypair-name set-keypair-name] (rn/use-state "") | ||
[error set-error] (rn/use-state) | ||
on-change-text (rn/use-callback | ||
(fn [value] | ||
(set-keypair-name value) | ||
(cond | ||
(validators/has-emojis? value) | ||
(set-error :emoji) | ||
|
||
(validators/has-special-characters? value) | ||
(set-error :special-char) | ||
|
||
(> (count value) keypair-name-max-length) | ||
(set-error :too-long) | ||
|
||
(and (seq value) (< (count value) keypair-name-min-length)) | ||
(set-error :too-short) | ||
|
||
:else (set-error nil)))) | ||
|
||
disabled? (or (some? error) (empty? keypair-name))] | ||
[rn/view {:flex 1} | ||
[floating-button-page/view | ||
{:customization-color customization-color | ||
:header [quo/page-nav | ||
{:background :white | ||
:type :no-title | ||
:icon-name :i/arrow-left | ||
:on-press prn}] | ||
:footer [quo/button | ||
{:customization-color customization-color | ||
:disabled? disabled? | ||
:on-press prn} | ||
(i18n/label :t/continue)]} | ||
[quo/page-top | ||
{:title "Key pair name" | ||
:description :text | ||
:description-text "Name key pair for your own personal reference" | ||
:container-style style/top}] | ||
[quo/input | ||
{:label "Key pair name" | ||
:placeholder "Collectibles account, Old vault...." | ||
:char-limit keypair-name-max-length | ||
:auto-focus true | ||
:container-style style/input | ||
:on-change-text on-change-text | ||
:error? error}] | ||
(when error | ||
[quo/info-message | ||
{:type :error | ||
:size :default | ||
:icon :i/info | ||
:container-style style/error} | ||
(get error-messages error)])]])) | ||
|
||
|
||
(comment | ||
(utils.re-frame/dispatch [:navigate-to :screen/wallet.add-key-pair-name]) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters