Skip to content

Commit

Permalink
Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrkhalil committed Apr 24, 2024
1 parent f98ea75 commit c80df7f
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 73 deletions.
20 changes: 10 additions & 10 deletions src/quo/components/share/share_qr_code/view.cljs
Original file line number Diff line number Diff line change
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
16 changes: 8 additions & 8 deletions src/quo/components/wallet/account_card/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,14 @@
:metrics? metrics?}]
[rn/pressable
{: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}
: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
Original file line number Diff line number Diff line change
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
137 changes: 85 additions & 52 deletions src/status_im/contexts/wallet/home/view.cljs
Original file line number Diff line number Diff line change
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 @@ -36,59 +38,80 @@
{: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 right-icon
:add-divider? add-divider?
:accessibility-label accessibility-label})
[{: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]
[{: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}
[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)
: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")
: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}
{: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}])
(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]
(map option (options account-name)))
[account-name address]
(keep option (options account-name address)))

(defn account-sheet
[{:keys [key-uid address prod-preferred-chain-ids] account-name :name}]
[{:keys [address] account-name :name}]
[quo/action-drawer
[(sample-options account-name)]])
[(sample-options account-name address)]])

(defn view
[]
Expand Down Expand Up @@ -124,18 +147,28 @@
:data cards
:horizontal true
:separator [rn/view {:style style/separator}]
: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]))
: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
Original file line number Diff line number Diff line change
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

0 comments on commit c80df7f

Please sign in to comment.