From d022c286bb4f1cc3d33c56b9ade4365f44cc6e9a Mon Sep 17 00:00:00 2001 From: Eric Dvorsak Date: Thu, 5 Oct 2017 19:16:41 +0200 Subject: [PATCH] [Wallet] remove syncing animation (#2011) * [design] remove syncing animation outside of chat views replace no-sync-bar? parameter by show-sync-bar? parameter as not showing the sync bar is the norm and showing it the exception (only appears in chats) * add suscription and spec for sync-state --- src/status_im/chat/screen.cljs | 2 +- src/status_im/chat/views/toolbar_content.cljs | 2 +- src/status_im/components/sync_state/gradient.cljs | 4 ++-- src/status_im/components/sync_state/offline.cljs | 2 +- src/status_im/components/toolbar_new/view.cljs | 4 ++-- src/status_im/transactions/screens/transaction_details.cljs | 2 +- src/status_im/transactions/screens/unsigned_transactions.cljs | 2 +- src/status_im/ui/screens/chats_list/views.cljs | 4 ++-- src/status_im/ui/screens/db.cljs | 2 +- src/status_im/ui/screens/subs.cljs | 4 ++++ src/status_im/ui/screens/wallet/choose_recipient/views.cljs | 3 +-- 11 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/status_im/chat/screen.cljs b/src/status_im/chat/screen.cljs index 554aa3f998..b3535cb899 100644 --- a/src/status_im/chat/screen.cljs +++ b/src/status_im/chat/screen.cljs @@ -114,7 +114,7 @@ [view [status-bar] (let [hide-nav? (or (empty? accounts) show-actions? creating?)] - [toolbar/toolbar2 {} + [toolbar/toolbar2 {:show-sync-bar? true} (when-not hide-nav? toolbar/default-nav-back) [toolbar-content-view] [toolbar-action]]) diff --git a/src/status_im/chat/views/toolbar_content.cljs b/src/status_im/chat/views/toolbar_content.cljs index 527b9001cc..8674be53d7 100644 --- a/src/status_im/chat/views/toolbar_content.cljs +++ b/src/status_im/chat/views/toolbar_content.cljs @@ -71,7 +71,7 @@ show-actions? [:chat-ui-props :show-actions?] accounts [:get-accounts] contact [:get-in [:contacts/contacts @chat-id]] - sync-state [:get :sync-state] + sync-state [:sync-state] creating? [:get :accounts/creating-account?]] [view (st/chat-name-view (or (empty? accounts) show-actions? diff --git a/src/status_im/components/sync_state/gradient.cljs b/src/status_im/components/sync_state/gradient.cljs index b8a84753af..a87fc3f01c 100644 --- a/src/status_im/components/sync_state/gradient.cljs +++ b/src/status_im/components/sync_state/gradient.cljs @@ -74,7 +74,7 @@ (defn sync-state-gradient-view [] - (let [sync-state (subscribe [:get :sync-state]) + (let [sync-state (subscribe [:sync-state]) gradient-position (anim/create-value 0) sync-state-opacity (anim/create-value 0.0) in-progress-opacity (anim/create-value 0.0) @@ -117,4 +117,4 @@ :locations [0 0.3 0.7 1] :style (st/gradient gradient-width)}]] (when (not= @sync-state :in-progress) - [animated-view {:style (st/synced-wrapper synced-opacity window-width)}])]])}))) \ No newline at end of file + [animated-view {:style (st/synced-wrapper synced-opacity window-width)}])]])}))) diff --git a/src/status_im/components/sync_state/offline.cljs b/src/status_im/components/sync_state/offline.cljs index b6e156f5b6..3ef986002f 100644 --- a/src/status_im/components/sync_state/offline.cljs +++ b/src/status_im/components/sync_state/offline.cljs @@ -17,7 +17,7 @@ :duration 250}))) (defn offline-view [_] - (let [sync-state (subscribe [:get :sync-state]) + (let [sync-state (subscribe [:sync-state]) network-status (subscribe [:get :network-status]) offline-opacity (anim/create-value 0.0) on-update (fn [_ _] diff --git a/src/status_im/components/toolbar_new/view.cljs b/src/status_im/components/toolbar_new/view.cljs index d7a31ab6ab..d7fc42a724 100644 --- a/src/status_im/components/toolbar_new/view.cljs +++ b/src/status_im/components/toolbar_new/view.cljs @@ -98,7 +98,7 @@ ([title] (toolbar2 nil title)) ([props title] (toolbar2 props default-nav-back [content-title title])) ([props nav-item content-item] (toolbar2 props nav-item content-item [actions [{:image :blank}]])) - ([{:keys [background-color style flat? no-sync-bar?]} + ([{:keys [background-color style flat? show-sync-bar?]} nav-item content-item action-items] @@ -114,7 +114,7 @@ [rn/view st/flex] content-item) action-items] - (when-not no-sync-bar? [sync-state-gradient-view/sync-state-gradient-view])])) + (when show-sync-bar? [sync-state-gradient-view/sync-state-gradient-view])])) (defn toolbar "DEPRECATED diff --git a/src/status_im/transactions/screens/transaction_details.cljs b/src/status_im/transactions/screens/transaction_details.cljs index 1475a76a84..844d73047a 100644 --- a/src/status_im/transactions/screens/transaction_details.cljs +++ b/src/status_im/transactions/screens/transaction_details.cljs @@ -54,7 +54,7 @@ [{:keys [id] :as transaction} [:get :selected-transaction] {:keys [password]} [:get :confirm-transactions] confirmed? [:get-in [:transaction-details-ui-props :confirmed?]] - sync-state [:get :sync-state] + sync-state [: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])} diff --git a/src/status_im/transactions/screens/unsigned_transactions.cljs b/src/status_im/transactions/screens/unsigned_transactions.cljs index 25d702e80d..adc4a449ac 100644 --- a/src/status_im/transactions/screens/unsigned_transactions.cljs +++ b/src/status_im/transactions/screens/unsigned_transactions.cljs @@ -45,7 +45,7 @@ [transactions [:transactions] {:keys [password]} [:get :confirm-transactions] confirmed? [:get-in [:transactions-list-ui-props :confirmed?]] - sync-state [:get :sync-state] + sync-state [: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])} diff --git a/src/status_im/ui/screens/chats_list/views.cljs b/src/status_im/ui/screens/chats_list/views.cljs index b734cec252..7f04b9b03d 100644 --- a/src/status_im/ui/screens/chats_list/views.cljs +++ b/src/status_im/ui/screens/chats_list/views.cljs @@ -38,7 +38,7 @@ (act/add #(re-frame/dispatch [:navigate-to :new-chat]))]) (defn toolbar-view [] - [toolbar/toolbar2 {} + [toolbar/toolbar2 {:show-sync-bar? true} [toolbar/nav-button (act/hamburger drawer/open-drawer!)] [toolbar/content-title (i18n/label :t/chats)] [toolbar/actions @@ -47,7 +47,7 @@ (android-toolbar-actions))]]) (defn toolbar-edit [] - [toolbar/toolbar2 {} + [toolbar/toolbar2 {:show-sync-bar? true} [toolbar/nav-button (act/back #(re-frame/dispatch [:set-in [:chat-list-ui-props :edit?] false]))] [toolbar/content-title (i18n/label :t/edit-chats)]]) diff --git a/src/status_im/ui/screens/db.cljs b/src/status_im/ui/screens/db.cljs index 677398e307..e949e2d1f3 100644 --- a/src/status_im/ui/screens/db.cljs +++ b/src/status_im/ui/screens/db.cljs @@ -63,7 +63,7 @@ ;;;;NODE (spec/def ::sync-listening-started (spec/nilable boolean?)) -(spec/def ::sync-state (spec/nilable keyword?)) +(spec/def ::sync-state (spec/nilable #{:pending :in-progress :synced :done :offline})) (spec/def ::sync-data (spec/nilable map?)) ;;;;NAVIGATION diff --git a/src/status_im/ui/screens/subs.cljs b/src/status_im/ui/screens/subs.cljs index 055794bd1c..b00caef87f 100644 --- a/src/status_im/ui/screens/subs.cljs +++ b/src/status_im/ui/screens/subs.cljs @@ -49,3 +49,7 @@ (reg-sub :network (fn [db] (:network db))) + +(reg-sub :sync-state + (fn [db] + (:sync-state db))) diff --git a/src/status_im/ui/screens/wallet/choose_recipient/views.cljs b/src/status_im/ui/screens/wallet/choose_recipient/views.cljs index 272267ed66..6c58e3e0e7 100644 --- a/src/status_im/ui/screens/wallet/choose_recipient/views.cljs +++ b/src/status_im/ui/screens/wallet/choose_recipient/views.cljs @@ -24,8 +24,7 @@ :params {:hide-actions? true}}])) (defn toolbar-view [camera-flashlight] - [toolbar/toolbar2 {:style wallet.styles/toolbar - :no-sync-bar? true} + [toolbar/toolbar2 {:style wallet.styles/toolbar} [toolbar/nav-button (act/back-white act/default-handler)] [toolbar/content-title {:color :white} (i18n/label :t/wallet-choose-recipient)] [toolbar/actions [{:icon (if (= :on camera-flashlight) :icons/flash-active