Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d778e03208 | ||
|
|
895ccc26f0 | ||
|
|
cfc86661cd | ||
|
|
a64af7243d | ||
|
|
9766a67e83 | ||
|
|
5f9ccf61a0 | ||
|
|
e4c77c619a |
@@ -28,3 +28,9 @@
|
||||
(h/render [disclaimer/view {:checked? false} "test"])
|
||||
(h/is-null (h/query-by-label-text :checkbox-on))
|
||||
(h/is-truthy (h/query-by-label-text :checkbox-off)))))
|
||||
|
||||
(h/test "Renders icon"
|
||||
(let [text "I accept this disclaimer"]
|
||||
(h/render [disclaimer/view {:icon :i/locked} text])
|
||||
(h/is-truthy (h/query-by-label-text :disclaimer-icon))))
|
||||
|
||||
|
||||
@@ -16,3 +16,6 @@
|
||||
|
||||
(def text
|
||||
{:margin-left 8})
|
||||
|
||||
(def icon-container
|
||||
{:align-items :flex-end :flex 1})
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
(ns quo.components.selectors.disclaimer.view
|
||||
(:require
|
||||
[quo.components.icon :as icons]
|
||||
[quo.components.markdown.text :as text]
|
||||
[quo.components.selectors.disclaimer.style :as style]
|
||||
[quo.components.selectors.selectors.view :as selectors]
|
||||
[quo.foundations.colors :as colors]
|
||||
[quo.theme]
|
||||
[react-native.core :as rn]))
|
||||
|
||||
(defn view
|
||||
[{:keys [checked? blur? accessibility-label container-style on-change]} label]
|
||||
[{:keys [checked? blur? accessibility-label container-style on-change icon]} label]
|
||||
(let [theme (quo.theme/use-theme)]
|
||||
[rn/touchable-without-feedback
|
||||
{:on-press on-change
|
||||
@@ -22,4 +24,9 @@
|
||||
[text/text
|
||||
{:size :paragraph-2
|
||||
:style style/text}
|
||||
label]]]))
|
||||
label]
|
||||
(when icon
|
||||
[rn/view {:style style/icon-container}
|
||||
[icons/icon icon
|
||||
{:accessibility-label :disclaimer-icon
|
||||
:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)}]])]]))
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
:else (string/capitalize (name network))))
|
||||
|
||||
(defn view-internal
|
||||
[{:keys [network status amount container-style on-press] :as args}]
|
||||
[{:keys [network status amount container-style on-press on-long-press] :as args}]
|
||||
(let [theme (quo.theme/use-theme)]
|
||||
(if (= status :add)
|
||||
[network-bridge-add (assoc args :theme theme)]
|
||||
@@ -35,7 +35,8 @@
|
||||
{:style (merge (style/container network status theme) container-style)
|
||||
:accessible true
|
||||
:accessibility-label :container
|
||||
:on-press on-press}
|
||||
:on-press on-press
|
||||
:on-long-press on-long-press}
|
||||
(if (= status :loading)
|
||||
[rn/view
|
||||
{:style (style/loading-skeleton theme)
|
||||
|
||||
@@ -93,3 +93,6 @@
|
||||
[state]
|
||||
(set-input-value state ""))
|
||||
|
||||
(defn empty-value?
|
||||
[state]
|
||||
(string/blank? (:value state)))
|
||||
|
||||
@@ -8,15 +8,17 @@
|
||||
(def descriptor
|
||||
[{:key :checked? :type :boolean}
|
||||
{:key :blur? :type :boolean}
|
||||
{:key :text :type :text}])
|
||||
{:key :text :type :text}
|
||||
{:key :icon :type :boolean}])
|
||||
|
||||
(defn view
|
||||
[]
|
||||
(let [state (reagent/atom {:checked? false
|
||||
:blur? true
|
||||
:text "I agree with the community rules"})]
|
||||
:text "I agree with the community rules"
|
||||
:icon false})]
|
||||
(fn []
|
||||
(let [{:keys [blur? checked? text]} @state]
|
||||
(let [{:keys [blur? checked? text icon]} @state]
|
||||
[preview/preview-container
|
||||
{:state state
|
||||
:descriptor descriptor
|
||||
@@ -27,6 +29,10 @@
|
||||
[quo/disclaimer
|
||||
{:blur? blur?
|
||||
:checked? checked?
|
||||
:icon (when icon
|
||||
(if checked?
|
||||
:i/locked
|
||||
:i/unlocked))
|
||||
:on-change #(swap! state update :checked? not)}
|
||||
text]]
|
||||
[quo/button {:disabled? (not checked?)}
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
sender-network-values (get-in db [:wallet :ui :send :sender-network-values])
|
||||
tx-type (get-in db [:wallet :ui :send :tx-type])
|
||||
disabled-from-chain-ids (or (get-in db [:wallet :ui :send :disabled-from-chain-ids]) [])
|
||||
from-locked-amounts (or (get-in db [:wallet :ui :send :from-locked-amounts]) {})
|
||||
token-decimals (if collectible 0 (:decimals token))
|
||||
native-token? (and token (= token-display-name "ETH"))
|
||||
routes-available? (pos? (count chosen-route))
|
||||
@@ -68,6 +69,7 @@
|
||||
:disabled-chain-ids disabled-from-chain-ids
|
||||
:receiver-networks receiver-networks
|
||||
:token-networks-ids token-networks-ids
|
||||
:from-locked-amounts from-locked-amounts
|
||||
:tx-type tx-type
|
||||
:receiver? false})
|
||||
(send-utils/reset-loading-network-amounts-to-zero
|
||||
@@ -141,8 +143,12 @@
|
||||
{:db (update-in db [:wallet :ui :send] dissoc :amount)}))
|
||||
|
||||
(rf/reg-event-fx :wallet/clean-disabled-from-networks
|
||||
(fn [{:keys [db]}]
|
||||
{:db (update-in db [:wallet :ui :send] dissoc :disabled-from-chain-ids)}))
|
||||
(fn [{:keys [db]}]
|
||||
{:db (update-in db [:wallet :ui :send] dissoc :disabled-from-chain-ids)}))
|
||||
|
||||
(rf/reg-event-fx :wallet/clean-from-locked-amounts
|
||||
(fn [{:keys [db]}]
|
||||
{:db (update-in db [:wallet :ui :send] dissoc :from-locked-amounts)}))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/select-send-address
|
||||
@@ -308,28 +314,39 @@
|
||||
(fn [{:keys [db]} [chain-ids]]
|
||||
{:db (assoc-in db [:wallet :ui :send :disabled-from-chain-ids] chain-ids)}))
|
||||
|
||||
(rf/reg-event-fx :wallet/lock-from-amount
|
||||
(fn [{:keys [db]} [chain-id amount]]
|
||||
{:db (assoc-in db [:wallet :ui :send :from-locked-amounts chain-id] amount)}))
|
||||
|
||||
(rf/reg-event-fx :wallet/unlock-from-amount
|
||||
(fn [{:keys [db]} [chain-id]]
|
||||
(let [new-locked-amounts (-> db
|
||||
(get-in [:wallet :ui :send :from-locked-amounts])
|
||||
(dissoc chain-id))]
|
||||
{:db (assoc-in db [:wallet :ui :send :from-locked-amounts] new-locked-amounts)})))
|
||||
|
||||
(rf/reg-event-fx :wallet/reset-network-amounts-to-zero
|
||||
(fn [{:keys [db]}]
|
||||
(let [sender-network-values (get-in db [:wallet :ui :send :sender-network-values])
|
||||
receiver-network-values (get-in db [:wallet :ui :send :receiver-network-values])
|
||||
disabled-from-chain-ids (get-in db [:wallet :ui :send :disabled-from-chain-ids])
|
||||
sender-network-values (send-utils/reset-network-amounts-to-zero
|
||||
{:network-amounts sender-network-values
|
||||
:disabled-chain-ids disabled-from-chain-ids})
|
||||
receiver-network-values (send-utils/reset-network-amounts-to-zero
|
||||
{:network-amounts receiver-network-values
|
||||
:disabled-chain-ids []})]
|
||||
{:db (-> db
|
||||
(assoc-in [:wallet :ui :send :sender-network-values] sender-network-values)
|
||||
(assoc-in [:wallet :ui :send :receiver-network-values] receiver-network-values)
|
||||
(update-in [:wallet :ui :send]
|
||||
dissoc
|
||||
:network-links
|
||||
(when (empty? sender-network-values) :sender-network-values)
|
||||
(when (empty? receiver-network-values) :receiver-network-values)))})))
|
||||
(fn [{:keys [db]}]
|
||||
(let [sender-network-values (get-in db [:wallet :ui :send :sender-network-values])
|
||||
receiver-network-values (get-in db [:wallet :ui :send :receiver-network-values])
|
||||
disabled-from-chain-ids (get-in db [:wallet :ui :send :disabled-from-chain-ids])
|
||||
sender-network-values (send-utils/reset-network-amounts-to-zero
|
||||
{:network-amounts sender-network-values
|
||||
:disabled-chain-ids disabled-from-chain-ids})
|
||||
receiver-network-values (send-utils/reset-network-amounts-to-zero
|
||||
{:network-amounts receiver-network-values
|
||||
:disabled-chain-ids []})]
|
||||
{:db (-> db
|
||||
(assoc-in [:wallet :ui :send :sender-network-values] sender-network-values)
|
||||
(assoc-in [:wallet :ui :send :receiver-network-values] receiver-network-values)
|
||||
(update-in [:wallet :ui :send]
|
||||
dissoc
|
||||
:network-links
|
||||
(when (empty? sender-network-values) :sender-network-values)
|
||||
(when (empty? receiver-network-values) :receiver-network-values)))})))
|
||||
|
||||
(rf/reg-event-fx :wallet/get-suggested-routes
|
||||
(fn [{:keys [db now]} [{:keys [amount updated-token]}]]
|
||||
(fn [{:keys [db now]} [{:keys [amount updated-token ]}]]
|
||||
(let [wallet-address (get-in db [:wallet :current-viewing-account-address])
|
||||
token (or updated-token (get-in db [:wallet :ui :send :token]))
|
||||
transaction-type (get-in db [:wallet :ui :send :tx-type])
|
||||
@@ -337,6 +354,7 @@
|
||||
to-address (get-in db [:wallet :ui :send :to-address])
|
||||
receiver-networks (get-in db [:wallet :ui :send :receiver-networks])
|
||||
disabled-from-chain-ids (or (get-in db [:wallet :ui :send :disabled-from-chain-ids]) [])
|
||||
from-locked-amounts (or (get-in db [:wallet :ui :send :from-locked-amounts]) {})
|
||||
test-networks-enabled? (get-in db [:profile/profile :test-networks-enabled?])
|
||||
networks ((if test-networks-enabled? :test :prod)
|
||||
(get-in db [:wallet :networks]))
|
||||
@@ -347,7 +365,8 @@
|
||||
to-token-id ""
|
||||
network-preferences (if token [] [(get-in collectible [:id :contract-id :chain-id])])
|
||||
gas-rates constants/gas-rate-medium
|
||||
amount-in (send-utils/amount-in-hex amount (if token token-decimal 0))
|
||||
to-hex (fn [val] (send-utils/amount-in-hex val (if token token-decimal 0)))
|
||||
amount-in (to-hex amount)
|
||||
from-address wallet-address
|
||||
disabled-from-chain-ids disabled-from-chain-ids
|
||||
disabled-to-chain-ids (if (= transaction-type :tx/bridge)
|
||||
@@ -356,7 +375,10 @@
|
||||
(not (some #(= chain-id %)
|
||||
receiver-networks)))
|
||||
network-chain-ids))
|
||||
from-locked-amount {}
|
||||
from-locked-amount (update-vals from-locked-amounts to-hex)
|
||||
_ (tap> {:in `get-suggested-routes
|
||||
:from-locked-amount from-locked-amount
|
||||
:amount-in amount-in})
|
||||
transaction-type-param (case transaction-type
|
||||
:tx/collectible-erc-721 constants/send-type-erc-721-transfer
|
||||
:tx/collectible-erc-1155 constants/send-type-erc-1155-transfer
|
||||
|
||||
@@ -125,6 +125,21 @@
|
||||
:style {:margin-top 15}}
|
||||
(i18n/label :t/no-routes-found)]])
|
||||
|
||||
|
||||
(defn- fetch-routes
|
||||
[{:keys [amount bounce-duration-ms token valid-input? ]}]
|
||||
(tap>
|
||||
{:in `fetch-routes
|
||||
:amount amount
|
||||
:token token})
|
||||
(if valid-input?
|
||||
(debounce/debounce-and-dispatch
|
||||
[:wallet/get-suggested-routes
|
||||
{:amount amount
|
||||
:updated-token token }]
|
||||
bounce-duration-ms)
|
||||
(rf/dispatch [:wallet/clean-suggested-routes])))
|
||||
|
||||
(defn view
|
||||
;; crypto-decimals, limit-crypto and initial-crypto-currency? args are needed
|
||||
;; for component tests only
|
||||
@@ -159,6 +174,7 @@
|
||||
send-enabled-networks (rf/sub [:wallet/wallet-send-enabled-networks])
|
||||
enabled-from-chain-ids (rf/sub
|
||||
[:wallet/wallet-send-enabled-from-chain-ids])
|
||||
send-from-locked-amounts (rf/sub [:wallet/wallet-send-from-locked-amounts])
|
||||
{token-balance :total-balance
|
||||
available-balance :available-balance
|
||||
:as token-by-symbol} (rf/sub [:wallet/token-by-symbol
|
||||
@@ -264,7 +280,14 @@
|
||||
limit-insufficient? (> (controlled-input/numeric-value input-state)
|
||||
current-limit)
|
||||
should-try-again? (and (not limit-insufficient?) no-routes-found?)
|
||||
current-address (rf/sub [:wallet/current-viewing-account-address])]
|
||||
current-address (rf/sub [:wallet/current-viewing-account-address])
|
||||
request-fetch-routes (fn [bounce-duration-ms]
|
||||
(fetch-routes
|
||||
{:amount amount
|
||||
:valid-input? valid-input?
|
||||
:bounce-duration-ms bounce-duration-ms
|
||||
:token token}))]
|
||||
|
||||
(rn/use-mount
|
||||
(fn []
|
||||
(let [dismiss-keyboard-fn #(when (= % "active") (rn/dismiss-keyboard!))
|
||||
@@ -284,6 +307,12 @@
|
||||
(clear-input!)
|
||||
(rf/dispatch [:wallet/clean-suggested-routes]))
|
||||
[current-address])
|
||||
(rn/use-effect
|
||||
(fn []
|
||||
(tap> {:in `use-effect
|
||||
:request-fetch-routes request-fetch-routes})
|
||||
(request-fetch-routes 0))
|
||||
[send-from-locked-amounts])
|
||||
[rn/view
|
||||
{:style style/screen
|
||||
:accessibility-label (str "container"
|
||||
@@ -329,7 +358,8 @@
|
||||
:valid-input? valid-input?
|
||||
:token-not-supported-in-receiver-networks? token-not-supported-in-receiver-networks?
|
||||
:lock-fetch-routes? just-toggled-mode?
|
||||
:current-screen-id current-screen-id}]
|
||||
:current-screen-id current-screen-id
|
||||
:request-fetch-routes request-fetch-routes}]
|
||||
(when (and (not loading-routes?)
|
||||
sender-network-values
|
||||
token-not-supported-in-receiver-networks?)
|
||||
|
||||
@@ -58,3 +58,16 @@
|
||||
{:margin-left 8
|
||||
:margin-right 12
|
||||
:padding-right 12})
|
||||
|
||||
(def disclaimer
|
||||
{:margin-horizontal 20
|
||||
:margin-top 20
|
||||
:margin-bottom 8})
|
||||
|
||||
(def input-container
|
||||
{:margin-top 8
|
||||
:margin-bottom 12})
|
||||
|
||||
(defn keyboard-container
|
||||
[bottom]
|
||||
{:padding-bottom bottom})
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
(ns status-im.contexts.wallet.send.routes.view
|
||||
(:require
|
||||
[quo.core :as quo]
|
||||
[react-native.core :as rn]
|
||||
[status-im.contexts.wallet.common.utils.networks :as network-utils]
|
||||
[status-im.contexts.wallet.send.routes.style :as style]
|
||||
[status-im.contexts.wallet.send.utils :as send-utils]
|
||||
[status-im.contexts.wallet.sheets.network-preferences.view :as network-preferences]
|
||||
[utils.debounce :as debounce]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
[clojure.string :as string]
|
||||
[quo.core :as quo]
|
||||
[react-native.core :as rn]
|
||||
[react-native.safe-area :as safe-area]
|
||||
[status-im.common.controlled-input.utils :as controlled-input]
|
||||
[status-im.contexts.wallet.common.utils :as utils]
|
||||
[status-im.contexts.wallet.common.utils.networks :as network-utils]
|
||||
[status-im.contexts.wallet.send.routes.style :as style]
|
||||
[status-im.contexts.wallet.send.utils :as send-utils]
|
||||
[status-im.contexts.wallet.sheets.network-preferences.view :as network-preferences]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.number :as number]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
|
||||
(def row-height 44)
|
||||
(def space-between-rows 11)
|
||||
@@ -16,15 +21,6 @@
|
||||
(def network-link-1x-height 56)
|
||||
(def network-link-2x-height 111)
|
||||
|
||||
(defn- fetch-routes
|
||||
[{:keys [amount bounce-duration-ms token valid-input?]}]
|
||||
(if valid-input?
|
||||
(debounce/debounce-and-dispatch
|
||||
[:wallet/get-suggested-routes
|
||||
{:amount amount
|
||||
:updated-token token}]
|
||||
bounce-duration-ms)
|
||||
(rf/dispatch [:wallet/clean-suggested-routes])))
|
||||
|
||||
(defn- open-preferences
|
||||
[]
|
||||
@@ -89,8 +85,140 @@
|
||||
(rf/dispatch [:wallet/update-receiver-networks
|
||||
chain-ids]))}]))}]))
|
||||
|
||||
(comment
|
||||
(string/capitalize (name :mainnet)))
|
||||
|
||||
(defn- make-limit-label-crypto
|
||||
[amount currency]
|
||||
(str amount
|
||||
" "
|
||||
(some-> currency
|
||||
name
|
||||
string/upper-case)))
|
||||
|
||||
(defn- make-limit-label-fiat
|
||||
[amount currency-symbol]
|
||||
(str currency-symbol amount))
|
||||
|
||||
(defn- edit-amount
|
||||
[{:keys [chain-id token-symbol]}]
|
||||
(rf/dispatch
|
||||
[:show-bottom-sheet
|
||||
{:content
|
||||
(fn []
|
||||
(let [{:keys [network-name] :as network-details} (rf/sub [:wallet/network-details-by-chain-id
|
||||
chain-id])
|
||||
{fiat-currency :currency} (rf/sub [:profile/profile])
|
||||
{token-decimals :decimals
|
||||
:as
|
||||
token} (rf/sub [:wallet/wallet-send-token])
|
||||
currency (rf/sub [:profile/currency])
|
||||
currency-symbol (rf/sub [:profile/currency-symbol])
|
||||
send-from-locked-amounts (rf/sub [:wallet/wallet-send-from-locked-amounts])
|
||||
locked-amount (get send-from-locked-amounts chain-id)
|
||||
network-name-str (string/capitalize (name network-name))
|
||||
[input-state set-input-state] (rn/use-state (cond-> controlled-input/init-state
|
||||
locked-amount (controlled-input/set-input-value locked-amount)))
|
||||
[crypto-currency? set-crypto-currency] (rn/use-state true)
|
||||
conversion-rate (-> token
|
||||
:market-values-per-currency
|
||||
currency
|
||||
:price)
|
||||
{token-balance :total-balance} (rf/sub [:wallet/token-by-symbol
|
||||
(str token-symbol)
|
||||
[chain-id]])
|
||||
current-crypto-limit (utils/get-standard-crypto-format
|
||||
token
|
||||
token-balance)
|
||||
current-fiat-limit (.toFixed (* token-balance conversion-rate) 2)
|
||||
current-limit (if crypto-currency?
|
||||
current-crypto-limit
|
||||
current-fiat-limit)
|
||||
crypto-decimals token-decimals
|
||||
input-amount (controlled-input/input-value input-state)
|
||||
[is-amount-locked? set-is-amount-locked] (rn/use-state (some? locked-amount))
|
||||
bottom (safe-area/get-bottom)]
|
||||
(rn/use-effect
|
||||
(fn []
|
||||
(set-input-state #(controlled-input/set-upper-limit % current-limit)))
|
||||
[current-limit])
|
||||
[:<>
|
||||
[quo/drawer-top
|
||||
{:title (i18n/label :t/send-from-network {:network network-name-str})
|
||||
:description (i18n/label :t/define-amount-sent-from-network {:network network-name-str})}]
|
||||
[quo/token-input
|
||||
{:container-style style/input-container
|
||||
:token token-symbol
|
||||
:currency fiat-currency
|
||||
:currency-symbol currency-symbol
|
||||
:crypto-decimals (min token-decimals 6)
|
||||
:error? (controlled-input/input-error input-state)
|
||||
:networks [network-details]
|
||||
:title (i18n/label
|
||||
:t/send-limit
|
||||
{:limit (if crypto-currency?
|
||||
(make-limit-label-crypto current-limit token-symbol)
|
||||
(make-limit-label-fiat current-limit currency-symbol))})
|
||||
:conversion conversion-rate
|
||||
:show-keyboard? false
|
||||
:value (controlled-input/input-value input-state)
|
||||
:on-swap (fn [swap-to-crypto-currency?]
|
||||
(set-crypto-currency swap-to-crypto-currency?)
|
||||
(set-input-state
|
||||
(fn [input-state]
|
||||
(controlled-input/set-input-value
|
||||
input-state
|
||||
(let [value (controlled-input/input-value input-state)
|
||||
new-value (if swap-to-crypto-currency?
|
||||
(.toFixed (/ value conversion-rate)
|
||||
crypto-decimals)
|
||||
(.toFixed (* value conversion-rate) 12))]
|
||||
(number/remove-trailing-zeroes new-value))))))}]
|
||||
[quo/disclaimer
|
||||
{:on-change (fn [checked?]
|
||||
(tap> {:checked checked?})
|
||||
(set-is-amount-locked checked?))
|
||||
:checked? is-amount-locked?
|
||||
:container-style style/disclaimer
|
||||
:icon (if is-amount-locked?
|
||||
:i/locked
|
||||
:i/unlocked)}
|
||||
(i18n/label :t/dont-auto-recalculate-network {:network network-name-str})]
|
||||
[quo/bottom-actions
|
||||
{:actions :one-action
|
||||
:button-one-label (i18n/label :t/update)
|
||||
:button-one-props {:on-press (fn []
|
||||
(if is-amount-locked?
|
||||
(let [limit-in-crypto (if crypto-currency?
|
||||
input-amount
|
||||
(number/remove-trailing-zeroes
|
||||
(.toFixed (/ input-amount
|
||||
conversion-rate)
|
||||
crypto-decimals)))]
|
||||
(rf/dispatch [:wallet/lock-from-amount chain-id limit-in-crypto]))
|
||||
(rf/dispatch [:wallet/unlock-from-amount chain-id]))
|
||||
(rf/dispatch [:hide-bottom-sheet]))
|
||||
:disabled? (or (controlled-input/empty-value? input-state)
|
||||
(controlled-input/input-error input-state))}}]
|
||||
[quo/numbered-keyboard
|
||||
{:container-style (style/keyboard-container bottom)
|
||||
:left-action :dot
|
||||
:delete-key? true
|
||||
:on-press (fn [c]
|
||||
(let [new-text (str input-amount c)
|
||||
max-decimals (if crypto-currency? crypto-decimals 2)
|
||||
regex-pattern (str "^\\d*\\.?\\d{0," max-decimals "}$")
|
||||
regex (re-pattern regex-pattern)]
|
||||
(when (re-matches regex new-text)
|
||||
(set-is-amount-locked true)
|
||||
(set-input-state #(controlled-input/add-character % c)))))
|
||||
:on-delete (fn []
|
||||
(set-input-state controlled-input/delete-last))
|
||||
:on-long-press-delete (fn []
|
||||
(set-input-state controlled-input/delete-all))}]]))}]))
|
||||
|
||||
(defn render-network-values
|
||||
[{:keys [network-values token-symbol on-press receiver? loading-routes?
|
||||
[{:keys [network-values token-symbol on-press on-long-press receiver? loading-routes?
|
||||
token-not-supported-in-receiver-networks?]}]
|
||||
[rn/view
|
||||
(map-indexed (fn [index {:keys [chain-id total-amount type]}]
|
||||
@@ -98,22 +226,27 @@
|
||||
{:key (str (if receiver? "to" "from") "-" chain-id)
|
||||
:style {:margin-top (if (pos? index) 11 7.5)}}
|
||||
[quo/network-bridge
|
||||
{:amount (if (= type :not-available)
|
||||
(i18n/label :t/not-available)
|
||||
(str total-amount " " token-symbol))
|
||||
:network (network-utils/id->network chain-id)
|
||||
:status (cond (and (= type :not-available)
|
||||
loading-routes?
|
||||
token-not-supported-in-receiver-networks?)
|
||||
:loading
|
||||
(= type :not-available)
|
||||
:disabled
|
||||
:else type)
|
||||
:on-press #(when (not loading-routes?)
|
||||
(cond
|
||||
(= type :add)
|
||||
(open-preferences)
|
||||
on-press (on-press chain-id total-amount)))}]])
|
||||
{:amount (if (= type :not-available)
|
||||
(i18n/label :t/not-available)
|
||||
(str total-amount " " token-symbol))
|
||||
:network (network-utils/id->network chain-id)
|
||||
:status (cond (and (= type :not-available)
|
||||
loading-routes?
|
||||
token-not-supported-in-receiver-networks?)
|
||||
:loading
|
||||
(= type :not-available)
|
||||
:disabled
|
||||
:else type)
|
||||
:on-press #(when (not loading-routes?)
|
||||
(cond
|
||||
(= type :add)
|
||||
(open-preferences)
|
||||
on-press (on-press chain-id total-amount)))
|
||||
:on-long-press #(when (not loading-routes?)
|
||||
(cond
|
||||
(= type :add)
|
||||
(open-preferences)
|
||||
on-long-press (on-long-press chain-id)))}]])
|
||||
network-values)])
|
||||
|
||||
(defn render-network-links
|
||||
@@ -155,6 +288,10 @@
|
||||
|
||||
(defn disable-chain
|
||||
[chain-id disabled-from-chain-ids token-available-networks-for-suggested-routes]
|
||||
#_(tap> {:in `disable-chain
|
||||
:chain-id chain-id
|
||||
:disabled-from-chain-ids disabled-from-chain-ids
|
||||
:token-available-networks-for-suggested-routes token-available-networks-for-suggested-routes})
|
||||
(let [disabled-chain-ids
|
||||
(if (contains? (set
|
||||
disabled-from-chain-ids)
|
||||
@@ -176,7 +313,7 @@
|
||||
:text (i18n/label :t/at-least-one-network-must-be-activated)}]))))
|
||||
|
||||
(defn view
|
||||
[{:keys [token theme input-value value valid-input?
|
||||
[{:keys [token theme input-value valid-input? request-fetch-routes
|
||||
lock-fetch-routes? on-press-to-network current-screen-id
|
||||
token-not-supported-in-receiver-networks?]}]
|
||||
(let [token-symbol (:symbol token)
|
||||
@@ -202,19 +339,11 @@
|
||||
(when (and active-screen?
|
||||
(> (count token-available-networks-for-suggested-routes) 0)
|
||||
(not lock-fetch-routes?))
|
||||
(fetch-routes
|
||||
{:amount value
|
||||
:valid-input? valid-input?
|
||||
:bounce-duration-ms 2000
|
||||
:token token})))
|
||||
(request-fetch-routes 2000)))
|
||||
[input-value valid-input?])
|
||||
(rn/use-effect
|
||||
#(when (and active-screen? (> (count token-available-networks-for-suggested-routes) 0))
|
||||
(fetch-routes
|
||||
{:amount value
|
||||
:valid-input? valid-input?
|
||||
:bounce-duration-ms 0
|
||||
:token token}))
|
||||
(request-fetch-routes 0))
|
||||
[disabled-from-chain-ids])
|
||||
[rn/scroll-view {:content-container-style style/routes-container}
|
||||
(when show-routes?
|
||||
@@ -234,6 +363,11 @@
|
||||
chain-id-to-disable
|
||||
disabled-from-chain-ids
|
||||
token-available-networks-for-suggested-routes))
|
||||
|
||||
:on-long-press (fn [chain-id]
|
||||
(edit-amount
|
||||
{:chain-id chain-id
|
||||
:token-symbol token-symbol}))
|
||||
:receiver? false
|
||||
:theme theme
|
||||
:loading-routes? loading-routes?
|
||||
@@ -249,8 +383,5 @@
|
||||
:loading-routes? loading-routes?
|
||||
:theme theme
|
||||
:token-not-supported-in-receiver-networks? token-not-supported-in-receiver-networks?
|
||||
:on-save #(fetch-routes
|
||||
{:amount input-value
|
||||
:valid-input? valid-input?
|
||||
:bounce-duration-ms 0})}]]]))
|
||||
:on-save #(request-fetch-routes 0)}]]]))
|
||||
|
||||
|
||||
@@ -12,5 +12,6 @@
|
||||
:button-one-label (i18n/label :t/review-send)
|
||||
:on-navigate-back (fn []
|
||||
(rf/dispatch [:wallet/clean-disabled-from-networks])
|
||||
(rf/dispatch [:wallet/clean-from-locked-amounts])
|
||||
(rf/dispatch [:wallet/clean-send-amount])
|
||||
(rf/dispatch [:navigate-back]))}])
|
||||
|
||||
@@ -121,7 +121,7 @@
|
||||
network-amounts))
|
||||
|
||||
(defn network-amounts
|
||||
[{:keys [network-values disabled-chain-ids receiver-networks token-networks-ids tx-type receiver?]}]
|
||||
[{:keys [network-values disabled-chain-ids receiver-networks token-networks-ids tx-type receiver? from-locked-amounts]}]
|
||||
(let [disabled-set (set disabled-chain-ids)
|
||||
receiver-networks-set (set receiver-networks)
|
||||
network-values-keys (set (keys network-values))
|
||||
@@ -160,8 +160,12 @@
|
||||
(map
|
||||
(fn [[chain-id amount]]
|
||||
{:chain-id chain-id
|
||||
:total-amount amount
|
||||
:total-amount (let [locked-amount (get from-locked-amounts chain-id)]
|
||||
(if locked-amount
|
||||
locked-amount
|
||||
amount))
|
||||
:type (cond
|
||||
(contains? from-locked-amounts chain-id) :locked
|
||||
(contains? not-available-networks-set chain-id) :not-available
|
||||
(or receiver? (not (contains? disabled-set chain-id))) :default
|
||||
(and (not receiver?) (contains? disabled-set chain-id)) :disabled)}))
|
||||
|
||||
@@ -80,6 +80,7 @@
|
||||
(fn [networks [_ chain-id]]
|
||||
(some #(when (= chain-id (:chain-id %)) %) networks)))
|
||||
|
||||
|
||||
(re-frame/reg-sub
|
||||
:wallet/selected-network-details
|
||||
:<- [:wallet/network-details]
|
||||
|
||||
@@ -131,6 +131,11 @@
|
||||
:<- [:wallet/wallet-send]
|
||||
:-> :disabled-from-chain-ids)
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/wallet-send-from-locked-amounts
|
||||
:<- [:wallet/wallet-send]
|
||||
:-> :from-locked-amounts)
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/wallet-send-from-values-by-chain
|
||||
:<- [:wallet/wallet-send]
|
||||
|
||||
@@ -2650,5 +2650,8 @@
|
||||
"proceed-anyway": "Proceed anyway",
|
||||
"sending-to-unpreferred-networks": "Sending to unpreferred networks",
|
||||
"review-send": "Review send",
|
||||
"review-bridge": "Review bridge"
|
||||
"review-bridge": "Review bridge",
|
||||
"send-from-network" : "Send from {{network}}",
|
||||
"define-amount-sent-from-network" : "Define amount sent from {{network}} network",
|
||||
"dont-auto-recalculate-network": "Don't auto recalculate {{network}}"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user