|
1 | 1 | (ns status-im2.contexts.onboarding.enable-biometrics.view
|
2 | 2 | (:require
|
3 | 3 | [quo.core :as quo]
|
| 4 | + [quo.theme :as quo.theme] |
4 | 5 | [react-native.core :as rn]
|
5 | 6 | [react-native.safe-area :as safe-area]
|
6 | 7 | [status-im2.common.biometric.events :as biometric]
|
7 | 8 | [status-im2.common.parallax.view :as parallax]
|
8 | 9 | [status-im2.common.parallax.whitelist :as whitelist]
|
9 | 10 | [status-im2.common.resources :as resources]
|
| 11 | + [status-im2.common.standard-authentication.core :as standard-auth] |
10 | 12 | [status-im2.contexts.onboarding.enable-biometrics.style :as style]
|
| 13 | + [status-im2.navigation.state :as state] |
11 | 14 | [utils.i18n :as i18n]
|
12 |
| - [utils.re-frame :as rf])) |
| 15 | + [utils.re-frame :as rf] |
| 16 | + [utils.security.core :as security])) |
| 17 | + |
13 | 18 |
|
14 | 19 | (defn page-title
|
15 | 20 | []
|
|
21 | 26 | :description-accessibility-label :enable-biometrics-sub-title}])
|
22 | 27 |
|
23 | 28 | (defn enable-biometrics-buttons
|
24 |
| - [insets] |
| 29 | + [insets theme] |
25 | 30 | (let [supported-biometric-type (rf/sub [:biometric/supported-type])
|
26 | 31 | bio-type-label (biometric/get-label-by-type supported-biometric-type)
|
27 |
| - profile-color (:color (rf/sub [:onboarding-2/profile]))] |
| 32 | + profile-color (or (:color (rf/sub [:onboarding-2/profile])) |
| 33 | + (rf/sub [:profile/customization-color])) |
| 34 | + syncing-results? (= :syncing-results @state/root-id)] |
28 | 35 | [rn/view {:style (style/buttons insets)}
|
29 |
| - [quo/button |
30 |
| - {:accessibility-label :enable-biometrics-button |
31 |
| - :on-press #(rf/dispatch [:onboarding-2/enable-biometrics]) |
32 |
| - :icon-left :i/face-id |
33 |
| - :customization-color profile-color} |
34 |
| - (i18n/label :t/biometric-enable-button {:bio-type-label bio-type-label})] |
| 36 | + [standard-auth/button |
| 37 | + (merge |
| 38 | + {:size 40 |
| 39 | + :accessibility-label :enable-biometrics-button |
| 40 | + :icon-left :i/face-id |
| 41 | + :customization-color profile-color |
| 42 | + :button-label (i18n/label :t/biometric-enable-button {:bio-type-label bio-type-label})} |
| 43 | + (if syncing-results? |
| 44 | + {:theme theme |
| 45 | + :blur? true |
| 46 | + :on-enter-password (fn [entered-password] |
| 47 | + (rf/dispatch |
| 48 | + [:onboarding-2/authenticate-enable-biometrics |
| 49 | + (security/safe-unmask-data |
| 50 | + entered-password)]) |
| 51 | + (rf/dispatch [:hide-bottom-sheet])) |
| 52 | + :auth-button-label (i18n/label :t/confirm)} |
| 53 | + {:on-press #(rf/dispatch [:onboarding-2/enable-biometrics])}))] |
35 | 54 | [quo/button
|
36 | 55 | {:accessibility-label :maybe-later-button
|
37 | 56 | :background :blur
|
38 | 57 | :type :grey
|
39 |
| - :on-press #(rf/dispatch [:onboarding-2/create-account-and-login]) |
| 58 | + :on-press #(rf/dispatch (if syncing-results? |
| 59 | + [:navigate-to-within-stack |
| 60 | + [:enable-notifications :enable-biometrics]] |
| 61 | + [:onboarding-2/create-account-and-login])) |
40 | 62 | :container-style {:margin-top 12}}
|
41 | 63 | (i18n/label :t/maybe-later)]]))
|
42 | 64 |
|
|
55 | 77 | :style (style/page-illustration width)
|
56 | 78 | :source (resources/get-image :biometrics)}]))
|
57 | 79 |
|
58 |
| -(defn enable-biometrics |
59 |
| - [] |
| 80 | +(defn f-enable-biometrics |
| 81 | + [{:keys [theme]}] |
60 | 82 | (let [insets (safe-area/get-insets)]
|
61 | 83 | [rn/view {:style (style/page-container insets)}
|
62 | 84 | [page-title]
|
63 | 85 | (if whitelist/whitelisted?
|
64 | 86 | [enable-biometrics-parallax]
|
65 | 87 | [enable-biometrics-simple])
|
66 |
| - [enable-biometrics-buttons insets]])) |
| 88 | + [enable-biometrics-buttons insets theme]])) |
| 89 | + |
| 90 | + |
| 91 | +(defn- internale-enable-biometrics |
| 92 | + [params] |
| 93 | + [:f> f-enable-biometrics params]) |
| 94 | + |
| 95 | +(def view (quo.theme/with-theme internale-enable-biometrics)) |
0 commit comments