From 4540500da29ff55655135f6cea31cc578ee3e766 Mon Sep 17 00:00:00 2001 From: ibrkhalil Date: Wed, 24 Apr 2024 12:20:29 +0200 Subject: [PATCH] Show a menu of operations for a saved address --- .../components/wallet/account_card/view.cljs | 5 +- src/status_im/contexts/wallet/home/view.cljs | 68 ++++++++++++++++++- translations/en.json | 4 +- 3 files changed, 73 insertions(+), 4 deletions(-) diff --git a/src/quo/components/wallet/account_card/view.cljs b/src/quo/components/wallet/account_card/view.cljs index 84c912b629..5c352d5b64 100644 --- a/src/quo/components/wallet/account_card/view.cljs +++ b/src/quo/components/wallet/account_card/view.cljs @@ -96,7 +96,7 @@ (defn- user-account [{:keys [name balance percentage-value loading? amount customization-color type emoji metrics? - on-press]}] + on-press on-long-press]}] (let [theme (quo.theme/use-theme) [pressed? set-pressed] (rn/use-state false) on-press-in (rn/use-callback #(set-pressed true)) @@ -110,7 +110,8 @@ :theme theme :metrics? metrics?}] [rn/pressable - {:on-press-in on-press-in + {:on-long-press on-long-press + :on-press-in on-press-in :on-press-out on-press-out :style (style/card {:customization-color customization-color :type type diff --git a/src/status_im/contexts/wallet/home/view.cljs b/src/status_im/contexts/wallet/home/view.cljs index 307de25720..14dc043cd8 100644 --- a/src/status_im/contexts/wallet/home/view.cljs +++ b/src/status_im/contexts/wallet/home/view.cljs @@ -35,6 +35,61 @@ {:id :collectibles :label (i18n/label :t/collectibles) :accessibility-label :collectibles-tab} {:id :activity :label (i18n/label :t/activity) :accessibility-label :activity-tab}]) +(defn option + [{:keys [icon label on-press danger? sub-label chevron? add-divider? accessibility-label right-icon]}] + {:icon icon + :label label + :on-press on-press + :danger? danger? + :sub-label sub-label + :right-icon (or right-icon (when chevron? :i/chevron-right)) + :add-divider? add-divider? + :accessibility-label accessibility-label}) + +(defn options + [account-name] + [{:icon :i/arrow-up + :label (i18n/label :t/send-to-user {:user account-name}) + :on-press #(js/alert "TODO: to be implemented, requires design input") + :accessibility-label :manage-notifications} + {:icon :i/link + :right-icon :i/external + :label (i18n/label :t/view-address-on-website {:website "Etherscan"}) + :on-press #(js/alert "TODO: to be implemented, requires design input") + :accessibility-label :manage-notifications} + {:icon :i/link + :right-icon :i/external + :label (i18n/label :t/view-address-on-website {:website "Optimistic"}) + :on-press #(js/alert "TODO: to be implemented, requires design input") + :accessibility-label :manage-notifications} + {:icon :i/share + :label (i18n/label :t/share-address) + :on-press #(js/alert "TODO: to be implemented, requires design input") + :accessibility-label :manage-notifications} + {:icon :i/qr-code + :label (i18n/label :t/show-address-qr) + :on-press #(js/alert "TODO: to be implemented, requires design input") + :accessibility-label :manage-notifications} + {:icon :i/edit + :label (i18n/label :t/edit-account) + :on-press #(js/alert "TODO: to be implemented, requires design input") + :accessibility-label :manage-notifications} + {:icon :i/delete + :label (i18n/label :t/remove-account) + :on-press #(js/alert "TODO: to be implemented, requires design input") + :danger? true + :accessibility-label :manage-notifications + :add-divider? true}]) + +(defn sample-options + [account-name] + (map option (options account-name))) + +(defn account-sheet + [{:keys [key-uid address prod-preferred-chain-ids] account-name :name}] + [quo/action-drawer + [(sample-options account-name)]]) + (defn view [] (let [[selected-tab set-selected-tab] (rn/use-state (:id (first tabs-data))) @@ -69,7 +124,18 @@ :data cards :horizontal true :separator [rn/view {:style style/separator}] - :render-fn (fn [item] [quo/account-card item]) + :render-fn (fn [{:keys [public-key ens-name color] account-name :name :as item}] + (let [updated-item (assoc item :on-long-press (fn [] (rf/dispatch [:show-bottom-sheet + {:selected-item (fn [] + [quo/saved-address {:active-state? false + :user-props {:name account-name + :address public-key + :ens ens-name + :customization-color color}}]) + :content (fn [] + [account-sheet + item])}])))] + [quo/account-card updated-item])) :shows-horizontal-scroll-indicator false}] [quo/tabs {:style style/tabs diff --git a/translations/en.json b/translations/en.json index 0234e4f9f8..02655141f7 100644 --- a/translations/en.json +++ b/translations/en.json @@ -2589,5 +2589,7 @@ "private-key-public-address": "Public address of private key", "this-account-has-no-activity": "This account has no activity", "this-address-has-activity": "This address has activity", - "scanning-for-activity": "Scanning for activity..." + "scanning-for-activity": "Scanning for activity...", + "send-to-user": "Send to {{user}}", + "view-address-on-website": "View address on {{website}}" }