This commit is contained in:
Gustavo Nunes 2017-05-04 01:41:53 -03:00 committed by Roman Volosovskyi
parent b5edab5a21
commit 0359c2819b
2 changed files with 52 additions and 39 deletions

View File

@ -5,6 +5,7 @@
[status-im.components.common.common :as common] [status-im.components.common.common :as common]
[status-im.components.sticky-button :as sticky-button] [status-im.components.sticky-button :as sticky-button]
[status-im.components.status-bar :as status-bar] [status-im.components.status-bar :as status-bar]
[status-im.components.sync-state.offline :as offline-view]
[status-im.components.toolbar-new.actions :as act] [status-im.components.toolbar-new.actions :as act]
[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]
@ -51,22 +52,28 @@
(defview transaction-details [] (defview transaction-details []
[{:keys [id] :as transaction} [:get :selected-transaction] [{:keys [id] :as transaction} [:get :selected-transaction]
{:keys [password]} [:get :confirm-transactions] {:keys [password]} [:get :confirm-transactions]
confirmed? [:get-in [:transaction-details-ui-props :confirmed?]]] confirmed? [:get-in [:transaction-details-ui-props :confirmed?]]
{:component-did-update #(when-not transaction (rf/dispatch [:navigate-to-modal :unsigned-transactions])) sync-state [:get :sync-state]
network-status [:get :network-status]]
{:component-did-update #(when-not transaction (rf/dispatch [:navigate-to-modal :unsigned-transactions]))
:component-will-unmount #(rf/dispatch [:set-in [:transaction-details-ui-props :confirmed?] false])} :component-will-unmount #(rf/dispatch [:set-in [:transaction-details-ui-props :confirmed?] false])}
[rn/keyboard-avoiding-view {:style st/transactions-screen} (let [offline? (or (= network-status :offline) (= sync-state :offline))]
[status-bar/status-bar {:type :transaction}] [rn/keyboard-avoiding-view {:style st/transactions-screen}
[toolbar-view] [status-bar/status-bar {:type :transaction}]
[rn/scroll-view st/details-screen-content-container [toolbar-view]
[transactions-list-item/view transaction #(rf/dispatch [:navigate-to-modal :unsigned-transactions])] [rn/scroll-view st/details-screen-content-container
[common/separator st/details-separator st/details-separator-wrapper] [transactions-list-item/view transaction #(rf/dispatch [:navigate-to-modal :unsigned-transactions])]
[details transaction]] [common/separator st/details-separator st/details-separator-wrapper]
(when confirmed? [password-form/view 1]) [details transaction]]
(let [confirm-text (if confirmed? (when (and confirmed? (not offline?))
(i18n/label :t/confirm) [password-form/view 1])
(i18n/label-pluralize 1 :t/confirm-transactions)) (when-not offline?
confirm-fn (if confirmed? (let [confirm-text (if confirmed?
#(do (rf/dispatch [:accept-transaction password id]) (i18n/label :t/confirm)
(rf/dispatch [:set :confirmed-transactions-count 1])) (i18n/label-pluralize 1 :t/confirm-transactions))
#(rf/dispatch [:set-in [:transaction-details-ui-props :confirmed?] true]))] confirm-fn (if confirmed?
[sticky-button/sticky-button confirm-text confirm-fn])]) #(do (rf/dispatch [:accept-transaction password id])
(rf/dispatch [:set :confirmed-transactions-count 1]))
#(rf/dispatch [:set-in [:transaction-details-ui-props :confirmed?] true]))]
[sticky-button/sticky-button confirm-text confirm-fn]))
[offline-view/offline-view {:top (if platform/ios? 21 0)}]]))

View File

@ -5,6 +5,7 @@
[status-im.components.react :as rn] [status-im.components.react :as rn]
[status-im.components.sticky-button :as sticky-button] [status-im.components.sticky-button :as sticky-button]
[status-im.components.status-bar :as status-bar] [status-im.components.status-bar :as status-bar]
[status-im.components.sync-state.offline :as offline-view]
[status-im.components.toolbar-new.actions :as act] [status-im.components.toolbar-new.actions :as act]
[status-im.components.toolbar-new.view :as toolbar] [status-im.components.toolbar-new.view :as toolbar]
[status-im.transactions.views.list-item :as transactions-list-item] [status-im.transactions.views.list-item :as transactions-list-item]
@ -41,26 +42,31 @@
[transactions-list-item/view row]]])) [transactions-list-item/view row]]]))
(defview unsigned-transactions [] (defview unsigned-transactions []
[transactions [:transactions] [transactions [:transactions]
{:keys [password]} [:get :confirm-transactions] {:keys [password]} [:get :confirm-transactions]
confirmed? [:get-in [:transactions-list-ui-props :confirmed?]]] confirmed? [:get-in [:transactions-list-ui-props :confirmed?]]
{:component-did-update #(when-not (seq transactions) (rf/dispatch [:navigate-back])) sync-state [:get :sync-state]
network-status [:get :network-status]]
{:component-did-update #(when-not (seq transactions) (rf/dispatch [:navigate-back]))
:component-will-unmount #(rf/dispatch [:set-in [:transactions-list-ui-props :confirmed?] false])} :component-will-unmount #(rf/dispatch [:set-in [:transactions-list-ui-props :confirmed?] false])}
[(if platform/ios? rn/keyboard-avoiding-view rn/view) (merge {:behavior :padding} st/transactions-screen) (let [offline? (or (= network-status :offline) (= sync-state :offline))]
[status-bar/status-bar {:type :transaction}] [(if platform/ios? rn/keyboard-avoiding-view rn/view) (merge {:behavior :padding} st/transactions-screen)
[toolbar-view transactions] [status-bar/status-bar {:type :transaction}]
[rn/view {:style st/transactions-screen-content-container} [toolbar-view transactions]
[rn/list-view {:style st/transactions-list [rn/view {:style st/transactions-screen-content-container}
:dataSource (lw/to-datasource transactions) [rn/list-view {:style st/transactions-list
:renderSeparator (render-separator-fn (count transactions)) :dataSource (lw/to-datasource transactions)
:renderRow render-row-fn}] :renderSeparator (render-separator-fn (count transactions))
(when confirmed? :renderRow render-row-fn}]
[password-form/view (count transactions)])] (when (and confirmed? (not offline?))
(let [confirm-text (if confirmed? [password-form/view (count transactions)])]
(i18n/label :t/confirm) (when-not offline?
(i18n/label-pluralize (count transactions) :t/confirm-transactions)) (let [confirm-text (if confirmed?
confirm-fn (if confirmed? (i18n/label :t/confirm)
#(do (rf/dispatch [:accept-transactions password]) (i18n/label-pluralize (count transactions) :t/confirm-transactions))
(rf/dispatch [:set :confirmed-transactions-count (count transactions)])) confirm-fn (if confirmed?
#(rf/dispatch [:set-in [:transactions-list-ui-props :confirmed?] true]))] #(do (rf/dispatch [:accept-transactions password])
[sticky-button/sticky-button confirm-text confirm-fn])]) (rf/dispatch [:set :confirmed-transactions-count (count transactions)]))
#(rf/dispatch [:set-in [:transactions-list-ui-props :confirmed?] true]))]
[sticky-button/sticky-button confirm-text confirm-fn]))
[offline-view/offline-view {:top (if platform/ios? 21 0)}]]))