wip
This commit is contained in:
parent
cfc86661cd
commit
895ccc26f0
|
@ -318,6 +318,13 @@
|
||||||
(fn [{:keys [db]} [chain-id amount]]
|
(fn [{:keys [db]} [chain-id amount]]
|
||||||
{:db (assoc-in db [:wallet :ui :send :from-locked-amounts 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
|
(rf/reg-event-fx :wallet/reset-network-amounts-to-zero
|
||||||
(fn [{:keys [db]}]
|
(fn [{:keys [db]}]
|
||||||
(let [sender-network-values (get-in db [:wallet :ui :send :sender-network-values])
|
(let [sender-network-values (get-in db [:wallet :ui :send :sender-network-values])
|
||||||
|
|
|
@ -113,11 +113,10 @@
|
||||||
currency (rf/sub [:profile/currency])
|
currency (rf/sub [:profile/currency])
|
||||||
currency-symbol (rf/sub [:profile/currency-symbol])
|
currency-symbol (rf/sub [:profile/currency-symbol])
|
||||||
send-from-locked-amounts (rf/sub [:wallet/wallet-send-from-locked-amounts])
|
send-from-locked-amounts (rf/sub [:wallet/wallet-send-from-locked-amounts])
|
||||||
existing-locked-amount (when send-from-locked-amounts
|
locked-amount (get send-from-locked-amounts chain-id)
|
||||||
(get send-from-locked-amounts chain-id))
|
|
||||||
network-name-str (string/capitalize (name network-name))
|
network-name-str (string/capitalize (name network-name))
|
||||||
[input-state set-input-state] (rn/use-state (cond-> controlled-input/init-state
|
[input-state set-input-state] (rn/use-state (cond-> controlled-input/init-state
|
||||||
existing-locked-amount (controlled-input/set-input-value existing-locked-amount)))
|
locked-amount (controlled-input/set-input-value locked-amount)))
|
||||||
[crypto-currency? set-crypto-currency] (rn/use-state true)
|
[crypto-currency? set-crypto-currency] (rn/use-state true)
|
||||||
conversion-rate (-> token
|
conversion-rate (-> token
|
||||||
:market-values-per-currency
|
:market-values-per-currency
|
||||||
|
@ -135,7 +134,11 @@
|
||||||
current-crypto-limit
|
current-crypto-limit
|
||||||
current-fiat-limit)
|
current-fiat-limit)
|
||||||
crypto-decimals token-decimals
|
crypto-decimals token-decimals
|
||||||
input-amount (controlled-input/input-value input-state)]
|
input-amount (controlled-input/input-value input-state)
|
||||||
|
[is-amount-locked? set-is-amount-locked] (rn/use-state (some? locked-amount))
|
||||||
|
unlock-amount (fn []
|
||||||
|
(rf/dispatch [:wallet/unlock-from-amount chain-id]))]
|
||||||
|
|
||||||
(rn/use-effect
|
(rn/use-effect
|
||||||
(fn []
|
(fn []
|
||||||
(set-input-state #(controlled-input/set-upper-limit % current-limit)))
|
(set-input-state #(controlled-input/set-upper-limit % current-limit)))
|
||||||
|
@ -188,21 +191,24 @@
|
||||||
;; :on-token-press show-select-asset-sheet
|
;; :on-token-press show-select-asset-sheet
|
||||||
}]
|
}]
|
||||||
[quo/disclaimer
|
[quo/disclaimer
|
||||||
{:on-change #(tap> {:checked %})
|
{:on-change (fn [checked?]
|
||||||
:checked? existing-locked-amount}
|
(tap> {:checked checked?})
|
||||||
|
(set-is-amount-locked checked?))
|
||||||
|
:checked? is-amount-locked?}
|
||||||
(i18n/label :t/dont-auto-recalculate-network {:network network-name-str})]
|
(i18n/label :t/dont-auto-recalculate-network {:network network-name-str})]
|
||||||
[quo/bottom-actions
|
[quo/bottom-actions
|
||||||
{:actions :one-action
|
{:actions :one-action
|
||||||
:button-one-label (i18n/label :t/update)
|
:button-one-label (i18n/label :t/update)
|
||||||
:button-one-props {:on-press #(do
|
:button-one-props {:on-press (fn []
|
||||||
|
(if is-amount-locked?
|
||||||
(let [limit-in-crypto (if crypto-currency?
|
(let [limit-in-crypto (if crypto-currency?
|
||||||
input-amount
|
input-amount
|
||||||
(number/remove-trailing-zeroes
|
(number/remove-trailing-zeroes
|
||||||
(.toFixed (/ input-amount
|
(.toFixed (/ input-amount
|
||||||
conversion-rate)
|
conversion-rate)
|
||||||
crypto-decimals)))]
|
crypto-decimals)))]
|
||||||
(when on-update
|
(rf/dispatch [:wallet/lock-from-amount chain-id limit-in-crypto]))
|
||||||
(on-update chain-id limit-in-crypto)))
|
(rf/dispatch [:wallet/unlock-from-amount chain-id]))
|
||||||
(rf/dispatch [:hide-bottom-sheet]))
|
(rf/dispatch [:hide-bottom-sheet]))
|
||||||
:disabled? (or (controlled-input/empty-value? input-state)
|
:disabled? (or (controlled-input/empty-value? input-state)
|
||||||
(controlled-input/input-error input-state))}}]
|
(controlled-input/input-error input-state))}}]
|
||||||
|
@ -216,6 +222,7 @@
|
||||||
regex-pattern (str "^\\d*\\.?\\d{0," max-decimals "}$")
|
regex-pattern (str "^\\d*\\.?\\d{0," max-decimals "}$")
|
||||||
regex (re-pattern regex-pattern)]
|
regex (re-pattern regex-pattern)]
|
||||||
(when (re-matches regex new-text)
|
(when (re-matches regex new-text)
|
||||||
|
(set-is-amount-locked true)
|
||||||
(set-input-state #(controlled-input/add-character % c)))))
|
(set-input-state #(controlled-input/add-character % c)))))
|
||||||
:on-delete (fn []
|
:on-delete (fn []
|
||||||
(set-input-state controlled-input/delete-last))
|
(set-input-state controlled-input/delete-last))
|
||||||
|
@ -372,9 +379,7 @@
|
||||||
:on-long-press (fn [chain-id]
|
:on-long-press (fn [chain-id]
|
||||||
(edit-amount
|
(edit-amount
|
||||||
{:chain-id chain-id
|
{:chain-id chain-id
|
||||||
:token-symbol token-symbol
|
:token-symbol token-symbol}))
|
||||||
:on-update (fn [chain-id limit-in-crypto]
|
|
||||||
(rf/dispatch [:wallet/lock-from-amount chain-id limit-in-crypto]))}))
|
|
||||||
:receiver? false
|
:receiver? false
|
||||||
:theme theme
|
:theme theme
|
||||||
:loading-routes? loading-routes?
|
:loading-routes? loading-routes?
|
||||||
|
|
Loading…
Reference in New Issue