|
| 1 | +(ns status-im2.contexts.quo-preview.inputs.recovery-phrase-input |
| 2 | + (:require [quo2.core :as quo] |
| 3 | + [quo2.foundations.colors :as colors] |
| 4 | + [react-native.core :as rn] |
| 5 | + [reagent.core :as reagent] |
| 6 | + [status-im2.contexts.quo-preview.preview :as preview])) |
| 7 | + |
| 8 | +(def descriptor |
| 9 | + [{:label "Text" |
| 10 | + :key :text |
| 11 | + :type :text} |
| 12 | + {:label "Placeholder" |
| 13 | + :key :placeholder |
| 14 | + :type :text} |
| 15 | + {:label "Blur" |
| 16 | + :key :blur? |
| 17 | + :type :boolean} |
| 18 | + {:label "Mark errors" |
| 19 | + :key :mark-errors? |
| 20 | + :type :boolean} |
| 21 | + {:label "Customization color" |
| 22 | + :key :customization-color |
| 23 | + :type :select |
| 24 | + :options (map (fn [[color _]] |
| 25 | + {:key color :value (name color)}) |
| 26 | + colors/customization)} |
| 27 | + {:label "Word limit" |
| 28 | + :key :word-limit |
| 29 | + :type :select |
| 30 | + :options [{:key nil :value "No limit"} |
| 31 | + {:key 5 :value "5 words"} |
| 32 | + {:key 10 :value "10 words"} |
| 33 | + {:key 20 :value "20 words"}]}]) |
| 34 | + |
| 35 | +(defn cool-preview |
| 36 | + [] |
| 37 | + (let [state (reagent/atom {:text "" |
| 38 | + :placeholder "Type or paste your recovery phrase" |
| 39 | + :customization-color :blue |
| 40 | + :word-limit 20 |
| 41 | + :mark-errors? true})] |
| 42 | + (fn [] |
| 43 | + [rn/touchable-without-feedback {:on-press rn/dismiss-keyboard!} |
| 44 | + [rn/view {:style {:padding-bottom 150}} |
| 45 | + [rn/view {:style {:flex 1}} |
| 46 | + [preview/customizer state descriptor] |
| 47 | + [quo/text {:size :paragraph-2} |
| 48 | + "(Any word with at least 6 chars is marked as error)"]] |
| 49 | + [preview/blur-view |
| 50 | + {:style {:align-items :center |
| 51 | + :margin-vertical 20 |
| 52 | + :width "100%"} |
| 53 | + :height 200 |
| 54 | + :show-blur-background? (:blur? @state)} |
| 55 | + [rn/view |
| 56 | + {:style {:height 150 |
| 57 | + :width "100%"}} |
| 58 | + [quo/recovery-phrase-input |
| 59 | + {:mark-errors? (:mark-errors? @state) |
| 60 | + :error-pred #(> (count %) 5) |
| 61 | + :on-change-text #(swap! state assoc :text %) |
| 62 | + :placeholder (:placeholder @state) |
| 63 | + :customization-color (:customization-color @state) |
| 64 | + :word-limit (:word-limit @state)} |
| 65 | + (:text @state)]]]]]))) |
| 66 | + |
| 67 | +(defn preview-recovery-phrase-input |
| 68 | + [] |
| 69 | + [rn/view |
| 70 | + {:style {:background-color (colors/theme-colors colors/white colors/neutral-95) |
| 71 | + :flex 1}} |
| 72 | + [rn/flat-list |
| 73 | + {:style {:flex 1} |
| 74 | + :keyboardShouldPersistTaps :always |
| 75 | + :header [cool-preview] |
| 76 | + :key-fn str}]]) |
| 77 | + |
0 commit comments