From 52e51c5de13cbc998df2b82b2ae5428dd8793d79 Mon Sep 17 00:00:00 2001 From: Gheorghe Pinzaru Date: Fri, 28 Feb 2020 18:11:00 +0300 Subject: [PATCH] fixup --- .../src/status_im/ui/components/react.cljs | 2 -- src/status_im/contact/core.cljs | 2 +- src/status_im/hardwallet/core.cljs | 4 +--- src/status_im/init/core.cljs | 8 +++++-- src/status_im/multiaccounts/logout/core.cljs | 10 ++++---- .../ui/components/status_bar/view.cljs | 11 +++++---- .../ui/screens/add_new/new_chat/events.cljs | 5 ++++ .../screens/add_new/new_chat/navigation.cljs | 6 ----- src/status_im/ui/screens/events.cljs | 2 -- src/status_im/ui/screens/group/events.cljs | 8 +++++-- .../ui/screens/group/navigation.cljs | 6 ----- src/status_im/ui/screens/navigation.cljs | 8 +------ .../ui/screens/routing/chat_stack.cljs | 6 ++--- src/status_im/ui/screens/routing/core.cljs | 5 ---- .../ui/screens/routing/intro_login_stack.cljs | 2 ++ src/status_im/ui/screens/routing/main.cljs | 10 +++++--- .../ui/screens/routing/wallet_stack.cljs | 8 +++---- src/status_im/ui/screens/views.cljs | 4 ++-- src/status_im/ui/screens/wallet/events.cljs | 24 +++++++++++++++++++ .../ui/screens/wallet/navigation.cljs | 23 ------------------ 20 files changed, 72 insertions(+), 82 deletions(-) delete mode 100644 src/status_im/ui/screens/add_new/new_chat/navigation.cljs delete mode 100644 src/status_im/ui/screens/group/navigation.cljs create mode 100644 src/status_im/ui/screens/wallet/events.cljs delete mode 100644 src/status_im/ui/screens/wallet/navigation.cljs diff --git a/components/src/status_im/ui/components/react.cljs b/components/src/status_im/ui/components/react.cljs index 1227e74cd5f..5af59c0a9c7 100644 --- a/components/src/status_im/ui/components/react.cljs +++ b/components/src/status_im/ui/components/react.cljs @@ -273,6 +273,4 @@ (def safe-area-provider (adapt-class (object/get js-dependencies/safe-area-context "SafeAreaProvider"))) (def safe-area-consumer (adapt-class (object/get js-dependencies/safe-area-context "SafeAreaConsumer"))) -(def safe-area-consumer (adapt-class (object/get js-dependencies/safe-area-context "SafeAreaConsumer"))) - (def safe-area-view (adapt-class (object/get js-dependencies/safe-area-context "SafeAreaView"))) diff --git a/src/status_im/contact/core.cljs b/src/status_im/contact/core.cljs index 8e6a4b84dcb..d2b5df273f0 100644 --- a/src/status_im/contact/core.cljs +++ b/src/status_im/contact/core.cljs @@ -160,7 +160,7 @@ (contacts-store/fetch-contacts-rpc cofx #(re-frame/dispatch [::contacts-loaded %]))) (fx/defn open-contact-toggle-list - [{:keys [db :as cofx]}] + [{:keys [db] :as cofx}] (fx/merge cofx {:db (assoc db :group/selected-contacts #{} diff --git a/src/status_im/hardwallet/core.cljs b/src/status_im/hardwallet/core.cljs index 547c9929f3d..e84d93b5012 100644 --- a/src/status_im/hardwallet/core.cljs +++ b/src/status_im/hardwallet/core.cljs @@ -122,9 +122,7 @@ (defn multiaccounts-screen-did-load [{:keys [db]}] - {:db (-> db - (assoc-in [:hardwallet :setup-step] nil) - (dissoc :multiaccounts/login))}) + {:db (assoc-in db [:hardwallet :setup-step] nil)}) (defn authentication-method-screen-did-load [{:keys [db]}] diff --git a/src/status_im/init/core.cljs b/src/status_im/init/core.cljs index 78d4836797f..3e195668607 100644 --- a/src/status_im/init/core.cljs +++ b/src/status_im/init/core.cljs @@ -36,10 +36,14 @@ (let [{{:multiaccounts/keys [multiaccounts] :as db} :db} cofx] (cond (empty? multiaccounts) - (navigation/navigate-to-cofx cofx :intro-stack {:screen :intro}) + (navigation/navigate-reset cofx {:index 1 + :routes [{:name :intro-stack} + {:name :intro}]}) logout? - (navigation/navigate-to-cofx cofx :intro-stack {:screen :multiaccounts}) + (navigation/navigate-reset cofx {:index 1 + :routes [{:name :intro-stack} + {:name :multiaccounts}]}) :else (let [{:keys [key-uid public-key photo-path name]} (first (#(sort-by :last-sign-in > %) (vals multiaccounts)))] diff --git a/src/status_im/multiaccounts/logout/core.cljs b/src/status_im/multiaccounts/logout/core.cljs index af994018fd3..03f51eb8e06 100644 --- a/src/status_im/multiaccounts/logout/core.cljs +++ b/src/status_im/multiaccounts/logout/core.cljs @@ -9,12 +9,12 @@ [status-im.ui.screens.navigation :as navigation] [status-im.utils.keychain.core :as keychain])) -(fx/defn logout-method [{:keys [db] :as cofx} auth-method] +(fx/defn logout-method [{:keys [db] :as cofx} {:keys [auth-method logout?]}] (let [key-uid (get-in db [:multiaccount :key-uid])] (fx/merge cofx {::logout nil :keychain/clear-user-password key-uid - ::init/open-multiaccounts #(re-frame/dispatch [::init/initialize-multiaccounts % {:logout? true}])} + ::init/open-multiaccounts #(re-frame/dispatch [::init/initialize-multiaccounts % {:logout? logout?}])} (keychain/save-auth-method key-uid auth-method) (transport/stop-whisper) (chaos-mode/stop-checking) @@ -23,7 +23,8 @@ (fx/defn logout {:events [:logout]} [cofx] - (logout-method cofx keychain/auth-method-none)) + (logout-method cofx {:auth-method keychain/auth-method-none + :logout? true})) (fx/defn show-logout-confirmation [_] {:ui/show-confirmation @@ -37,7 +38,8 @@ {:events [:biometric-logout]} [cofx] (fx/merge cofx - (logout-method keychain/auth-method-biometric-prepare) + (logout-method {:auth-method keychain/auth-method-biometric-prepare + :logout? false}) (fn [{:keys [db]}] {:db (assoc-in db [:multiaccounts/login :save-password?] true)}))) diff --git a/src/status_im/ui/components/status_bar/view.cljs b/src/status_im/ui/components/status_bar/view.cljs index 2309ee90206..910a00032e9 100644 --- a/src/status_im/ui/components/status_bar/view.cljs +++ b/src/status_im/ui/components/status_bar/view.cljs @@ -3,13 +3,14 @@ [status-im.ui.components.status-bar.styles :as styles] [status-im.utils.platform :as platform])) +(def route->bar-type (merge {:qr-scanner {:type :black}} + (when platform/ios? + {:new-chat {:type :black} + :new-public-chat {:type :black}}))) + ;; TODO: Integrate into navigation (defn get-config [view-id] - (or (get {:qr-scanner {:type :black} - :new-chat {:type :black} - :new-public-chat {:type :black}} - view-id) - {:type :main})) + (get route->bar-type view-id {:type :main})) (defn set-status-bar "If more than one `StatusBar` is rendered, the one which was mounted last will diff --git a/src/status_im/ui/screens/add_new/new_chat/events.cljs b/src/status_im/ui/screens/add_new/new_chat/events.cljs index 34ad94de927..908507bc4cb 100644 --- a/src/status_im/ui/screens/add_new/new_chat/events.cljs +++ b/src/status_im/ui/screens/add_new/new_chat/events.cljs @@ -37,3 +37,8 @@ {:resolve-public-key {:chain chain :contact-identity new-identity :cb #(re-frame/dispatch [:new-chat/set-new-identity % new-identity])}})))))) + +(handlers/register-handler-fx + ::new-chat-focus + (fn [{:keys [db]}] + {:db (dissoc db :contacts/new-identity :contacts/new-identity-error)})) diff --git a/src/status_im/ui/screens/add_new/new_chat/navigation.cljs b/src/status_im/ui/screens/add_new/new_chat/navigation.cljs deleted file mode 100644 index 309254f709f..00000000000 --- a/src/status_im/ui/screens/add_new/new_chat/navigation.cljs +++ /dev/null @@ -1,6 +0,0 @@ -(ns status-im.ui.screens.add-new.new-chat.navigation - (:require [status-im.ui.screens.navigation :as navigation])) - -(defmethod navigation/preload-data! :new-chat - [db _] - (dissoc db :contacts/new-identity :contacts/new-identity-error)) diff --git a/src/status_im/ui/screens/events.cljs b/src/status_im/ui/screens/events.cljs index 8d5b59e40cb..e29c0503034 100644 --- a/src/status_im/ui/screens/events.cljs +++ b/src/status_im/ui/screens/events.cljs @@ -4,9 +4,7 @@ status-im.ui.screens.group.chat-settings.events status-im.ui.screens.group.events status-im.utils.universal-links.events - status-im.ui.screens.add-new.new-chat.navigation status-im.ui.screens.profile.events - status-im.ui.screens.wallet.navigation [re-frame.core :as re-frame] [status-im.chat.models :as chat] [status-im.hardwallet.core :as hardwallet] diff --git a/src/status_im/ui/screens/group/events.cljs b/src/status_im/ui/screens/group/events.cljs index 5a0b0acefe4..7f5c974453f 100644 --- a/src/status_im/ui/screens/group/events.cljs +++ b/src/status_im/ui/screens/group/events.cljs @@ -1,6 +1,5 @@ (ns status-im.ui.screens.group.events - (:require [status-im.utils.handlers :as handlers] - [status-im.ui.screens.group.navigation])) + (:require [status-im.utils.handlers :as handlers])) (handlers/register-handler-fx :deselect-contact @@ -21,3 +20,8 @@ :select-participant (fn [{:keys [db]} [_ id]] {:db (update db :selected-participants conj id)})) + +(handlers/register-handler-fx + ::add-participants-toggle-list + (fn [{db :db}] + {:db (assoc db :selected-participants #{})})) diff --git a/src/status_im/ui/screens/group/navigation.cljs b/src/status_im/ui/screens/group/navigation.cljs deleted file mode 100644 index 29c641b01cd..00000000000 --- a/src/status_im/ui/screens/group/navigation.cljs +++ /dev/null @@ -1,6 +0,0 @@ -(ns status-im.ui.screens.group.navigation - (:require [status-im.ui.screens.navigation :as nav])) - -(defmethod nav/preload-data! :add-participants-toggle-list - [db _] - (assoc db :selected-participants #{})) diff --git a/src/status_im/ui/screens/navigation.cljs b/src/status_im/ui/screens/navigation.cljs index f093d97f565..f2c824788d9 100644 --- a/src/status_im/ui/screens/navigation.cljs +++ b/src/status_im/ui/screens/navigation.cljs @@ -10,11 +10,6 @@ (defmethod unload-data! :default [db] db) -(defmulti preload-data! - (fn [db [_ view-id]] (or view-id (:view-id db)))) - -(defmethod preload-data! :default [db _] db) - (fx/defn navigate-to-cofx [{:keys [db]} go-to-view-id screen-params] (let [db (cond-> (assoc db :view-id go-to-view-id) @@ -48,7 +43,7 @@ (re-frame/assoc-coeffect context :db (unload-data! db)))))) (def navigation-interceptors - [unload-data-interceptor (re-frame/enrich preload-data!)]) + [unload-data-interceptor]) (re-frame/reg-fx ::navigate-to @@ -86,7 +81,6 @@ (handlers/register-handler-fx :navigate-back - (re-frame/enrich preload-data!) (fn [cofx _] (navigate-back cofx))) diff --git a/src/status_im/ui/screens/routing/chat_stack.cljs b/src/status_im/ui/screens/routing/chat_stack.cljs index 7f8c0b17ac8..d79e6cc410d 100644 --- a/src/status_im/ui/screens/routing/chat_stack.cljs +++ b/src/status_im/ui/screens/routing/chat_stack.cljs @@ -6,6 +6,7 @@ [status-im.ui.screens.group.views :as group] [status-im.ui.screens.profile.group-chat.views :as profile.group-chat] [status-im.chat.models.loading :as chat.loading] + [status-im.ui.screens.group.events :as group.events] [status-im.ui.screens.stickers.views :as stickers])) (defonce stack (navigation/create-stack)) @@ -23,13 +24,10 @@ :component chat/select-chat} {:name :profile :component profile.contact/profile} - - ;; {:name :take-picture - ;; :component }] - {:name :new-group :component group/new-group} {:name :add-participants-toggle-list + :on-focus [::group.events/add-participants-toggle-list] :component group/add-participants-toggle-list} {:name :contact-toggle-list :component group/contact-toggle-list} diff --git a/src/status_im/ui/screens/routing/core.cljs b/src/status_im/ui/screens/routing/core.cljs index fd6e0c8a79f..8a604327915 100644 --- a/src/status_im/ui/screens/routing/core.cljs +++ b/src/status_im/ui/screens/routing/core.cljs @@ -48,11 +48,6 @@ (defn wrapped-screen-style [{:keys [insets]} insets-obj] (merge {:background-color :white - :position :absolute - :left 0 - :right 0 - :top 0 - :bottom 0 :flex 1} (when (get insets :bottom) {:padding-bottom (oget insets-obj "bottom")}) diff --git a/src/status_im/ui/screens/routing/intro_login_stack.cljs b/src/status_im/ui/screens/routing/intro_login_stack.cljs index c0f598d67f6..262554ef6c7 100644 --- a/src/status_im/ui/screens/routing/intro_login_stack.cljs +++ b/src/status_im/ui/screens/routing/intro_login_stack.cljs @@ -23,6 +23,8 @@ :component intro/intro} {:name :multiaccounts :component multiaccounts/multiaccounts}) + {:name :progress + :component progress/progress} {:name :login :component login/login} ;; {:name :intro-wizard diff --git a/src/status_im/ui/screens/routing/main.cljs b/src/status_im/ui/screens/routing/main.cljs index 3dc6d97d1b0..3ef7d86da58 100644 --- a/src/status_im/ui/screens/routing/main.cljs +++ b/src/status_im/ui/screens/routing/main.cljs @@ -9,12 +9,14 @@ [status-im.ui.screens.stickers.views :as stickers] [status-im.ui.screens.home.views :as home] [status-im.ui.screens.add-new.new-chat.views :as new-chat] + [status-im.ui.screens.add-new.new-chat.events :as new-chat.events] [status-im.ui.screens.chat.views :as chat] [status-im.ui.screens.keycard.views :as keycard] [status-im.ui.screens.wallet.transactions.views :as wallet-transactions] [status-im.ui.screens.routing.intro-login-stack :as intro-login-stack] [status-im.ui.screens.routing.chat-stack :as chat-stack] [status-im.ui.screens.routing.wallet-stack :as wallet-stack] + [status-im.ui.screens.wallet.events :as wallet.events] [status-im.ui.screens.routing.profile-stack :as profile-stack] [status-im.ui.screens.routing.browser-stack :as browser-stack] [status-im.chat.models.loading :as chat.loading] @@ -25,7 +27,7 @@ (defonce modals-stack (navigation/create-stack)) (defonce bottom-tabs (navigation/create-bottom-tabs)) -;; TODO: Add two-pane navigator on chat-stack +;; TODO(Ferossgp): Add two-pane navigator on chat-stack (defn tabs [] [bottom-tabs {:initial-route-name :chat-stack :lazy false @@ -38,6 +40,7 @@ :insets {:top false} :component browser-stack/browser-stack} {:name :wallet-stack + :on-focus [::wallet.events/wallet-stack] :insets {:top false} :component wallet-stack/wallet-stack} {:name :profile-stack @@ -46,8 +49,8 @@ (views/defview get-main-component [_] (views/letsubs [logged-in? [:multiaccount/logged-in?]] - [main-stack (merge {:header-mode :none - :mode :modal}) + [main-stack {:header-mode :none + :mode :modal} [(if logged-in? {:name :tabs :insets {:top false} @@ -69,6 +72,7 @@ {:name :keycard-welcome :component keycard/welcome} {:name :new-chat + :on-focus [::new-chat.events/new-chat-focus] :transition :presentation-ios :component new-chat/new-chat} {:name :new-public-chat diff --git a/src/status_im/ui/screens/routing/wallet_stack.cljs b/src/status_im/ui/screens/routing/wallet_stack.cljs index aebf0465acf..db3d76b4c54 100644 --- a/src/status_im/ui/screens/routing/wallet_stack.cljs +++ b/src/status_im/ui/screens/routing/wallet_stack.cljs @@ -9,6 +9,7 @@ [status-im.ui.screens.wallet.account.views :as wallet.account] [status-im.ui.screens.wallet.add-new.views :as add-account] [status-im.ui.screens.wallet.account-settings.views :as account-settings] + [status-im.ui.screens.wallet.events :as wallet.events] [status-im.ui.screens.routing.core :as navigation])) (defonce stack (navigation/create-stack)) @@ -21,6 +22,7 @@ {:name :wallet-account :component wallet.account/account} {:name :add-new-account + :on-focus [::wallet.events/add-new-account] :component add-account/add-account} {:name :add-watch-account :component add-account/add-watch-account} @@ -34,18 +36,14 @@ :component account-settings/account-settings} {:name :collectibles-list :component collectibles/collectibles-list} - ;; {:name :wallet-onboarding-setup - ;; :component } {:name :wallet-transaction-details :component wallet-transactions/transaction-details} - ;; {:name :wallet-settings-hook - ;; :component } {:name :wallet-settings-assets :component wallet-settings/manage-assets} {:name :wallet-add-custom-token + :on-focus [::wallet.events/wallet-add-custom-token] :component custom-tokens/add-custom-token} {:name :wallet-custom-token-details :component custom-tokens/custom-token-details} - {:name :currency-settings :component currency-settings/currency-settings}]]) diff --git a/src/status_im/ui/screens/views.cljs b/src/status_im/ui/screens/views.cljs index eb341bef3e7..cc61adc2bfe 100644 --- a/src/status_im/ui/screens/views.cljs +++ b/src/status_im/ui/screens/views.cljs @@ -83,8 +83,8 @@ (when debug? (persist-state! state))) -(defonce main-app-navigator (routing/get-main-component false)) -(defonce twopane-app-navigator (routing/get-main-component true)) +(defonce main-app-navigator (partial routing/get-main-component false)) +(defonce twopane-app-navigator (partial routing/get-main-component true)) (defn main [] (let [two-pane? (reagent/atom (dimensions/fit-two-pane?))] diff --git a/src/status_im/ui/screens/wallet/events.cljs b/src/status_im/ui/screens/wallet/events.cljs new file mode 100644 index 00000000000..62388aa5bf1 --- /dev/null +++ b/src/status_im/ui/screens/wallet/events.cljs @@ -0,0 +1,24 @@ +(ns status-im.ui.screens.wallet.events + (:require [status-im.ui.screens.wallet.signing-phrase.views :as signing-phrase] + [status-im.utils.handlers :as handlers])) + +(handlers/register-handler-fx + ::wallet-stack + (fn [{:keys [db]}] + (let [wallet-set-up-passed? (get-in db [:multiaccount :wallet-set-up-passed?]) + sign-phrase-showed? (get db :wallet/sign-phrase-showed?)] + {:dispatch [:wallet.ui/pull-to-refresh] ;TODO temporary simple fix for v1 + :db (if (or wallet-set-up-passed? sign-phrase-showed?) + db + (assoc db :popover/popover {:view [signing-phrase/signing-phrase]} + :wallet/sign-phrase-showed? true))}))) + +(handlers/register-handler-fx + ::wallet-add-custom-token + (fn [{:keys [db]}] + {:db (dissoc db :wallet/custom-token-screen)})) + +(handlers/register-handler-fx + ::add-new-account + (fn [{:keys [db]}] + {:db (dissoc db :add-account)})) diff --git a/src/status_im/ui/screens/wallet/navigation.cljs b/src/status_im/ui/screens/wallet/navigation.cljs deleted file mode 100644 index 00bc6026133..00000000000 --- a/src/status_im/ui/screens/wallet/navigation.cljs +++ /dev/null @@ -1,23 +0,0 @@ -(ns status-im.ui.screens.wallet.navigation - (:require [status-im.ui.screens.navigation :as navigation] - [status-im.ui.screens.wallet.signing-phrase.views :as signing-phrase] - [re-frame.core :as re-frame])) - -(defmethod navigation/preload-data! :wallet-stack - [db [event]] - (let [wallet-set-up-passed? (get-in db [:multiaccount :wallet-set-up-passed?]) - sign-phrase-showed? (get db :wallet/sign-phrase-showed?)] - ;;TODO temporary simple fix for v1 - (re-frame/dispatch [:wallet.ui/pull-to-refresh]) - (if (or (= event :navigate-back) wallet-set-up-passed? sign-phrase-showed?) - db - (assoc db :popover/popover {:view [signing-phrase/signing-phrase]} - :wallet/sign-phrase-showed? true)))) - -(defmethod navigation/preload-data! :wallet-add-custom-token - [db [event]] - (dissoc db :wallet/custom-token-screen)) - -(defmethod navigation/preload-data! :add-new-account - [db [event]] - (dissoc db :add-account))