|
1 | 1 | (ns status-im2.contexts.wallet.send.transaction-confirmation.view
|
2 | 2 | (:require
|
3 |
| - [clojure.string :as string] |
4 | 3 | [quo.core :as quo]
|
5 | 4 | [quo.foundations.resources :as quo.resources]
|
6 | 5 | [quo.theme :as quo.theme]
|
7 | 6 | [react-native.core :as rn]
|
8 | 7 | [react-native.safe-area :as safe-area]
|
9 | 8 | [reagent.core :as reagent]
|
| 9 | + [status-im2.common.resources :as resources] |
10 | 10 | [status-im2.contexts.wallet.send.transaction-confirmation.style :as style]
|
11 | 11 | [utils.i18n :as i18n]
|
12 | 12 | [utils.re-frame :as rf]))
|
13 | 13 |
|
14 |
| -(def tabs-data |
15 |
| - [{:id :tab/assets :label (i18n/label :t/assets) :accessibility-label :assets-tab} |
16 |
| - {:id :tab/collectibles :label (i18n/label :t/collectibles) :accessibility-label :collectibles-tab}]) |
17 |
| - |
18 |
| -(defn- network-names |
19 |
| - [balances-per-chain] |
20 |
| - (mapv (fn [chain-id-keyword] |
21 |
| - (let [chain-id-str (name chain-id-keyword) |
22 |
| - chain-id (js/parseInt chain-id-str)] |
23 |
| - (case chain-id |
24 |
| - 10 {:source (quo.resources/get-network :optimism)} |
25 |
| - 42161 {:source (quo.resources/get-network :arbitrum)} |
26 |
| - 5 {:source (quo.resources/get-network :ethereum)} |
27 |
| - 1 {:source (quo.resources/get-network :ethereum)} |
28 |
| - :unknown))) ; Default case if the chain-id is not recognized |
29 |
| - (keys balances-per-chain))) |
30 |
| - |
31 |
| -(defn- asset-component |
32 |
| - [] |
33 |
| - (fn [token _ _ _] |
34 |
| - (let [on-press #(js/alert "Not implemented yet") |
35 |
| - total-balance (reduce + |
36 |
| - (map #(js/parseFloat (:balance %)) |
37 |
| - (vals (:balancesPerChain token)))) |
38 |
| - total-balance-formatted (.toFixed total-balance 2) |
39 |
| - currency :usd |
40 |
| - currency-symbol "$" |
41 |
| - price-fiat-currency (get-in token [:marketValuesPerCurrency currency :price]) |
42 |
| - balance-fiat (* total-balance price-fiat-currency) |
43 |
| - balance-fiat-formatted (.toFixed balance-fiat 2) |
44 |
| - networks-list (network-names (:balancesPerChain token))] |
45 |
| - [quo/token-network |
46 |
| - {:token (quo.resources/get-token (keyword (string/lower-case (:symbol token)))) |
47 |
| - :label (:name token) |
48 |
| - :token-value (str total-balance-formatted " " (:symbol token)) |
49 |
| - :fiat-value (str currency-symbol balance-fiat-formatted) |
50 |
| - :networks networks-list |
51 |
| - :on-press on-press}]))) |
52 |
| - |
53 |
| -(defn- asset-list |
54 |
| - [account-address search-text] |
55 |
| - (let [tokens (rf/sub [:wallet/tokens]) |
56 |
| - account-tokens (get tokens (keyword account-address)) |
57 |
| - sorted-tokens (sort-by :name compare account-tokens) |
58 |
| - filtered-tokens (filter #(or (string/starts-with? (string/lower-case (:name %)) |
59 |
| - (string/lower-case search-text)) |
60 |
| - (string/starts-with? (string/lower-case (:symbol %)) |
61 |
| - (string/lower-case search-text))) |
62 |
| - sorted-tokens)] |
63 |
| - [rn/view {:style {:flex 1}} |
64 |
| - [rn/flat-list |
65 |
| - {:data filtered-tokens |
66 |
| - :content-container-style {:padding-horizontal 8} |
67 |
| - :keyboard-should-persist-taps :handled |
68 |
| - :key-fn :id |
69 |
| - :on-scroll-to-index-failed identity |
70 |
| - :render-fn asset-component}]])) |
71 |
| - |
72 |
| -(defn- tab-view |
73 |
| - [account search-text selected-tab] |
74 |
| - (case selected-tab |
75 |
| - :tab/assets [asset-list account search-text] |
76 |
| - :tab/collectibles [quo/empty-state |
77 |
| - {:title (i18n/label :t/no-collectibles) |
78 |
| - :description (i18n/label :t/no-collectibles-description) |
79 |
| - :placeholder? true |
80 |
| - :container-style style/empty-container-style}])) |
81 |
| - |
82 |
| -(defn- search-input |
83 |
| - [search-text] |
84 |
| - (let [on-change-text #(reset! search-text %)] |
85 |
| - (fn [] |
86 |
| - [rn/view {:style style/search-input-container} |
87 |
| - [quo/input |
88 |
| - {:small? true |
89 |
| - :placeholder (i18n/label :t/search-assets) |
90 |
| - :icon-name :i/search |
91 |
| - :value @search-text |
92 |
| - :on-change-text on-change-text}]]))) |
93 |
| - |
94 | 14 | (defn- f-view-internal
|
95 |
| - [account-address] |
96 |
| - (let [margin-top (safe-area/get-top) |
97 |
| - selected-tab (reagent/atom (:id (first tabs-data))) |
98 |
| - search-text (reagent/atom "") |
99 |
| - account-address (string/lower-case (or account-address |
100 |
| - (rf/sub [:get-screen-params :wallet-accounts]))) |
101 |
| - on-close #(rf/dispatch [:navigate-back-within-stack :wallet-select-asset]) |
102 |
| - #_status-account-props |
103 |
| - #_{:customization-color :purple |
104 |
| - :size 32 |
105 |
| - :emoji "🍑" |
106 |
| - :type :default |
107 |
| - :name "Collectibles vault" |
108 |
| - :address "0x0ah...78b"} |
109 |
| - #_user-props |
110 |
| - #_{:full-name "M L" |
111 |
| - :status-indicator? false |
112 |
| - :size :small |
113 |
| - :ring-background (resources/get-mock-image :ring) |
114 |
| - :customization-color :blue |
115 |
| - :name "Mark Libot" |
116 |
| - :address "0x0ah...78b" |
117 |
| - :status-account (merge status-account-props {:size 16})}] |
| 15 | + [theme] |
| 16 | + (let [reset-slider? (reagent/atom false) |
| 17 | + margin-top (safe-area/get-top) |
| 18 | + biometric-auth? true |
| 19 | + on-close #(rf/dispatch [:navigate-back-within-stack :wallet-select-asset]) |
| 20 | + status-account-props {:customization-color :purple |
| 21 | + :size 32 |
| 22 | + :emoji "🍑" |
| 23 | + :type :default |
| 24 | + :name "Collectibles vault" |
| 25 | + :address "0x0ah...78b"} |
| 26 | + user-props {:full-name "M L" |
| 27 | + :status-indicator? false |
| 28 | + :size :small |
| 29 | + :ring-background (resources/get-mock-image :ring) |
| 30 | + :customization-color :blue |
| 31 | + :name "Mark Libot" |
| 32 | + :address "0x0ah...78b" |
| 33 | + :status-account (merge status-account-props |
| 34 | + {:size 16 |
| 35 | + :name "New house" |
| 36 | + :emoji "🍔"})}] |
118 | 37 | (fn []
|
119 |
| - [rn/scroll-view |
120 |
| - {:content-container-style (style/container margin-top) |
121 |
| - :keyboard-should-persist-taps :handled |
122 |
| - :scroll-enabled false} |
123 |
| - [quo/page-nav |
124 |
| - {:icon-name :i/arrow-left |
125 |
| - :on-press on-close |
126 |
| - :accessibility-label :top-bar |
127 |
| - :right-side :account-switcher |
128 |
| - :account-switcher {:customization-color :purple |
129 |
| - :on-press #(js/alert "Not implemented yet") |
130 |
| - :state :default |
131 |
| - :emoji "🍑"}}] |
132 |
| - [quo/text-combinations |
133 |
| - {:title (i18n/label :t/select-asset) |
134 |
| - :container-style style/title-container |
135 |
| - :title-accessibility-label :title-label}] |
136 |
| - #_[quo/summary-info |
| 38 | + [rn/view {:style {:flex 1}} |
| 39 | + [quo/gradient-cover |
| 40 | + {:customization-color :purple}] |
| 41 | + [rn/view |
| 42 | + {:style (style/container margin-top)} |
| 43 | + [quo/page-nav |
| 44 | + {:icon-name :i/arrow-left |
| 45 | + :on-press on-close |
| 46 | + :accessibility-label :top-bar |
| 47 | + :right-side {:icon-name :i/advanced |
| 48 | + :on-press (fn callback [] nil) |
| 49 | + :accessibility-label "Advanced"} |
| 50 | + :account-switcher {:customization-color :purple |
| 51 | + :on-press #(js/alert "Not implemented yet") |
| 52 | + :state :default |
| 53 | + :emoji "🍑"}}] |
| 54 | + [rn/view {:style style/content-container} |
| 55 | + [rn/view {:style {:flex-direction :row}} |
| 56 | + [quo/text |
| 57 | + {:size :heading-1 |
| 58 | + :weight :semi-bold |
| 59 | + :style style/title-container |
| 60 | + :accessibility-label :send-label} |
| 61 | + (i18n/label :t/send)] |
| 62 | + [quo/summary-tag |
| 63 | + {:label "150 ETH" |
| 64 | + :type :token |
| 65 | + :image-source (quo.resources/get-token :eth)}]] |
| 66 | + [rn/view |
| 67 | + {:style {:flex-direction :row |
| 68 | + :margin-top 4}} |
| 69 | + [quo/text |
| 70 | + {:size :heading-1 |
| 71 | + :weight :semi-bold |
| 72 | + :style style/title-container |
| 73 | + :accessibility-label :send-label} |
| 74 | + (i18n/label :t/from)] |
| 75 | + [quo/summary-tag |
| 76 | + {:label "Collectibles vault" |
| 77 | + :type :account |
| 78 | + :emoji "🍑" |
| 79 | + :customization-color :purple}]] |
| 80 | + [rn/view |
| 81 | + {:style {:flex-direction :row |
| 82 | + :margin-top 4}} |
| 83 | + [quo/text |
| 84 | + {:size :heading-1 |
| 85 | + :weight :semi-bold |
| 86 | + :style style/title-container |
| 87 | + :accessibility-label :send-label} |
| 88 | + (i18n/label :t/to)] |
| 89 | + [quo/summary-tag |
| 90 | + {:label "Mark Libot" |
| 91 | + :type :user |
| 92 | + :image-source (resources/get-mock-image :user-picture-male4) |
| 93 | + :customization-color :magenta}]]] |
| 94 | + [rn/view |
| 95 | + {:style {:padding-horizontal 20 |
| 96 | + :padding-bottom 16}} |
| 97 | + [quo/text |
| 98 | + {:size :paragraph-2 |
| 99 | + :weight :medium |
| 100 | + :style {:margin-bottom 8} |
| 101 | + :accessibility-label :summary-from-label} |
| 102 | + (i18n/label :t/from-capitalized)] |
| 103 | + [quo/summary-info |
137 | 104 | {:type :status-account
|
138 | 105 | :networks? true
|
139 | 106 | :values {:ethereum 150
|
140 | 107 | :optimism 50
|
141 | 108 | :arbitrum 25}
|
142 |
| - :account-props user-props}] |
143 |
| - #_[quo/summary-info |
144 |
| - {:type :status-account |
| 109 | + :account-props status-account-props}]] |
| 110 | + [rn/view |
| 111 | + {:style {:padding-horizontal 20 |
| 112 | + :padding-bottom 16}} |
| 113 | + [quo/text |
| 114 | + {:size :paragraph-2 |
| 115 | + :weight :medium |
| 116 | + :style {:margin-bottom 8} |
| 117 | + :accessibility-label :summary-from-label} |
| 118 | + (i18n/label :t/to-capitalized)] |
| 119 | + [quo/summary-info |
| 120 | + {:type :user |
145 | 121 | :networks? true
|
146 | 122 | :values {:ethereum 150
|
147 | 123 | :optimism 50
|
148 | 124 | :arbitrum 25}
|
149 |
| - :account-props status-account-props}] |
150 |
| - #_[rn/view |
151 |
| - [quo/data-item] |
152 |
| - [quo/data-item] |
153 |
| - [quo/data-item]] |
154 |
| - #_[quo/slide-button |
155 |
| - {:size size |
156 |
| - :container-style container-style |
157 |
| - :customization-color customization-color |
| 125 | + :account-props user-props}]] |
| 126 | + [rn/view |
| 127 | + {:style {:padding-horizontal 20 |
| 128 | + :padding-bottom 16}} |
| 129 | + [quo/text |
| 130 | + {:size :paragraph-2 |
| 131 | + :weight :medium |
| 132 | + :style {:margin-bottom 8} |
| 133 | + :accessibility-label :summary-from-label} |
| 134 | + (i18n/label :t/details)] |
| 135 | + [rn/view |
| 136 | + {:style (style/details-container theme)} |
| 137 | + [quo/data-item |
| 138 | + {:container-style {:flex 1 |
| 139 | + :height 36} |
| 140 | + :blur? false |
| 141 | + :description :default |
| 142 | + :icon-right? false |
| 143 | + :card? false |
| 144 | + :label :none |
| 145 | + :status :default |
| 146 | + :size :small |
| 147 | + :title "Est. time" |
| 148 | + :subtitle "3-5 min"}] |
| 149 | + [quo/data-item |
| 150 | + {:container-style {:flex 1 |
| 151 | + :height 36} |
| 152 | + :blur? false |
| 153 | + :description :default |
| 154 | + :icon-right? false |
| 155 | + :card? false |
| 156 | + :label :none |
| 157 | + :status :default |
| 158 | + :size :small |
| 159 | + :title "Max fees" |
| 160 | + :subtitle "€188,70"}] |
| 161 | + [quo/data-item |
| 162 | + {:container-style {:flex 1 |
| 163 | + :height 36} |
| 164 | + :blur? false |
| 165 | + :description :default |
| 166 | + :icon-right? false |
| 167 | + :card? false |
| 168 | + :label :none |
| 169 | + :status :default |
| 170 | + :size :small |
| 171 | + :title "Mark gets" |
| 172 | + :subtitle "149.99 ETH"}]]] |
| 173 | + [rn/safe-area-view |
| 174 | + {:style style/slide-button-container} |
| 175 | + [quo/slide-button |
| 176 | + {:size :size/s-48 |
| 177 | + :customization-color :purple |
158 | 178 | :on-reset (when @reset-slider? #(reset! reset-slider? false))
|
159 |
| - :on-complete #(authorize {:on-close on-close |
160 |
| - :auth-button-icon-left auth-button-icon-left |
161 |
| - :theme theme |
162 |
| - :blur? blur? |
163 |
| - :customization-color customization-color |
164 |
| - :on-enter-password on-enter-password |
165 |
| - :biometric-auth? biometric-auth? |
166 |
| - :on-auth-success on-auth-success |
167 |
| - :on-auth-fail on-auth-fail |
168 |
| - :auth-button-label auth-button-label}) |
| 179 | + :on-complete #(js/alert "Not implemented yet") |
169 | 180 | :track-icon (if biometric-auth? :i/face-id :password)
|
170 |
| - :track-text track-text}]]))) |
| 181 | + :track-text "Slide to send"}]]]]))) |
171 | 182 |
|
172 | 183 | (defn- view-internal
|
173 |
| - [{:keys [account-address]}] |
174 |
| - [:f> f-view-internal account-address]) |
| 184 | + [{:keys [theme]}] |
| 185 | + [:f> f-view-internal theme]) |
175 | 186 |
|
176 | 187 | (def view (quo.theme/with-theme view-internal))
|
0 commit comments