Compare commits

...
Author SHA1 Message Date
ibrkhalil c80df7f7a9 Improvements 2024-04-24 15:32:21 +02:00
ibrkhalil f98ea75adb cleanups 2024-04-24 15:32:21 +02:00
ibrkhalil 4540500da2 Show a menu of operations for a saved address 2024-04-24 15:32:20 +02:00
6 changed files with 135 additions and 25 deletions
@@ -22,16 +22,6 @@
(defn- header
[{: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
: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)]
[rn/view {:style style/space-between-tabs}]
[tab/view
{:accessibility-label :share-qr-code-legacy-tab
:id :wallet-legacy-tab
@@ -40,7 +30,17 @@
:size 24
:active (= :legacy address)
:on-press on-legacy-press}
(i18n/label :t/legacy)]])
(i18n/label :t/legacy)]
[rn/view {:style style/space-between-tabs}]
[tab/view
{: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 (= :multichain address)
:on-press on-multichain-press}
(i18n/label :t/multichain)]])
(defn- info-label
[share-qr-code-type]
@@ -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,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
+10 -3
View File
@@ -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]]
+100 -1
View File
@@ -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]
@@ -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)))
@@ -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
+1
View File
@@ -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]
+3 -1
View File
@@ -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}}"
}