Skip to content

Commit

Permalink
[#8968] custom seed phrase popover
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitryn committed Sep 18, 2019
1 parent 4f7cb54 commit d6ea8fd
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 7 deletions.
18 changes: 15 additions & 3 deletions src/status_im/multiaccounts/recover/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
[status-im.multiaccounts.create.core :as multiaccounts.create]
[status-im.multiaccounts.db :as db]
[status-im.native-module.core :as status]
[status-im.popover.core :as popover]
[status-im.ui.screens.navigation :as navigation]
[status-im.utils.fx :as fx]
[status-im.utils.security :as security]
Expand Down Expand Up @@ -153,9 +154,20 @@
{:events [::enter-phrase-input-submitted ::enter-phrase-next-pressed]}
[{:keys [db] :as cofx}]
(let [{:keys [password passphrase]} (:multiaccounts/recover db)]
(when (mnemonic/valid-length? passphrase)
{::import-multiaccount {:passphrase passphrase
:password password}})))
(if (check-phrase-warnings passphrase)
(popover/show-popover cofx {:view :custom-seed-phrase})
(when (mnemonic/valid-length? passphrase)
{::import-multiaccount {:passphrase passphrase
:password password}}))))

(fx/defn continue-to-import-mnemonic
{:events [::continue-pressed]}
[{:keys [db] :as cofx}]
(let [{:keys [password passphrase]} (:multiaccounts/recover db)]
(fx/merge cofx
{::import-multiaccount {:passphrase passphrase
:password password}}
(popover/hide-popover))))

(fx/defn cancel-pressed
{:events [::cancel-pressed]}
Expand Down
55 changes: 53 additions & 2 deletions src/status_im/ui/screens/multiaccounts/recover/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,49 @@
[status-im.utils.utils :as utils]
[status-im.constants :as constants]
[status-im.ui.components.list-item.views :as list-item]
[status-im.utils.platform :as platform]))
[status-im.utils.platform :as platform]
[status-im.react-native.resources :as resources]
[status-im.ui.components.icons.vector-icons :as icons]))

(defview custom-seed-phrase []
[react/view
[react/view {:margin-top 24 :margin-horizontal 24 :align-items :center}
[react/view {:background-color colors/blue-light :width 32 :height 32 :border-radius 16
:align-items :center :justify-content :center}
[icons/icon :main-icons/help {:color colors/blue}]]
[react/text {:style {:typography :title-bold
:margin-top 16
:margin-bottom 8}}
(i18n/label :t/custom-seed-phrase)]
[react/view {:flex-wrap :wrap
:flex-direction :row
:justify-content :center
:text-align :center
:width 320}
[react/text {:style {:color colors/gray
:text-align :center
:line-height 22}}
(i18n/label :t/custom-seed-phrase-text-1)]
[react/text {:style {:color colors/black
:text-align :center
:line-height 22}}
(i18n/label :t/custom-seed-phrase-text-2)]
[react/text {:style {:color colors/gray
:text-align :center
:line-height 22}}
(i18n/label :t/custom-seed-phrase-text-3)]
[react/text {:style {:color colors/black
:text-align :center
:line-height 22}}
(i18n/label :t/custom-seed-phrase-text-4)]]
[react/view {:margin-bottom 24 :margin-horizontal 24 :align-items :center}
[components.common/button {:on-press #(re-frame/dispatch [::multiaccounts.recover/continue-pressed])
:button-style {:margin-top 24}
:label (i18n/label :t/continue)}]
[components.common/button {:on-press #(re-frame/dispatch [:hide-popover])
:button-style {:margin-top 24}
:background? false
:label (i18n/label :t/cancel)}]]]])

(defn bottom-sheet-view []
[react/view {:flex 1 :flex-direction :row}
Expand All @@ -37,7 +79,16 @@
:title :t/recover-with-keycard
:disabled? (not config/hardwallet-enabled?)
:accessibility-label :recover-with-keycard-button
:icon :main-icons/keycard-logo
:icon [react/view {:border-width 1
:border-radius 20
:border-color colors/blue-light
:background-color colors/blue-light
:justify-content :center
:align-items :center
:width 40
:height 40}
[react/image {:source (resources/get-image :keycard-logo-blue)
:style {:width 24 :height 24}}]]
:on-press #(re-frame/dispatch [::hardwallet/recover-with-keycard-pressed])}])]])

(def bottom-sheet
Expand Down
6 changes: 5 additions & 1 deletion src/status_im/ui/screens/popover/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
[re-frame.core :as re-frame]
[status-im.ui.screens.wallet.signing-phrase.views :as signing-phrase]
[status-im.ui.screens.wallet.request.views :as request]
[status-im.ui.screens.profile.user.views :as profile.user]))
[status-im.ui.screens.profile.user.views :as profile.user]
[status-im.ui.screens.multiaccounts.recover.views :as multiaccounts.recover]))

(defn hide-panel-anim
[bottom-anim-value alpha-value window-height]
Expand Down Expand Up @@ -98,6 +99,9 @@
(= :share-chat-key view)
[profile.user/share-chat-key]

(= :custom-seed-phrase view)
[multiaccounts.recover/custom-seed-phrase]

:else
[view])]]]]])))})))

Expand Down
7 changes: 6 additions & 1 deletion translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1087,5 +1087,10 @@
"your-data-belongs-to-you": "If you lose your seed phrase you lose your data and funds",
"your-data-belongs-to-you-description": "Status can’t help you recover your multiaccount if you lose your seed phrase. You are in charge of the security of your data, and backing up your seed phrase is the best safeguard.",
"your-recovery-phrase": "Your seed phrase",
"your-recovery-phrase-description": "This is your seed phrase. You use it to prove that this is your wallet. You only get to see it once! Write it on paper and keep it in a secure place. You will need it if you lose or reinstall your wallet."
"your-recovery-phrase-description": "This is your seed phrase. You use it to prove that this is your wallet. You only get to see it once! Write it on paper and keep it in a secure place. You will need it if you lose or reinstall your wallet.",
"custom-seed-phrase": "Custom seed phrase",
"custom-seed-phrase-text-1": "This looks like a custom seed phrase and doesn't match the Status dictionary. This could also mean ",
"custom-seed-phrase-text-2": "some words are misspelled.",
"custom-seed-phrase-text-3": " If so, you'll end up creating a",
"custom-seed-phrase-text-4": " new account"
}

0 comments on commit d6ea8fd

Please sign in to comment.