From f5fcc9f45ed252af5c0e03407aa47543731ce898 Mon Sep 17 00:00:00 2001 From: mmilad75 <55688834+mmilad75@users.noreply.github.com> Date: Tue, 16 Apr 2024 16:32:50 +0100 Subject: [PATCH] Wallet: Token Options should be specific to watch only account #18543 (#19583) --- .../contexts/wallet/account/view.cljs | 14 +-- .../add_account/create_account/view.cljs | 2 +- .../wallet/common/token_value/view.cljs | 100 +++++++++++------- .../wallet/sheets/buy_token/style.cljs | 5 + .../wallet/sheets/buy_token/view.cljs | 15 +++ src/status_im/feature_flags.cljs | 11 +- 6 files changed, 94 insertions(+), 53 deletions(-) create mode 100644 src/status_im/contexts/wallet/sheets/buy_token/style.cljs create mode 100644 src/status_im/contexts/wallet/sheets/buy_token/view.cljs diff --git a/src/status_im/contexts/wallet/account/view.cljs b/src/status_im/contexts/wallet/account/view.cljs index e597fb3db1..ffa25306aa 100644 --- a/src/status_im/contexts/wallet/account/view.cljs +++ b/src/status_im/contexts/wallet/account/view.cljs @@ -6,20 +6,10 @@ [status-im.contexts.wallet.account.style :as style] [status-im.contexts.wallet.account.tabs.view :as tabs] [status-im.contexts.wallet.common.account-switcher.view :as account-switcher] - [status-im.contexts.wallet.common.temp :as temp] + [status-im.contexts.wallet.sheets.buy-token.view :as buy-token] [utils.i18n :as i18n] [utils.re-frame :as rf])) -(defn buy-drawer - [] - [:<> - [quo/drawer-top {:title (i18n/label :t/buy-tokens)}] - [rn/flat-list - {:data temp/buy-tokens-list - :style {:padding-horizontal 8 - :padding-bottom 8} - :render-fn quo/settings-item}]]) - (def first-tab-id :assets) (defn tabs-data @@ -55,7 +45,7 @@ :flow-id :wallet-flow}])) :receive-action #(rf/dispatch [:open-modal :screen/wallet.share-address {:status :receive}]) :buy-action #(rf/dispatch [:show-bottom-sheet - {:content buy-drawer}]) + {:content buy-token/view}]) :bridge-action #(rf/dispatch [:wallet/start-bridge])}]) [quo/tabs {:style style/tabs diff --git a/src/status_im/contexts/wallet/add_account/create_account/view.cljs b/src/status_im/contexts/wallet/add_account/create_account/view.cljs index 43219cc932..46aadc36cd 100644 --- a/src/status_im/contexts/wallet/add_account/create_account/view.cljs +++ b/src/status_im/contexts/wallet/add_account/create_account/view.cljs @@ -47,7 +47,7 @@ :image :icon :image-props :i/derivated-path :action :button - :action-props {:on-press #(if (ff/enabled? :ff/wallet.edit-derivation-path) + :action-props {:on-press #(if (ff/enabled? ::ff/wallet.edit-derivation-path) (rf/dispatch [:standard-auth/authorize {:on-auth-success on-auth-success :auth-button-label (i18n/label :t/continue)}]) diff --git a/src/status_im/contexts/wallet/common/token_value/view.cljs b/src/status_im/contexts/wallet/common/token_value/view.cljs index c0a194f496..2779836a66 100644 --- a/src/status_im/contexts/wallet/common/token_value/view.cljs +++ b/src/status_im/contexts/wallet/common/token_value/view.cljs @@ -1,52 +1,80 @@ (ns status-im.contexts.wallet.common.token-value.view (:require [quo.core :as quo] + [status-im.contexts.wallet.sheets.buy-token.view :as buy-token] + [status-im.feature-flags :as ff] [utils.i18n :as i18n] [utils.re-frame :as rf])) +(defn- action-buy + [] + {:icon :i/buy + :accessibility-label :buy + :label (i18n/label :t/buy) + :on-press #(rf/dispatch [:show-bottom-sheet + {:content buy-token/view}]) + :right-icon :i/external}) + +(defn- action-send + [token-data] + {:icon :i/send + :accessibility-label :send + :label (i18n/label :t/send) + :on-press (fn [] + (rf/dispatch [:hide-bottom-sheet]) + (rf/dispatch [:wallet/clean-send-data]) + (rf/dispatch [:wallet/send-select-token + {:token token-data + :start-flow? true}]))}) + +(defn- action-receive + [] + {:icon :i/receive + :accessibility-label :receive + :label (i18n/label :t/receive) + :on-press #(rf/dispatch [:open-modal :screen/wallet.share-address {:status :receive}])}) + +(defn- action-bridge + [] + {:icon :i/bridge + :accessibility-label :bridge + :label (i18n/label :t/bridge) + :on-press #(js/alert "to be implemented")}) + +(defn- action-manage-tokens + [watch-only?] + {:icon :i/settings + :accessibility-label :settings + :label (i18n/label :t/manage-tokens) + :on-press #(js/alert "to be implemented") + :add-divider? (not watch-only?)}) + +(defn- action-hide + [] + {:icon :i/hide + :accessibility-label :hide + :label (i18n/label :t/hide) + :on-press #(js/alert "to be implemented")}) + (defn token-value-drawer - [token] + [token watch-only?] (let [token-data (first (rf/sub [:wallet/current-viewing-account-tokens-filtered (:token token)]))] - [:<> - [quo/action-drawer - [[{:icon :i/buy - :accessibility-label :buy - :label (i18n/label :t/buy) - :on-press #(js/alert "to be implemented") - :right-icon :i/external} - {:icon :i/send - :accessibility-label :send - :label (i18n/label :t/send) - :on-press (fn [] - (rf/dispatch [:hide-bottom-sheet]) - (rf/dispatch [:wallet/clean-send-data]) - (rf/dispatch [:wallet/send-select-token - {:token token-data - :start-flow? true}]))} - {:icon :i/receive - :accessibility-label :receive - :label (i18n/label :t/receive) - :on-press #(js/alert "to be implemented")} - {:icon :i/bridge - :accessibility-label :bridge - :label (i18n/label :t/bridge) - :on-press #(js/alert "to be implemented")} - {:icon :i/settings - :accessibility-label :settings - :label (i18n/label :t/manage-tokens) - :on-press #(js/alert "to be implemented") - :add-divider? true} - {:icon :i/hide - :accessibility-label :hide - :label (i18n/label :t/hide) - :on-press #(js/alert "to be implemented")}]]]])) + [quo/action-drawer + [(cond->> [(when (ff/enabled? ::ff/wallet.assets-modal-manage-tokens) + (action-manage-tokens watch-only?)) + (when (ff/enabled? ::ff/wallet.assets-modal-hide) + (action-hide))] + (not watch-only?) (concat [(action-buy) + (action-send token-data) + (action-receive) + (action-bridge)]))]])) (defn view [item _ _ {:keys [watch-only?]}] [quo/token-value (cond-> item - (not watch-only?) + (or (not watch-only?) (ff/enabled? ::ff/wallet.long-press-watch-only-asset)) (assoc :on-long-press #(rf/dispatch [:show-bottom-sheet - {:content (fn [] [token-value-drawer item]) + {:content (fn [] [token-value-drawer item watch-only?]) :selected-item (fn [] [quo/token-value item])}])))]) diff --git a/src/status_im/contexts/wallet/sheets/buy_token/style.cljs b/src/status_im/contexts/wallet/sheets/buy_token/style.cljs new file mode 100644 index 0000000000..913ae28bc3 --- /dev/null +++ b/src/status_im/contexts/wallet/sheets/buy_token/style.cljs @@ -0,0 +1,5 @@ +(ns status-im.contexts.wallet.sheets.buy-token.style) + +(def list-container + {:padding-horizontal 8 + :padding-bottom 8}) diff --git a/src/status_im/contexts/wallet/sheets/buy_token/view.cljs b/src/status_im/contexts/wallet/sheets/buy_token/view.cljs new file mode 100644 index 0000000000..7330773312 --- /dev/null +++ b/src/status_im/contexts/wallet/sheets/buy_token/view.cljs @@ -0,0 +1,15 @@ +(ns status-im.contexts.wallet.sheets.buy-token.view + (:require [quo.core :as quo] + [react-native.core :as rn] + [status-im.contexts.wallet.common.temp :as temp] + [status-im.contexts.wallet.sheets.buy-token.style :as style] + [utils.i18n :as i18n])) + +(defn view + [] + [:<> + [quo/drawer-top {:title (i18n/label :t/buy-tokens)}] + [rn/flat-list + {:data temp/buy-tokens-list + :style style/list-container + :render-fn quo/settings-item}]]) diff --git a/src/status_im/feature_flags.cljs b/src/status_im/feature_flags.cljs index d6403625c8..83325fd2d7 100644 --- a/src/status_im/feature_flags.cljs +++ b/src/status_im/feature_flags.cljs @@ -10,10 +10,13 @@ (defonce ^:private feature-flags-config (reagent/atom - {::wallet.bridge-token (enabled-in-env? :FLAG_BRIDGE_TOKEN_ENABLED) - ::wallet.edit-derivation-path (enabled-in-env? :FLAG_EDIT_DERIVATION_PATH) - ::wallet.remove-account (enabled-in-env? :FLAG_REMOVE_ACCOUNT_ENABLED) - ::community.edit-account-selection (enabled-in-env? :FLAG_EDIT_ACCOUNT_SELECTION_ENABLED)})) + {::wallet.bridge-token (enabled-in-env? :FLAG_BRIDGE_TOKEN_ENABLED) + ::wallet.edit-derivation-path (enabled-in-env? :FLAG_EDIT_DERIVATION_PATH) + ::wallet.remove-account (enabled-in-env? :FLAG_REMOVE_ACCOUNT_ENABLED) + ::wallet.long-press-watch-only-asset (enabled-in-env? :FLAG_LONG_PRESS_WATCH_ONLY_ASSET_ENABLED) + ::wallet.assets-modal-manage-tokens (enabled-in-env? :FLAG_ASSETS_MODAL_MANAGE_TOKENS) + ::wallet.assets-modal-hide (enabled-in-env? :FLAG_ASSETS_MODAL_HIDE) + ::community.edit-account-selection (enabled-in-env? :FLAG_EDIT_ACCOUNT_SELECTION_ENABLED)})) (defn feature-flags [] @feature-flags-config)