-
Notifications
You must be signed in to change notification settings - Fork 985
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
72 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 64 additions & 51 deletions
115
src/status_im/contexts/wallet/common/token_value/view.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,78 @@ | ||
(ns status-im.contexts.wallet.common.token-value.view | ||
(:require [quo.core :as quo] | ||
[status-im.feature-flags :as ff] | ||
[utils.i18n :as i18n] | ||
[utils.re-frame :as rf])) | ||
|
||
(defn watch-only-token-value-drawer | ||
(defn- action-buy | ||
[] | ||
[quo/action-drawer | ||
[[{:icon :i/settings | ||
:accessibility-label :settings | ||
:label (i18n/label :t/manage-tokens) | ||
:on-press #(js/alert "to be implemented")} | ||
{:icon :i/hide | ||
:accessibility-label :hide | ||
:label (i18n/label :t/hide) | ||
:on-press #(js/alert "to be implemented")}]]]) | ||
{:icon :i/buy | ||
:accessibility-label :buy | ||
:label (i18n/label :t/buy) | ||
:on-press #(js/alert "to be implemented") | ||
: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")}]]])) | ||
[(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 | ||
(merge item | ||
{:on-long-press | ||
#(rf/dispatch | ||
[:show-bottom-sheet | ||
{:content (fn [] | ||
(if watch-only? | ||
[watch-only-token-value-drawer] | ||
[token-value-drawer item])) | ||
:selected-item (fn [] [quo/token-value item])}])})]) | ||
(cond-> item | ||
(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 watch-only?]) | ||
:selected-item (fn [] [quo/token-value item])}])))]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters