Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show a menu of operations for a saved address and add share and show QR code for a saved address #19782

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/quo/components/share/share_qr_code/view.cljs
Expand Up @@ -23,24 +23,24 @@
[{:keys [on-legacy-press on-multichain-press address]}]
[rn/view {:style style/header-container}
[tab/view
{:accessibility-label :share-qr-code-multichain-tab
:id :wallet-multichain-tab
{:accessibility-label :share-qr-code-legacy-tab
:id :wallet-legacy-tab
:active-item-container-style style/header-tab-active
:item-container-style style/header-tab-inactive
:size 24
:active (= :multichain address)
:on-press on-multichain-press}
(i18n/label :t/multichain)]
:active (= :legacy address)
:on-press on-legacy-press}
(i18n/label :t/legacy)]
[rn/view {:style style/space-between-tabs}]
[tab/view
{:accessibility-label :share-qr-code-legacy-tab
:id :wallet-legacy-tab
{:accessibility-label :share-qr-code-multichain-tab
:id :wallet-multichain-tab
:active-item-container-style style/header-tab-active
:item-container-style style/header-tab-inactive
:size 24
:active (= :legacy address)
:on-press on-legacy-press}
(i18n/label :t/legacy)]])
:active (= :multichain address)
:on-press on-multichain-press}
(i18n/label :t/multichain)]])

(defn- info-label
[share-qr-code-type]
Expand Down
19 changes: 10 additions & 9 deletions src/quo/components/wallet/account_card/view.cljs
Expand Up @@ -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))
Expand All @@ -110,14 +110,15 @@
:theme theme
:metrics? metrics?}]
[rn/pressable
{:on-press-in on-press-in
:on-press-out on-press-out
:style (style/card {:customization-color customization-color
:type type
:theme theme
:pressed? pressed?
:metrics? metrics?})
:on-press on-press}
{: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
:theme theme
:pressed? pressed?
:metrics? metrics?})
:on-press on-press}
(when (and customization-color (and (not watch-only?) (not missing-keypair?)))
[customization-colors/overlay
{:customization-color customization-color
Expand Down
13 changes: 10 additions & 3 deletions src/status_im/contexts/wallet/events.cljs
Expand Up @@ -26,10 +26,17 @@
:type :positive
:text (i18n/label :t/account-created {:name (:name account)})}]]]})))


(defn set-current-viewing-account
[{:keys [db]} [address]]
{:db (assoc-in db [:wallet :current-viewing-account-address] address)})

(rf/reg-event-fx :wallet/set-current-viewing-account set-current-viewing-account)

(rf/reg-event-fx :wallet/navigate-to-account
(fn [{:keys [db]} [address]]
{:db (assoc-in db [:wallet :current-viewing-account-address] address)
:fx [[:dispatch [:navigate-to :screen/wallet.accounts address]]]}))
(fn [_cofx [address]]
{:fx [[:dispatch [:wallet/set-current-viewing-account address]]
[:dispatch [:navigate-to :screen/wallet.accounts address]]]}))

(rf/reg-event-fx :wallet/navigate-to-new-account
(fn [{:keys [db]} [address]]
Expand Down
101 changes: 100 additions & 1 deletion src/status_im/contexts/wallet/home/view.cljs
Expand Up @@ -2,7 +2,9 @@
(:require
[quo.core :as quo]
[react-native.core :as rn]
[react-native.platform :as platform]
[status-im.common.home.top-nav.view :as common.top-nav]
[status-im.config :as config]
[status-im.contexts.wallet.home.style :as style]
[status-im.contexts.wallet.home.tabs.view :as tabs]
[status-im.contexts.wallet.sheets.network-filter.view :as network-filter]
Expand Down Expand Up @@ -35,6 +37,82 @@
{: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 add-divider? accessibility-label right-icon] :as opt}]
(when opt
^{:key label}
{:icon icon
:label label
:on-press on-press
:danger? danger?
:sub-label sub-label
:right-icon right-icon
:add-divider? add-divider?
:accessibility-label accessibility-label}))

(defn options
[account-name address]
[(when config/show-not-implemented-features?
{: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})
(when config/show-not-implemented-features?
{: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})
(when config/show-not-implemented-features?
{: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
:on-press #(rf/dispatch
[:open-share
{:options (if platform/ios?
{:activityItemSources [{:placeholderItem {:type :text
:content address}
:item {:default {:type :text
:content
address}}
:linkMetadata {:title address}}]}
{:title address
:subject address
:message address
:isNewTask true})}])
:label (i18n/label :t/share-address)
:accessibility-label :manage-notifications}
{:icon :i/qr-code
:label (i18n/label :t/show-address-qr)
:on-press (fn []
(rf/dispatch [:wallet/set-current-viewing-account address])
(rf/dispatch [:open-modal :screen/wallet.share-address {:status :share}]))
:accessibility-label :manage-notifications}
(when config/show-not-implemented-features?
{:icon :i/edit
:label (i18n/label :t/edit-account)
:on-press #(rf/dispatch [:navigate-to :screen/wallet.edit-account])
:accessibility-label :manage-notifications})
(when config/show-not-implemented-features?
{: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 address]
(keep option (options account-name address)))

(defn account-sheet
[{:keys [address] account-name :name}]
[quo/action-drawer
[(sample-options account-name address)]])

(defn view
[]
(let [[selected-tab set-selected-tab] (rn/use-state (:id (first tabs-data)))
Expand Down Expand Up @@ -69,7 +147,28 @@
:data cards
:horizontal true
:separator [rn/view {:style style/separator}]
:render-fn (fn [item] [quo/account-card item])
:render-fn (fn [{:keys [address 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 address
: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
Expand Down
1 change: 1 addition & 0 deletions src/status_im/events.cljs
Expand Up @@ -37,6 +37,7 @@
status-im.contexts.wallet.common.wizard.events
status-im.contexts.wallet.effects
status-im.contexts.wallet.events
status-im.contexts.wallet.save-address.events
status-im.contexts.wallet.send.events
status-im.contexts.wallet.signals
[status-im.db :as db]
Expand Down
4 changes: 3 additions & 1 deletion translations/en.json
Expand Up @@ -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}}"
}