show warning when app is syncing

This commit is contained in:
Eric Dvorsak 2017-10-13 18:07:04 +02:00 committed by Roman Volosovskyi
parent dea6bdb2ca
commit 22f39e88c0
4 changed files with 37 additions and 17 deletions

View File

@ -53,3 +53,8 @@
(reg-sub :sync-state (reg-sub :sync-state
(fn [db] (fn [db]
(:sync-state db))) (:sync-state db)))
(reg-sub :syncing?
:<- [:sync-state]
(fn [sync-state]
(= sync-state :syncing)))

View File

@ -62,10 +62,12 @@
(str (when pos-change? "+") change "%") (str (when pos-change? "+") change "%")
"-%")]])) "-%")]]))
(defn main-section [usd-value change error-message] (defn main-section [usd-value change syncing? error-message]
[react/view {:style styles/main-section} [react/view {:style styles/main-section}
(if syncing?
[wallet.views/wallet-syncing styles/error-container styles/error-message]
(when error-message (when error-message
[wallet.views/error-message-view styles/error-container styles/error-message]) [wallet.views/error-message-view styles/error-container styles/error-message]))
[react/view {:style styles/total-balance-container} [react/view {:style styles/total-balance-container}
[react/view {:style styles/total-balance} [react/view {:style styles/total-balance}
[react/text {:style styles/total-balance-value} usd-value] [react/text {:style styles/total-balance-value} usd-value]
@ -75,10 +77,12 @@
(i18n/label :t/wallet-total-value)] (i18n/label :t/wallet-total-value)]
[change-display change]] [change-display change]]
[react/view {:style (merge button.styles/buttons-container styles/buttons)} [react/view {:style (merge button.styles/buttons-container styles/buttons)}
[btn/button {:on-press #(rf/dispatch [:navigate-to :wallet-send-transaction]) [btn/button {:disabled? syncing?
:on-press #(rf/dispatch [:navigate-to :wallet-send-transaction])
:style (button.styles/button-bar :first) :text-style styles/main-button-text} :style (button.styles/button-bar :first) :text-style styles/main-button-text}
(i18n/label :t/wallet-send)] (i18n/label :t/wallet-send)]
[btn/button {:on-press #(rf/dispatch [:navigate-to :wallet-request-transaction]) [btn/button {:disabled? syncing?
:on-press #(rf/dispatch [:navigate-to :wallet-request-transaction])
:style (button.styles/button-bar :other) :text-style styles/main-button-text} :style (button.styles/button-bar :other) :text-style styles/main-button-text}
(i18n/label :t/wallet-request)] (i18n/label :t/wallet-request)]
[btn/button {:disabled? true :style (button.styles/button-bar :last) :text-style styles/main-button-text} [btn/button {:disabled? true :style (button.styles/button-bar :last) :text-style styles/main-button-text}
@ -141,10 +145,11 @@
portfolio-value [:portfolio-value] portfolio-value [:portfolio-value]
portfolio-change [:portfolio-change] portfolio-change [:portfolio-change]
prices-loading? [:prices-loading?] prices-loading? [:prices-loading?]
syncing? [:syncing?]
balance-loading? [:wallet/balance-loading?] balance-loading? [:wallet/balance-loading?]
error-message [:wallet/error-message?]] error-message [:wallet/error-message?]]
[react/view {:style wallet.styles/wallet-container} [react/view {:style wallet.styles/wallet-container}
[toolbar-view] [toolbar-view]
[react/view components.styles/flex [react/view components.styles/flex
[main-section portfolio-value portfolio-change error-message] [main-section portfolio-value portfolio-change syncing? error-message]
[asset-section balance prices-loading? balance-loading?]]])) [asset-section balance prices-loading? balance-loading?]]]))

View File

@ -1,5 +1,5 @@
(ns status-im.ui.screens.wallet.styles (ns status-im.ui.screens.wallet.styles
(:require-macros [status-im.utils.styles :refer [defstyle]]) (:require-macros [status-im.utils.styles :refer [defstyle defnstyle]])
(:require [status-im.components.styles :as styles])) (:require [status-im.components.styles :as styles]))
;; errors ;; errors
@ -12,8 +12,8 @@
:android {:padding-top 10 :android {:padding-top 10
:padding-bottom 10}}) :padding-bottom 10}})
(def error-exclamation (defnstyle exclamation [color]
{:background-color styles/color-red-2 {:background-color color
:border-radius 100 :border-radius 100
:width 16 :width 16
:height 16 :height 16
@ -21,6 +21,11 @@
:margin-right 6 :margin-right 6
:margin-top 2}) :margin-top 2})
(def error-exclamation
(exclamation styles/color-red-2))
(def warning-exclamation
(exclamation :gold))
;; wallet ;; wallet
@ -44,8 +49,7 @@
{:margin-left 8}) {:margin-left 8})
(defn button-container [enabled?] (defn button-container [enabled?]
(merge (merge {:flex-direction :row
{:flex-direction :row
:align-items :center} :align-items :center}
(when-not enabled? (when-not enabled?
{:opacity 0.4}))) {:opacity 0.4})))

View File

@ -4,9 +4,15 @@
[status-im.components.icons.vector-icons :as vector-icons] [status-im.components.icons.vector-icons :as vector-icons]
[status-im.i18n :as i18n])) [status-im.i18n :as i18n]))
(defn error-message-view [error-container-style error-message-style] (defn message-view [error-container-style error-message-style icon-container-style label]
[react/view {:style error-container-style} [react/view {:style error-container-style}
[react/view {:style styles/error-container} [react/view {:style styles/error-container}
[vector-icons/icon :icons/exclamation_mark {:color :white [vector-icons/icon :icons/exclamation_mark {:color :white
:container-style styles/error-exclamation}] :container-style icon-container-style}]
[react/text {:style error-message-style} (i18n/label :t/wallet-error)]]]) [react/text {:style error-message-style} label]]])
(defn error-message-view [error-container-style error-message-style]
[message-view error-container-style error-message-style styles/error-exclamation (i18n/label :t/wallet-error)])
(defn wallet-syncing [error-container-style error-message-style]
[message-view error-container-style error-message-style styles/warning-exclamation (i18n/label :t/sync-in-progress)])