From eecd1d50e4a27a26b5a24282aaba2e2df4c6c9f5 Mon Sep 17 00:00:00 2001 From: Mohsen Date: Mon, 19 Aug 2024 15:30:03 +0330 Subject: [PATCH] [#19926] feat: allow for disabling testnet mode by pressing the banner (#20935) --- src/status_im/common/alert_banner/view.cljs | 6 ++++-- src/status_im/common/bottom_sheet/view.cljs | 5 +++-- src/status_im/contexts/profile/login/events.cljs | 5 +++-- src/status_im/contexts/settings/wallet/events.cljs | 14 ++++++++++++++ 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/status_im/common/alert_banner/view.cljs b/src/status_im/common/alert_banner/view.cljs index dd6371fe81..191da4ebbb 100644 --- a/src/status_im/common/alert_banner/view.cljs +++ b/src/status_im/common/alert_banner/view.cljs @@ -19,8 +19,10 @@ :text-color (colors/resolve-color :danger theme)}}) (defn- banner - [{:keys [text type second-banner? colors-map]}] - [rn/view (when second-banner? {:style style/second-banner-wrapper}) + [{:keys [text type second-banner? colors-map on-press]}] + [rn/pressable + {:on-press #(when on-press (on-press)) + :style (when second-banner? style/second-banner-wrapper)} [hole-view/hole-view {:style (style/hole-view (get-in colors-map [type :background-color])) :holes (if second-banner? diff --git a/src/status_im/common/bottom_sheet/view.cljs b/src/status_im/common/bottom_sheet/view.cljs index c4d1b1abee..2d81f3e978 100644 --- a/src/status_im/common/bottom_sheet/view.cljs +++ b/src/status_im/common/bottom_sheet/view.cljs @@ -126,7 +126,8 @@ [reanimated/view {:style (reanimated/apply-animations-to-style {:opacity bg-opacity} - {:flex 1 :background-color colors/neutral-100-opa-70})}]] + {:flex 1 + :background-color (if shell? colors/neutral-100-opa-60 colors/neutral-100-opa-70)})}]] ;; sheet [gesture/gesture-detector {:gesture sheet-gesture} [reanimated/view @@ -138,7 +139,7 @@ [quo/blur {:style style/shell-bg :blur-radius (or blur-radius 20) - :blur-amount 32 + :blur-amount 15 :blur-type :transparent :overlay-color :transparent}]]) (when selected-item diff --git a/src/status_im/contexts/profile/login/events.cljs b/src/status_im/contexts/profile/login/events.cljs index a48371dd45..58e755f641 100644 --- a/src/status_im/contexts/profile/login/events.cljs +++ b/src/status_im/contexts/profile/login/events.cljs @@ -251,5 +251,6 @@ config/enable-alert-banner?) {:fx [[:dispatch [:alert-banners/add - {:type :alert - :text (i18n/label :t/testnet-mode-enabled)}]]]}))) + {:type :alert + :text (i18n/label :t/testnet-mode-enabled) + :on-press #(rf/dispatch [:wallet/show-disable-testnet-mode-confirmation])}]]]}))) diff --git a/src/status_im/contexts/settings/wallet/events.cljs b/src/status_im/contexts/settings/wallet/events.cljs index 7c559638f1..d762d76db9 100644 --- a/src/status_im/contexts/settings/wallet/events.cljs +++ b/src/status_im/contexts/settings/wallet/events.cljs @@ -2,7 +2,9 @@ (:require [clojure.string :as string] [native-module.core :as native-module] + [react-native.platform :as platform] [status-im.contexts.settings.wallet.data-store :as data-store] + [status-im.contexts.settings.wallet.network-settings.testnet-mode.view :as testnet] [taoensso.timbre :as log] [utils.i18n :as i18n] [utils.re-frame :as rf] @@ -292,3 +294,15 @@ (rf/reg-event-fx :wallet/make-partially-operable-accounts-fully-operable make-partially-operable-accounts-fully-operable) + +(rf/reg-event-fx :wallet/show-disable-testnet-mode-confirmation + (fn [{:keys [db]} _] + (let [theme (:theme db) + blur? (and (not platform/android?) (= theme :dark))] + {:fx [[:dispatch + [:show-bottom-sheet + {:content (fn [] [testnet/view + {:enable? false + :blur? blur?}]) + :shell? blur? + :theme (when-not platform/android? theme)}]]]})))