-
Notifications
You must be signed in to change notification settings - Fork 992
/
Copy pathview.cljs
95 lines (87 loc) · 3.63 KB
/
view.cljs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
(ns status-im.contexts.onboarding.syncing.progress.view
(:require
[quo.core :as quo]
[react-native.core :as rn]
[status-im.common.resources :as resources]
[status-im.contexts.onboarding.common.background.view :as background]
[status-im.contexts.onboarding.syncing.progress.style :as style]
[utils.debounce :as debounce]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
(defn pairing-progress
[status]
(not= status :error))
(defn page-title
[pairing-progress?]
[quo/text-combinations
{:container-style {:margin-top 56 :margin-horizontal 20}
:title (i18n/label (if pairing-progress?
:t/sync-profile-title
:t/sync-devices-error-title))
:description (when-not pairing-progress?
(i18n/label :t/sync-devices-error-sub-title))
:title-accessibility-label :progress-screen-title
:description-accessibility-label :progress-screen-sub-title}])
(defn- navigate-to-enter-seed-phrase
[]
(rf/dispatch [:syncing/set-syncing-fallback-flow])
(debounce/debounce-and-dispatch
[:onboarding/navigate-to-sign-in-by-seed-phrase :screen/onboarding.log-in]
500))
(defn- try-again
[logged-in?]
(rf/dispatch [:syncing/clear-states])
(if logged-in?
(rf/dispatch [:navigate-back])
(rf/dispatch [:navigate-back-to :screen/onboarding.log-in])))
(defn try-again-button
[profile-color logged-in?]
(let [two-vertical-actions-height 116]
[quo/bottom-actions
{:actions (if logged-in? :one-action :two-vertical-actions)
:blur? true
:container-style {:height (when-not logged-in? two-vertical-actions-height)}
:button-two-label (i18n/label :t/use-recovery-phrase)
:button-two-props {:type :primary
:accessibility-label :try-seed-phrase-button
:customization-color profile-color
:size 40
:on-press navigate-to-enter-seed-phrase}
:button-one-label
(i18n/label :t/try-again)
:button-one-props
{:type (if logged-in? :primary :grey)
:accessibility-label :try-again-later-button
:customization-color profile-color
:size 40
:on-press #(try-again logged-in?)}}]))
(defn- illustration
[pairing-progress?]
[rn/image
{:resize-mode :contain
:style (style/page-illustration (:width (rn/get-window)) pairing-progress?)
:source (resources/get-image (if pairing-progress? :syncing-devices :syncing-wrong))}])
(defn view
[in-onboarding?]
(let [pairing-status (rf/sub [:pairing/pairing-status])
logged-in? (rf/sub [:multiaccount/logged-in?])
pairing-progress? (pairing-progress pairing-status)
profile-color (or (:color (rf/sub [:onboarding/profile]))
(rf/sub [:profile/customization-color]))]
[rn/view {:style (style/page-container in-onboarding?)}
(when-not in-onboarding?
[rn/view {:style style/absolute-fill}
[background/view true]])
[quo/page-nav {:type :no-title :background :blur}]
[page-title pairing-progress?]
[illustration pairing-progress?]
(if pairing-progress?
[quo/information-box
{:type :default
:blur? true
:style {:margin-vertical 11 :margin-horizontal 12}}
(i18n/label :t/sync-devices-sub-title)]
[try-again-button profile-color logged-in?])]))
(defn view-onboarding
[]
[view true])