-
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.
chore(wallet): add flow for selecting own accounts in sendflows
- Loading branch information
Showing
11 changed files
with
134 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
(ns status-im2.contexts.wallet.send.events | ||
(:require | ||
[utils.number] | ||
[utils.re-frame :as rf])) | ||
|
||
(rf/reg-event-fx :wallet/select-address-tab | ||
(fn [{:keys [db]} [tab]] | ||
{:db (assoc-in db [:wallet :ui :send :select-address-tab] tab)})) | ||
|
||
(rf/reg-event-fx :wallet/select-send-account-address | ||
(fn [{:keys [db]} [address]] | ||
{:db (assoc db [:wallet :ui :send :send-account-address] address)})) |
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
10 changes: 10 additions & 0 deletions
10
src/status_im2/contexts/wallet/send/select_address/tabs/style.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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
(ns status-im2.contexts.wallet.send.select-address.tabs.style) | ||
|
||
(def empty-container-style | ||
{:justify-content :center | ||
:flex 1 | ||
:margin-bottom 44}) | ||
|
||
(def my-accounts-container | ||
{:padding-left 8 | ||
:padding-right 8}) |
57 changes: 57 additions & 0 deletions
57
src/status_im2/contexts/wallet/send/select_address/tabs/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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
(ns status-im2.contexts.wallet.send.select-address.tabs.view | ||
(:require | ||
[quo.core :as quo] | ||
[react-native.gesture :as gesture] | ||
[status-im2.contexts.wallet.send.select-address.tabs.style :as style] | ||
[utils.i18n :as i18n] | ||
[utils.re-frame :as rf])) | ||
|
||
(defn- render-account-item | ||
[{:keys [color address] :as account}] | ||
[quo/account-item | ||
{:account-props (assoc account :customization-color color) | ||
:on-press (fn [] | ||
(rf/dispatch [:wallet/select-send-account-address address]) | ||
(rf/dispatch [:navigate-to-within-stack | ||
[:wallet-select-asset :wallet-select-address]]))}]) | ||
|
||
(def data | ||
[{:id :tab/recent :label (i18n/label :t/recent) :accessibility-label :recent-tab} | ||
{:id :tab/saved :label (i18n/label :t/saved) :accessibility-label :saved-tab} | ||
{:id :tab/contacts :label (i18n/label :t/contacts) :accessibility-label :contacts-tab} | ||
{:id :tab/my-accounts :label (i18n/label :t/my-accounts) :accessibility-label :my-accounts-tab}]) | ||
|
||
(defn my-accounts | ||
[] | ||
(let [other-accounts (rf/sub [:wallet/other-accounts])] | ||
(if (zero? (count other-accounts)) | ||
[quo/empty-state | ||
{:title (i18n/label :t/no-other-accounts) | ||
:description (i18n/label :t/here-is-a-cat-in-a-box-instead) | ||
:placeholder? true | ||
:container-style style/empty-container-style}] | ||
[gesture/flat-list | ||
{:data other-accounts | ||
:render-fn render-account-item | ||
:content-container-style style/my-accounts-container | ||
:shows-vertical-scroll-indicator false}]))) | ||
|
||
(defn view | ||
[selected-tab] | ||
(case selected-tab | ||
:tab/recent [quo/empty-state | ||
{:title (i18n/label :t/no-recent-transactions) | ||
:description (i18n/label :t/make-one-it-is-easy-we-promise) | ||
:placeholder? true | ||
:container-style style/empty-container-style}] | ||
:tab/saved [quo/empty-state | ||
{:title (i18n/label :t/no-saved-addresses) | ||
:description (i18n/label :t/you-like-to-type-43-characters) | ||
:placeholder? true | ||
:container-style style/empty-container-style}] | ||
:tab/contacts [quo/empty-state | ||
{:title (i18n/label :t/no-contacts) | ||
:description (i18n/label :t/no-contacts-description) | ||
:placeholder? true | ||
:container-style style/empty-container-style}] | ||
:tab/my-accounts [my-accounts])) |
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
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
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
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
(ns status-im2.subs.wallet.send | ||
(:require | ||
[re-frame.core :as rf] | ||
[utils.number])) | ||
|
||
(rf/reg-sub | ||
:wallet/send-tab | ||
:<- [:wallet/ui] | ||
(fn [ui] | ||
(get-in ui [:send :select-address-tab]))) |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
(ns status-im2.subs.wallet.send-test | ||
(:require | ||
[cljs.test :refer [is testing]] | ||
[re-frame.db :as rf-db] | ||
status-im2.subs.root | ||
status-im2.subs.wallet.send | ||
[test-helpers.unit :as h] | ||
[utils.re-frame :as rf])) | ||
|
||
(h/deftest-sub :wallet/send-tab | ||
[sub-name] | ||
(testing "returns active tab for selecting address" | ||
(swap! rf-db/app-db assoc-in [:wallet :ui :send :select-address-tab] :tabs/recent) | ||
(is (= :tabs/recent (rf/sub [sub-name]))))) |
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
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