-
Notifications
You must be signed in to change notification settings - Fork 979
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#18817] Import private key: UI for key pair name
Move files Fix label Enable feature and fix auto-focus Add events and subs
- Loading branch information
Showing
10 changed files
with
197 additions
and
49 deletions.
There are no files selected for viewing
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
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}) |
77 changes: 77 additions & 0 deletions
77
...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,77 @@ | ||
(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]) | ||
key-pair-name (rf/sub [:wallet.import-private-key/key-pair-name]) | ||
[error set-error] (rn/use-state) | ||
on-change-text (rn/use-callback | ||
(fn [value] | ||
(rf/dispatch [:wallet.import-private-key/set-key-pair-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? key-pair-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 #(rf/dispatch [:navigate-back])}] | ||
:footer [quo/button | ||
{:customization-color customization-color | ||
:disabled? disabled? | ||
:on-press prn} | ||
(i18n/label :t/continue)]} | ||
[quo/page-top | ||
{:title (i18n/label :t/key-pair-name) | ||
:description :text | ||
:description-text (i18n/label :t/key-pair-name-desc) | ||
:container-style style/top}] | ||
[quo/input | ||
{:label (i18n/label :t/key-pair-name) | ||
:placeholder (i18n/label :t/key-pair-name-placeholder) | ||
: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)])]])) |
2 changes: 1 addition & 1 deletion
2
...ate_account/import_private_key/style.cljs → ...import_private_key/private_key/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
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
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
20 changes: 20 additions & 0 deletions
20
src/status_im/subs/wallet/add_account/import_private_key.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,20 @@ | ||
(ns status-im.subs.wallet.add-account.import-private-key | ||
(:require [re-frame.core :as rf])) | ||
|
||
(rf/reg-sub | ||
:wallet.import-private-key/private-key | ||
:<- [:wallet/ui] | ||
(fn [ui _] | ||
(get-in ui [:import-private-key :private-key]))) | ||
|
||
(rf/reg-sub | ||
:wallet.import-private-key/public-address | ||
:<- [:wallet/ui] | ||
(fn [ui _] | ||
(get-in ui [:import-private-key :public-address]))) | ||
|
||
(rf/reg-sub | ||
:wallet.import-private-key/key-pair-name | ||
:<- [:wallet/ui] | ||
(fn [ui _] | ||
(get-in ui [:import-private-key :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