mirror of
https://github.com/status-im/status-react.git
synced 2025-01-18 15:01:28 +00:00
feat: disable swap and bridge options on testnet mode (#21343)
Signed-off-by: Brian Sztamfater <brian@status.im>
This commit is contained in:
parent
60fc4f1b9a
commit
0c3e836272
@ -1,4 +1,5 @@
|
|||||||
(ns quo.components.buttons.wallet-ctas.style)
|
(ns quo.components.buttons.wallet-ctas.style
|
||||||
|
(:require [quo.foundations.colors :as colors]))
|
||||||
|
|
||||||
(def inner-container
|
(def inner-container
|
||||||
{:flex-direction :row
|
{:flex-direction :row
|
||||||
@ -10,3 +11,9 @@
|
|||||||
:width 77.75
|
:width 77.75
|
||||||
:justify-content :center
|
:justify-content :center
|
||||||
:align-items :center})
|
:align-items :center})
|
||||||
|
|
||||||
|
(defn action-button-text
|
||||||
|
[theme disabled?]
|
||||||
|
(cond-> {:margin-top 4
|
||||||
|
:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)}
|
||||||
|
disabled? (assoc :opacity 0.5)))
|
||||||
|
@ -3,28 +3,28 @@
|
|||||||
[quo.components.buttons.wallet-button.view :as wallet-button]
|
[quo.components.buttons.wallet-button.view :as wallet-button]
|
||||||
[quo.components.buttons.wallet-ctas.style :as style]
|
[quo.components.buttons.wallet-ctas.style :as style]
|
||||||
[quo.components.markdown.text :as text]
|
[quo.components.markdown.text :as text]
|
||||||
[quo.foundations.colors :as colors]
|
|
||||||
[quo.theme :as quo.theme]
|
[quo.theme :as quo.theme]
|
||||||
[react-native.core :as rn]
|
[react-native.core :as rn]
|
||||||
[utils.i18n :as i18n]))
|
[utils.i18n :as i18n]))
|
||||||
|
|
||||||
|
|
||||||
(defn action-button
|
(defn action-button
|
||||||
[{:keys [icon text on-press theme accessibility-label]}]
|
[{:keys [icon text on-press theme accessibility-label disabled?]}]
|
||||||
[rn/view
|
[rn/view
|
||||||
{:style style/button-container
|
{:style style/button-container
|
||||||
:accessibility-label accessibility-label}
|
:accessibility-label accessibility-label}
|
||||||
[wallet-button/view
|
[wallet-button/view
|
||||||
{:icon icon
|
{:icon icon
|
||||||
:on-press on-press}]
|
:disabled? disabled?
|
||||||
|
:on-press on-press}]
|
||||||
[text/text
|
[text/text
|
||||||
{:weight :medium
|
{:weight :medium
|
||||||
:size :paragraph-2
|
:size :paragraph-2
|
||||||
:style {:margin-top 4
|
:style (style/action-button-text theme disabled?)} text]])
|
||||||
:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)}} text]])
|
|
||||||
|
|
||||||
(defn view
|
(defn view
|
||||||
[{:keys [buy-action send-action receive-action bridge-action swap-action container-style]}]
|
[{:keys [buy-action send-action receive-action bridge-action swap-action bridge-disabled?
|
||||||
|
swap-disabled? container-style]}]
|
||||||
(let [theme (quo.theme/use-theme)]
|
(let [theme (quo.theme/use-theme)]
|
||||||
[rn/view {:style container-style}
|
[rn/view {:style container-style}
|
||||||
[rn/view {:style style/inner-container}
|
[rn/view {:style style/inner-container}
|
||||||
@ -52,10 +52,12 @@
|
|||||||
:text (i18n/label :t/swap)
|
:text (i18n/label :t/swap)
|
||||||
:on-press swap-action
|
:on-press swap-action
|
||||||
:theme theme
|
:theme theme
|
||||||
|
:disabled? swap-disabled?
|
||||||
:accessibility-label :swap}])
|
:accessibility-label :swap}])
|
||||||
[action-button
|
[action-button
|
||||||
{:icon :i/bridge
|
{:icon :i/bridge
|
||||||
:text (i18n/label :t/bridge)
|
:text (i18n/label :t/bridge)
|
||||||
:on-press bridge-action
|
:on-press bridge-action
|
||||||
:theme theme
|
:theme theme
|
||||||
|
:disabled? bridge-disabled?
|
||||||
:accessibility-label :bridge}]]]))
|
:accessibility-label :bridge}]]]))
|
||||||
|
@ -26,7 +26,8 @@
|
|||||||
(let [selected-tab (or (rf/sub [:wallet/account-tab]) first-tab-id)
|
(let [selected-tab (or (rf/sub [:wallet/account-tab]) first-tab-id)
|
||||||
{:keys [name color formatted-balance
|
{:keys [name color formatted-balance
|
||||||
watch-only?]} (rf/sub [:wallet/current-viewing-account])
|
watch-only?]} (rf/sub [:wallet/current-viewing-account])
|
||||||
customization-color (rf/sub [:profile/customization-color])]
|
customization-color (rf/sub [:profile/customization-color])
|
||||||
|
testnet-mode? (rf/sub [:profile/test-networks-enabled?])]
|
||||||
(hot-reload/use-safe-unmount (fn []
|
(hot-reload/use-safe-unmount (fn []
|
||||||
(rf/dispatch [:wallet/close-account-page])
|
(rf/dispatch [:wallet/close-account-page])
|
||||||
(rf/dispatch [:wallet/clean-current-viewing-account])))
|
(rf/dispatch [:wallet/clean-current-viewing-account])))
|
||||||
@ -46,23 +47,25 @@
|
|||||||
[quo/wallet-graph {:time-frame :empty}])
|
[quo/wallet-graph {:time-frame :empty}])
|
||||||
(when (not watch-only?)
|
(when (not watch-only?)
|
||||||
[quo/wallet-ctas
|
[quo/wallet-ctas
|
||||||
{:container-style style/cta-buttons
|
{:container-style style/cta-buttons
|
||||||
:send-action (fn []
|
:send-action (fn []
|
||||||
(rf/dispatch [:wallet/clean-send-data])
|
(rf/dispatch [:wallet/clean-send-data])
|
||||||
(rf/dispatch [:wallet/wizard-navigate-forward
|
(rf/dispatch [:wallet/wizard-navigate-forward
|
||||||
{:start-flow? true
|
{:start-flow? true
|
||||||
:flow-id :wallet-send-flow}]))
|
:flow-id :wallet-send-flow}]))
|
||||||
:receive-action #(rf/dispatch [:open-modal :screen/wallet.share-address
|
:receive-action #(rf/dispatch [:open-modal :screen/wallet.share-address
|
||||||
{:status :receive}])
|
{:status :receive}])
|
||||||
:buy-action #(rf/dispatch [:show-bottom-sheet
|
:buy-action #(rf/dispatch [:show-bottom-sheet
|
||||||
{:content buy-token/view}])
|
{:content buy-token/view}])
|
||||||
:bridge-action (fn []
|
:bridge-action (fn []
|
||||||
(rf/dispatch [:wallet/clean-send-data])
|
(rf/dispatch [:wallet/clean-send-data])
|
||||||
(rf/dispatch [:wallet/start-bridge]))
|
(rf/dispatch [:wallet/start-bridge]))
|
||||||
:swap-action (when (ff/enabled? ::ff/wallet.swap)
|
:swap-action (when (ff/enabled? ::ff/wallet.swap)
|
||||||
(fn []
|
(fn []
|
||||||
(rf/dispatch [:wallet.tokens/get-token-list])
|
(rf/dispatch [:wallet.tokens/get-token-list])
|
||||||
(rf/dispatch [:open-modal :screen/wallet.swap-select-asset-to-pay])))}])
|
(rf/dispatch [:open-modal :screen/wallet.swap-select-asset-to-pay])))
|
||||||
|
:bridge-disabled? testnet-mode?
|
||||||
|
:swap-disabled? testnet-mode?}])
|
||||||
[quo/tabs
|
[quo/tabs
|
||||||
{:style style/tabs
|
{:style style/tabs
|
||||||
:size 32
|
:size 32
|
||||||
|
@ -37,20 +37,21 @@
|
|||||||
#(rf/dispatch [:open-modal :screen/share-shell {:initial-tab :wallet}]))})
|
#(rf/dispatch [:open-modal :screen/share-shell {:initial-tab :wallet}]))})
|
||||||
|
|
||||||
(defn- action-bridge
|
(defn- action-bridge
|
||||||
[{:keys [bridge-disabled?] :as params}]
|
[{:keys [bridge-disabled? testnet-mode?] :as params}]
|
||||||
{:icon :i/bridge
|
{:icon :i/bridge
|
||||||
:accessibility-label :bridge
|
:accessibility-label :bridge
|
||||||
:label (i18n/label :t/bridge)
|
:label (i18n/label :t/bridge)
|
||||||
:disabled? bridge-disabled?
|
:disabled? (or testnet-mode? bridge-disabled?)
|
||||||
:on-press (fn []
|
:on-press (fn []
|
||||||
(rf/dispatch [:hide-bottom-sheet])
|
(rf/dispatch [:hide-bottom-sheet])
|
||||||
(rf/dispatch [:wallet/bridge-select-token params]))})
|
(rf/dispatch [:wallet/bridge-select-token params]))})
|
||||||
|
|
||||||
(defn- action-swap
|
(defn- action-swap
|
||||||
[{:keys [token token-symbol]}]
|
[{:keys [token token-symbol testnet-mode?]}]
|
||||||
{:icon :i/swap
|
{:icon :i/swap
|
||||||
:accessibility-label :swap
|
:accessibility-label :swap
|
||||||
:label (i18n/label :t/swap)
|
:label (i18n/label :t/swap)
|
||||||
|
:disabled? testnet-mode?
|
||||||
:on-press (fn []
|
:on-press (fn []
|
||||||
(rf/dispatch [:hide-bottom-sheet])
|
(rf/dispatch [:hide-bottom-sheet])
|
||||||
(rf/dispatch [:wallet.swap/start
|
(rf/dispatch [:wallet.swap/start
|
||||||
@ -79,8 +80,10 @@
|
|||||||
{:query token-symbol}]))
|
{:query token-symbol}]))
|
||||||
selected-account (rf/sub [:wallet/current-viewing-account-address])
|
selected-account (rf/sub [:wallet/current-viewing-account-address])
|
||||||
token-owners (rf/sub [:wallet/operable-addresses-with-token-symbol token-symbol])
|
token-owners (rf/sub [:wallet/operable-addresses-with-token-symbol token-symbol])
|
||||||
params (cond-> {:start-flow? true
|
testnet-mode? (rf/sub [:profile/test-networks-enabled?])
|
||||||
:owners token-owners}
|
params (cond-> {:start-flow? true
|
||||||
|
:owners token-owners
|
||||||
|
:testnet-mode? testnet-mode?}
|
||||||
selected-account
|
selected-account
|
||||||
(assoc :token token-data
|
(assoc :token token-data
|
||||||
:stack-id :screen/wallet.accounts
|
:stack-id :screen/wallet.accounts
|
||||||
|
Loading…
x
Reference in New Issue
Block a user