rename wallet history -> wallet transactions

This commit is contained in:
Eric Dvorsak 2017-09-12 02:00:19 +02:00 committed by Eric Dvorsak
parent c22060542a
commit a43af5e078
6 changed files with 89 additions and 83 deletions

View File

@ -9,6 +9,7 @@
status-im.ui.screens.group.subs status-im.ui.screens.group.subs
status-im.ui.screens.profile.subs status-im.ui.screens.profile.subs
status-im.ui.screens.wallet.subs status-im.ui.screens.wallet.subs
status-im.ui.screens.wallet.transactions.subs
status-im.transactions.subs status-im.transactions.subs
status-im.bots.subs)) status-im.bots.subs))

View File

@ -44,7 +44,7 @@
[status-im.ui.screens.wallet.send.views :refer [send-transaction]] [status-im.ui.screens.wallet.send.views :refer [send-transaction]]
[status-im.ui.screens.wallet.wallet-list.views :refer [wallet-list-screen]] [status-im.ui.screens.wallet.wallet-list.views :refer [wallet-list-screen]]
[status-im.ui.screens.wallet.history.views :as wallet-history])) [status-im.ui.screens.wallet.transactions.views :as wallet-transactions]))
(defn validate-current-view (defn validate-current-view
[current-view signed-up?] [current-view signed-up?]
@ -103,8 +103,8 @@
:transaction-details transaction-details :transaction-details transaction-details
:confirmation-success confirmation-success :confirmation-success confirmation-success
:contact-list-modal contact-list-modal :contact-list-modal contact-list-modal
:wallet-transactions wallet-history/transactions :wallet-transactions wallet-transactions/transactions
:wallet-transactions-filter wallet-history/filter-history :wallet-transactions-filter wallet-transactions/filter-history
:wallet-transactions-sign-all wallet-history/sign-all :wallet-transactions-sign-all wallet-transactions/sign-all
(throw (str "Unknown modal view: " modal-view)))] (throw (str "Unknown modal view: " modal-view)))]
[component])]])]]))))) [component])]])]])))))

View File

@ -1,8 +1,6 @@
(ns status-im.ui.screens.wallet.subs (ns status-im.ui.screens.wallet.subs
(:require [re-frame.core :refer [reg-sub subscribe]] (:require [re-frame.core :refer [reg-sub subscribe]]
[clojure.string :as string] [status-im.utils.money :as money]))
[status-im.utils.money :as money]
[status-im.utils.datetime :as datetime]))
(reg-sub :balance (reg-sub :balance
(fn [db] (fn [db]
@ -21,10 +19,6 @@
(or (get-in db [:wallet :errors :balance-update]) (or (get-in db [:wallet :errors :balance-update])
(get-in db [:wallet :errors :prices-update])))) (get-in db [:wallet :errors :prices-update]))))
(reg-sub :wallet.transactions/error-message?
(fn [db]
(get-in db [:wallet :errors :transactions-update])))
(reg-sub :eth-balance (reg-sub :eth-balance
:<- [:balance] :<- [:balance]
(fn [balance] (fn [balance]
@ -59,55 +53,3 @@
(reg-sub :wallet/balance-loading? (reg-sub :wallet/balance-loading?
(fn [db] (fn [db]
(get-in db [:wallet :balance-loading?]))) (get-in db [:wallet :balance-loading?])))
(reg-sub :wallet.transactions/transactions-loading?
(fn [db]
(get-in db [:wallet :transactions-loading?])))
(reg-sub :wallet.transactions/transactions
(fn [db]
(group-by :type (get-in db [:wallet :transactions]))))
(reg-sub :wallet.transactions/unsigned-transactions
:<- [:wallet.transactions/transactions]
(fn [transactions]
(:unsigned transactions)))
(reg-sub :wallet.transactions/postponed-transactions-list
:<- [:wallet.transactions/transactions]
(fn [{:keys [postponed]}]
(when postponed
{:title "Postponed"
:key :postponed
:data postponed})))
(reg-sub :wallet.transactions/pending-transactions-list
:<- [:wallet.transactions/transactions]
(fn [{:keys [pending]}]
(when pending
{:title "Pending"
:key :pending
:data pending})))
(reg-sub :wallet.transactions/completed-transactions-list
:<- [:wallet.transactions/transactions]
(fn [{:keys [inbound outbound]}]
(->> (into inbound outbound)
(group-by #(datetime/timestamp->date-key (:timestamp %)))
(sort-by key)
reverse
(map (fn [[k v]]
{:title (datetime/timestamp->mini-date (:timestamp (first v)))
:key k
;; TODO (yenda investigate wether this sort-by is necessary or not)
:data (sort-by :timestamp v)})))))
(reg-sub :wallet.transactions/transactions-history-list
:<- [:wallet.transactions/postponed-transactions-list]
:<- [:wallet.transactions/pending-transactions-list]
:<- [:wallet.transactions/completed-transactions-list]
(fn [[postponed pending completed]]
(cond-> []
postponed (into postponed)
pending (into pending)
completed (into completed))))

View File

@ -1,4 +1,4 @@
(ns status-im.ui.screens.wallet.history.styles (ns status-im.ui.screens.wallet.transactions.styles
(:require [status-im.components.styles :as styles])) (:require [status-im.components.styles :as styles]))
(def error-container (def error-container

View File

@ -0,0 +1,59 @@
(ns status-im.ui.screens.wallet.transactions.subs
(:require [re-frame.core :refer [reg-sub subscribe]]
[status-im.utils.datetime :as datetime]))
(reg-sub :wallet.transactions/transactions-loading?
(fn [db]
(get-in db [:wallet :transactions-loading?])))
(reg-sub :wallet.transactions/error-message?
(fn [db]
(get-in db [:wallet :errors :transactions-update])))
(reg-sub :wallet.transactions/transactions
(fn [db]
(group-by :type (get-in db [:wallet :transactions]))))
(reg-sub :wallet.transactions/unsigned-transactions
:<- [:wallet.transactions/transactions]
(fn [transactions]
(:unsigned transactions)))
(reg-sub :wallet.transactions/postponed-transactions-list
:<- [:wallet.transactions/transactions]
(fn [{:keys [postponed]}]
(when postponed
{:title "Postponed"
:key :postponed
:data postponed})))
(reg-sub :wallet.transactions/pending-transactions-list
:<- [:wallet.transactions/transactions]
(fn [{:keys [pending]}]
(when pending
{:title "Pending"
:key :pending
:data pending})))
(reg-sub :wallet.transactions/completed-transactions-list
:<- [:wallet.transactions/transactions]
(fn [{:keys [inbound outbound]}]
(->> (into inbound outbound)
(group-by #(datetime/timestamp->date-key (:timestamp %)))
(sort-by key)
reverse
(map (fn [[k v]]
{:title (datetime/timestamp->mini-date (:timestamp (first v)))
:key k
;; TODO (yenda investigate wether this sort-by is necessary or not)
:data (sort-by :timestamp v)})))))
(reg-sub :wallet.transactions/transactions-history-list
:<- [:wallet.transactions/postponed-transactions-list]
:<- [:wallet.transactions/pending-transactions-list]
:<- [:wallet.transactions/completed-transactions-list]
(fn [[postponed pending completed]]
(cond-> []
postponed (into postponed)
pending (into pending)
completed (into completed))))

View File

@ -1,4 +1,4 @@
(ns status-im.ui.screens.wallet.history.views (ns status-im.ui.screens.wallet.transactions.views
(:require [re-frame.core :as re-frame] (:require [re-frame.core :as re-frame]
[reagent.core :as reagent] [reagent.core :as reagent]
[status-im.components.button.view :as button] [status-im.components.button.view :as button]
@ -10,7 +10,7 @@
[status-im.components.tabs.views :as tabs] [status-im.components.tabs.views :as tabs]
[status-im.components.toolbar-new.view :as toolbar] [status-im.components.toolbar-new.view :as toolbar]
[status-im.i18n :as i18n] [status-im.i18n :as i18n]
[status-im.ui.screens.wallet.history.styles :as history.styles] [status-im.ui.screens.wallet.transactions.styles :as transactions.styles]
[status-im.ui.screens.wallet.views :as wallet.views] [status-im.ui.screens.wallet.views :as wallet.views]
[status-im.utils.utils :as utils]) [status-im.utils.utils :as utils])
(:require-macros [status-im.utils.views :refer [defview letsubs]])) (:require-macros [status-im.utils.views :refer [defview letsubs]]))
@ -46,13 +46,16 @@
[history-action]])]) [history-action]])])
(defn action-buttons [m] (defn action-buttons [m]
[react/view {:style history.styles/action-buttons} [react/view {:style transactions.styles/action-buttons}
[button/primary-button {:text (i18n/label :t/transactions-sign) :on-press #(on-sign-transaction m)}] [button/primary-button {:text (i18n/label :t/transactions-sign) :on-press #(on-sign-transaction m)}]
[button/secondary-button {:text (i18n/label :t/delete) :on-press #(on-delete-transaction m)}]]) [button/secondary-button {:text (i18n/label :t/delete) :on-press #(on-delete-transaction m)}]])
(defn- unsigned? [type] (= "unsigned" type)) (defn- unsigned? [type] (= "unsigned" type))
(defn- transaction-icon [k background-color color] {:icon k :icon-opts {:color color} :style (history.styles/transaction-icon-background background-color)}) (defn- transaction-icon [k background-color color]
{:icon k
:icon-opts {:color color}
:style (transactions.styles/transaction-icon-background background-color)})
(defn- transaction-type->icon [s] (defn- transaction-type->icon [s]
(case s (case s
@ -72,17 +75,18 @@
(str (i18n/label :t/from) " " from)) (str (i18n/label :t/from) " " from))
(when (unsigned? type) (when (unsigned? type)
[action-buttons m])] [action-buttons m])]
[list/item-icon {:icon :icons/forward :icon-opts history.styles/forward}]]) [list/item-icon {:icon :icons/forward :icon-opts transactions.styles/forward}]])
;; TODO(yenda) hook with re-frame ;; TODO(yenda) hook with re-frame
(defn- empty-text [s] [react/text {:style history.styles/empty-text} s]) (defn- empty-text [s] [react/text {:style transactions.styles/empty-text} s])
(defview history-list [] (defview history-list []
(letsubs [transactions-history-list [:wallet.transactions/transactions-history-list] (letsubs [transactions-history-list [:wallet.transactions/transactions-history-list]
transactions-loading? [:wallet.transactions/transactions-loading?] transactions-loading? [:wallet.transactions/transactions-loading?]
error-message [:wallet.transactions/error-message?]] error-message [:wallet.transactions/error-message?]]
[react/scroll-view {:style styles/flex} [react/scroll-view {:style styles/flex}
(when error-message [wallet.views/error-message-view history.styles/error-container history.styles/error-message]) (when error-message
[wallet.views/error-message-view transactions.styles/error-container transactions.styles/error-message])
[list/section-list {:sections transactions-history-list [list/section-list {:sections transactions-history-list
:render-fn render-transaction :render-fn render-transaction
:empty-component (empty-text (i18n/label :t/transactions-history-empty)) :empty-component (empty-text (i18n/label :t/transactions-history-empty))
@ -113,16 +117,16 @@
(defview sign-all [] (defview sign-all []
[] []
[react/keyboard-avoiding-view {:style history.styles/sign-all-view} [react/keyboard-avoiding-view {:style transactions.styles/sign-all-view}
[react/view {:style history.styles/sign-all-done} [react/view {:style transactions.styles/sign-all-done}
[button/primary-button {:style history.styles/sign-all-done-button [button/primary-button {:style transactions.styles/sign-all-done-button
:text (i18n/label :t/done) :text (i18n/label :t/done)
:on-press #(re-frame/dispatch [:navigate-back])}]] :on-press #(re-frame/dispatch [:navigate-back])}]]
[react/view {:style history.styles/sign-all-popup} [react/view {:style transactions.styles/sign-all-popup}
[react/text {:style history.styles/sign-all-popup-sign-phrase} "one two three"] ;; TODO hook [react/text {:style transactions.styles/sign-all-popup-sign-phrase} "one two three"] ;; TODO hook
[react/text {:style history.styles/sign-all-popup-text} (i18n/label :t/transactions-sign-all-text)] [react/text {:style transactions.styles/sign-all-popup-text} (i18n/label :t/transactions-sign-all-text)]
[react/view {:style history.styles/sign-all-actions} [react/view {:style transactions.styles/sign-all-actions}
[react/text-input {:style history.styles/sign-all-input [react/text-input {:style transactions.styles/sign-all-input
:secure-text-entry true :secure-text-entry true
:placeholder (i18n/label :t/transactions-sign-input-placeholder)}] :placeholder (i18n/label :t/transactions-sign-input-placeholder)}]
[button/primary-button {:text (i18n/label :t/transactions-sign-all) :on-press #(on-sign-transaction %)}]]]]) [button/primary-button {:text (i18n/label :t/transactions-sign-all) :on-press #(on-sign-transaction %)}]]]])
@ -170,12 +174,12 @@
(defn- main-section [view-id tabs] (defn- main-section [view-id tabs]
(let [prev-view-id (reagent/atom @view-id)] (let [prev-view-id (reagent/atom @view-id)]
[tabs/swipable-tabs {:style history.styles/main-section [tabs/swipable-tabs {:style transactions.styles/main-section
:style-tabs history.styles/tabs :style-tabs transactions.styles/tabs
:style-tab-active history.styles/tab-active :style-tab-active transactions.styles/tab-active
:on-view-change #(do (reset! prev-view-id @view-id) :on-view-change #(do (reset! prev-view-id @view-id)
(reset! view-id %))} (reset! view-id %))}
tabs prev-view-id view-id])) tabs prev-view-id view-id]))
;; TODO(yenda) must reflect selected wallet ;; TODO(yenda) must reflect selected wallet