|
4 | 4 | [quo.theme :as quo.theme]
|
5 | 5 | [react-native.core :as rn]
|
6 | 6 | [reagent.core :as reagent]
|
7 |
| - [status-im.contexts.wallet.common.temp :as temp] |
8 | 7 | [status-im.contexts.wallet.create-account.new-keypair.check-your-backup.style :as style]
|
9 | 8 | [utils.i18n :as i18n]
|
10 | 9 | [utils.re-frame :as rf]))
|
|
31 | 30 |
|
32 | 31 | (defn- cheat-warning
|
33 | 32 | []
|
34 |
| - (let [{:keys [customization-color]} (rf/sub [:profile/profile])] |
| 33 | + (let [customization-color (rf/sub [:profile/customization-color])] |
35 | 34 | [:<>
|
36 | 35 | [quo/drawer-top {:title (i18n/label :t/do-not-cheat)}]
|
37 | 36 | [quo/text
|
|
62 | 61 |
|
63 | 62 | (defn- view-internal
|
64 | 63 | []
|
65 |
| - (let [random-indices (random-selection) |
66 |
| - quiz-index (reagent/atom 0) |
67 |
| - incorrect-count (reagent/atom 0) |
68 |
| - show-error? (reagent/atom false)] |
| 64 | + (let [random-indices (random-selection) |
| 65 | + quiz-index (reagent/atom 0) |
| 66 | + incorrect-count (reagent/atom 0) |
| 67 | + show-error? (reagent/atom false) |
| 68 | + {:keys [secret-phrase random-phrase]} (rf/sub [:wallet/create-account])] |
69 | 69 | (fn []
|
70 |
| - (let [current-word-index (get random-indices (min @quiz-index (dec questions-count))) |
71 |
| - current-word (get temp/secret-phrase current-word-index) |
72 |
| - [options-r-0 options-r-1] (random-words-with-string temp/random-words current-word) |
73 |
| - on-button-press (fn [word] |
74 |
| - (if (= word current-word) |
75 |
| - (do |
76 |
| - (reset! quiz-index (inc @quiz-index)) |
77 |
| - (reset! incorrect-count 0) |
78 |
| - (reset! show-error? false)) |
79 |
| - (do |
80 |
| - (when (> @incorrect-count 0) |
81 |
| - (rf/dispatch [:show-bottom-sheet |
82 |
| - {:content cheat-warning}])) |
83 |
| - (reset! incorrect-count (inc @incorrect-count)) |
84 |
| - (reset! show-error? true))))] |
| 70 | + (let [current-word-index (get random-indices |
| 71 | + (min @quiz-index (dec questions-count))) |
| 72 | + current-word (get secret-phrase current-word-index) |
| 73 | + [options-row-0 options-row-1] (random-words-with-string random-phrase current-word) |
| 74 | + on-button-press (fn [word] |
| 75 | + (if (= word current-word) |
| 76 | + (do |
| 77 | + (when (< @quiz-index questions-count) |
| 78 | + (reset! quiz-index (inc @quiz-index))) |
| 79 | + (reset! incorrect-count 0) |
| 80 | + (reset! show-error? false) |
| 81 | + (when (= @quiz-index questions-count) |
| 82 | + (rf/dispatch [:navigate-to |
| 83 | + :wallet-keypair-name]))) |
| 84 | + (do |
| 85 | + (when (> @incorrect-count 0) |
| 86 | + (rf/dispatch [:show-bottom-sheet |
| 87 | + {:content cheat-warning}])) |
| 88 | + (reset! incorrect-count (inc @incorrect-count)) |
| 89 | + (reset! show-error? true))))] |
85 | 90 | [rn/view {:style {:flex 1}}
|
86 | 91 | [quo/page-nav
|
87 | 92 | {:icon-name :i/arrow-left
|
|
109 | 114 |
|
110 | 115 | :else
|
111 | 116 | :disabled)
|
112 |
| - :word (get temp/secret-phrase num) |
| 117 | + :word (get secret-phrase num) |
113 | 118 | :number (inc num)
|
114 | 119 | :on-press #(when (= @quiz-index index)
|
115 | 120 | (reset! show-error? false))}])
|
|
119 | 124 | [buttons-row
|
120 | 125 | {:on-press on-button-press
|
121 | 126 | :margin-bottom 12
|
122 |
| - :options options-r-0}] |
| 127 | + :options options-row-0}] |
123 | 128 | [buttons-row
|
124 | 129 | {:on-press on-button-press
|
125 |
| - :options options-r-1}]]])))) |
| 130 | + :options options-row-1}]]])))) |
126 | 131 |
|
127 | 132 | (def view (quo.theme/with-theme view-internal))
|
0 commit comments