-
Notifications
You must be signed in to change notification settings - Fork 990
/
Copy pathview.cljs
172 lines (157 loc) · 5.52 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
(ns status-im2.navigation.view
(:require [quo2.foundations.colors :as colors]
[react-native.core :as rn]
[react-native.safe-area :as safe-area]
[reagent.core :as reagent]
[status-im.bottom-sheet.sheets :as bottom-sheets-old]
[status-im2.common.bottom-sheet.view :as bottom-sheet]
[status-im.ui.screens.popover.views :as popover]
[status-im.ui.screens.profile.visibility-status.views :as visibility-status-views]
[status-im.ui.screens.signing.views :as signing]
[status-im.ui.screens.wallet-connect.session-proposal.views :as wallet-connect]
[status-im.ui.screens.wallet.send.views :as wallet.send.views]
[status-im2.common.toasts.view :as toasts]
[status-im2.navigation.screens :as screens]
[status-im2.setup.hot-reload :as reloader]
[utils.re-frame :as rf]
[status-im2.common.bottom-sheet-screen.view :as bottom-sheet-screen]
[quo2.theme :as theme]))
(defn get-screens
[]
(reduce
(fn [acc screen]
(assoc acc (:name screen) screen))
{}
(screens/screens)))
(def screens (get-screens))
(defn inactive
[]
(when (rf/sub [:hide-screen?])
[rn/view
{:position :absolute
:flex 1
:top 0
:bottom 0
:left 0
:right 0
:background-color (colors/theme-colors colors/white colors/neutral-100)
:z-index 999999999999999999}]))
(defn wrapped-screen-style
[{:keys [top? bottom?]} background-color]
(merge
{:flex 1
:background-color (or background-color (colors/theme-colors colors/white colors/neutral-100))}
(when bottom?
{:padding-bottom (safe-area/get-bottom)})
(when top?
{:padding-top (safe-area/get-top)})))
(defn screen
[screen-key]
(reagent.core/reactify-component
(fn []
(let [{:keys [component options]} (get (if js/goog.DEBUG
(get-screens)
screens)
(keyword screen-key))
{:keys [insets sheet? theme]} options
user-theme (theme/get-theme)
background-color (or (get-in options [:layout :backgroundColor])
(when sheet? :transparent))]
^{:key (str "root" screen-key @reloader/cnt)}
[theme/provider {:theme (or theme user-theme)}
[rn/view {:style (wrapped-screen-style insets background-color)}
[inactive]
(if sheet?
[bottom-sheet-screen/view {:content component}]
[component])]
(when js/goog.DEBUG
[reloader/reload-view])]))))
(def bottom-sheet
(reagent/reactify-component
(fn []
(let [{:keys [sheets hide?]} (rf/sub [:bottom-sheet])
sheet (last sheets)
{:keys [theme]} sheet
insets (safe-area/get-insets)
user-theme (theme/get-theme)]
^{:key (str "sheet" @reloader/cnt)}
[theme/provider {:theme (or theme user-theme)}
[inactive]
[rn/keyboard-avoiding-view
{:style {:position :relative :flex 1}
:keyboard-vertical-offset (- (max 20 (:bottom insets)))}
(when sheet
[bottom-sheet/view {:insets insets :hide? hide?}
sheet])]]))))
(def toasts (reagent/reactify-component toasts/toasts))
;; LEGACY (should be removed in status 2.0)
(def popover-comp
(reagent/reactify-component
(fn []
^{:key (str "popover" @reloader/cnt)}
[:<>
[inactive]
[popover/popover]
(when js/goog.DEBUG
[reloader/reload-view])])))
(def visibility-status-popover-comp
(reagent/reactify-component
(fn []
^{:key (str "visibility-status-popover" @reloader/cnt)}
[rn/view
[inactive]
[visibility-status-views/visibility-status-popover]
(when js/goog.DEBUG
[reloader/reload-view])])))
(def sheet-comp-old
(reagent/reactify-component
(fn []
^{:key (str "sheet-old" @reloader/cnt)}
[:<>
[inactive]
[bottom-sheets-old/bottom-sheet]])))
(def signing-comp
(reagent/reactify-component
(fn []
^{:key (str "signing-sheet" @reloader/cnt)}
[:<>
[inactive]
[signing/signing]
(when js/goog.DEBUG
[reloader/reload-view])])))
(def select-acc-comp
(reagent/reactify-component
(fn []
^{:key (str "select-acc-sheet" @reloader/cnt)}
[:<>
[inactive]
[wallet.send.views/select-account]
(when js/goog.DEBUG
[reloader/reload-view])])))
(def wallet-connect-comp
(reagent/reactify-component
(fn []
^{:key (str "wallet-connect-sheet" @reloader/cnt)}
[:<>
[inactive]
[wallet-connect/wallet-connect-proposal-sheet]
(when js/goog.DEBUG
[reloader/reload-view])])))
(def wallet-connect-success-comp
(reagent/reactify-component
(fn []
^{:key (str "wallet-connect-success-sheet" @reloader/cnt)}
[:<>
[inactive]
[wallet-connect/wallet-connect-success-sheet-view]
(when js/goog.DEBUG
[reloader/reload-view])])))
(def wallet-connect-app-management-comp
(reagent/reactify-component
(fn []
^{:key (str "wallet-connect-app-management-sheet" @reloader/cnt)}
[:<>
[inactive]
[wallet-connect/wallet-connect-app-management-sheet-view]
(when js/goog.DEBUG
[reloader/reload-view])])))