Skip to content

Commit

Permalink
Use letsubs for stack subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferossgp committed Feb 29, 2020
1 parent 5d6da22 commit 44a8e2a
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 90 deletions.
2 changes: 0 additions & 2 deletions src/status_im/android/core.cljs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
(ns status-im.android.core
(:require [reagent.core :as reagent]
[re-frame.core :refer [subscribe dispatch dispatch-sync]]
[oops.core :refer [ocall]]
status-im.utils.db
status-im.ui.screens.db
status-im.ui.screens.events
Expand Down Expand Up @@ -42,7 +41,6 @@
(when-not (zero? @keyboard-height)
(dispatch [:set :keyboard-height 0]))))
(.hide react/splash-screen)
;; (ocall rn-dependencies/react-native-screens "enableScreens")
(.addEventListener react/app-state "change" app-state-change-handler)
(.addEventListener rn-dependencies/react-native-languages "change" on-languages-change)
(.addEventListener rn-dependencies/react-native-shake
Expand Down
2 changes: 0 additions & 2 deletions src/status_im/ios/core.cljs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
(ns status-im.ios.core
(:require [reagent.core :as reagent]
[re-frame.core :refer [subscribe dispatch dispatch-sync]]
[oops.core :refer [ocall]]
status-im.utils.db
status-im.ui.screens.db
status-im.ui.screens.events
Expand Down Expand Up @@ -39,7 +38,6 @@
#(when-not (= 0 @keyboard-height)
(dispatch [:set :keyboard-height 0])))
(.hide react/splash-screen)
(ocall rn-dependencies/react-native-screens "enableScreens")
(.addEventListener react/app-state "change" app-state-change-handler)
(.addEventListener rn-dependencies/react-native-languages "change" on-languages-change)
(.addEventListener rn-dependencies/react-native-shake
Expand Down
167 changes: 84 additions & 83 deletions src/status_im/ui/screens/routing/intro_login_stack.cljs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns status-im.ui.screens.routing.intro-login-stack
(:require [status-im.utils.config :as config]
[re-frame.core :as re-frame]
(:require-macros [status-im.utils.views :as views])
(:require [re-frame.core :as re-frame]
[status-im.ui.screens.multiaccounts.login.views :as login]
[status-im.ui.screens.progress.views :as progress]
[status-im.ui.screens.multiaccounts.views :as multiaccounts]
Expand All @@ -15,86 +15,87 @@

(defonce stack (navigation/create-stack))

(defn intro-stack []
[stack {:header-mode :none}
[(if (empty? @(re-frame/subscribe [:multiaccounts/multiaccounts]))
{:name :intro
:component intro/intro}
{:name :multiaccounts
:component multiaccounts/multiaccounts})
{:name :login
:component login/login}
;; {:name :intro-wizard
;; :component }
;; {:name :create-multiaccount
;; :component }
(views/defview intro-stack []
(views/letsubs [multiaccounts [:multiaccounts/multiaccounts]]
[stack {:header-mode :none}
[(if (empty? multiaccounts)
{:name :intro
:component intro/intro}
{:name :multiaccounts
:component multiaccounts/multiaccounts})
{:name :login
:component login/login}
;; {:name :intro-wizard
;; :component }
;; {:name :create-multiaccount
;; :component }

{:name :create-multiaccount-generate-key
:options {:stackPresentation "modal"}
:component intro/wizard-generate-key}
{:name :create-multiaccount-choose-key
:component intro/wizard-choose-key}
{:name :create-multiaccount-select-key-storage
:component intro/wizard-select-key-storage}
{:name :create-multiaccount-create-code
:component intro/wizard-create-code}
{:name :create-multiaccount-confirm-code
:component intro/wizard-confirm-code}
{:name :create-multiaccount-generate-key
:options {:stackPresentation "modal"}
:component intro/wizard-generate-key}
{:name :create-multiaccount-choose-key
:component intro/wizard-choose-key}
{:name :create-multiaccount-select-key-storage
:component intro/wizard-select-key-storage}
{:name :create-multiaccount-create-code
:component intro/wizard-create-code}
{:name :create-multiaccount-confirm-code
:component intro/wizard-confirm-code}

{:name :recover-multiaccount-enter-phrase
:component intro/wizard-enter-phrase}
{:name :recover-multiaccount-select-storage
:component intro/wizard-select-key-storage}
{:name :recover-multiaccount-enter-password
:component intro/wizard-create-code}
{:name :recover-multiaccount-confirm-password
:component intro/wizard-confirm-code}
{:name :recover-multiaccount-success
:component intro/wizard-recovery-success}
{:name :keycard-pairing
:back-handler :noop
:component keycard/pairing}
{:name :keycard-onboarding-intro
:component keycard.onboarding/intro}
{:name :keycard-onboarding-start
:component keycard.onboarding/start}
{:name :keycard-onboarding-puk-code
:component keycard.onboarding/puk-code}
{:name :keycard-onboarding-preparing
:component keycard.onboarding/preparing}
{:name :keycard-onboarding-finishing
:component keycard.onboarding/finishing}
{:name :keycard-onboarding-pin
:component keycard.onboarding/pin}
{:name :keycard-onboarding-recovery-phrase
:component keycard.onboarding/recovery-phrase}
{:name :keycard-onboarding-recovery-phrase-confirm-word1
:component keycard.onboarding/recovery-phrase-confirm-word}
{:name :keycard-onboarding-recovery-phrase-confirm-word2
:component keycard.onboarding/recovery-phrase-confirm-word}
{:name :keycard-recovery-intro
:component keycard.recovery/intro}
{:name :keycard-recovery-start
:component keycard.recovery/start}
{:name :keycard-recovery-pair
:component keycard.recovery/pair}
{:name :keycard-recovery-recovering
:component keycard.recovery/recovering}
{:name :keycard-recovery-success
:component keycard.recovery/success}
{:name :keycard-recovery-no-key
:component keycard.recovery/no-key}
{:name :keycard-recovery-pin
:component keycard.recovery/pin}
{:name :hardwallet-authentication-method
:component hardwallet.authentication/hardwallet-authentication-method}
{:name :keycard-login-pin
:component keycard/login-pin}
{:name :keycard-blank
:component keycard/blank}
{:name :keycard-wrong
:component keycard/wrong}
{:name :keycard-unpaired
:component keycard/unpaired}
{:name :not-keycard
:component keycard/not-keycard}]])
{:name :recover-multiaccount-enter-phrase
:component intro/wizard-enter-phrase}
{:name :recover-multiaccount-select-storage
:component intro/wizard-select-key-storage}
{:name :recover-multiaccount-enter-password
:component intro/wizard-create-code}
{:name :recover-multiaccount-confirm-password
:component intro/wizard-confirm-code}
{:name :recover-multiaccount-success
:component intro/wizard-recovery-success}
{:name :keycard-pairing
:back-handler :noop
:component keycard/pairing}
{:name :keycard-onboarding-intro
:component keycard.onboarding/intro}
{:name :keycard-onboarding-start
:component keycard.onboarding/start}
{:name :keycard-onboarding-puk-code
:component keycard.onboarding/puk-code}
{:name :keycard-onboarding-preparing
:component keycard.onboarding/preparing}
{:name :keycard-onboarding-finishing
:component keycard.onboarding/finishing}
{:name :keycard-onboarding-pin
:component keycard.onboarding/pin}
{:name :keycard-onboarding-recovery-phrase
:component keycard.onboarding/recovery-phrase}
{:name :keycard-onboarding-recovery-phrase-confirm-word1
:component keycard.onboarding/recovery-phrase-confirm-word}
{:name :keycard-onboarding-recovery-phrase-confirm-word2
:component keycard.onboarding/recovery-phrase-confirm-word}
{:name :keycard-recovery-intro
:component keycard.recovery/intro}
{:name :keycard-recovery-start
:component keycard.recovery/start}
{:name :keycard-recovery-pair
:component keycard.recovery/pair}
{:name :keycard-recovery-recovering
:component keycard.recovery/recovering}
{:name :keycard-recovery-success
:component keycard.recovery/success}
{:name :keycard-recovery-no-key
:component keycard.recovery/no-key}
{:name :keycard-recovery-pin
:component keycard.recovery/pin}
{:name :hardwallet-authentication-method
:component hardwallet.authentication/hardwallet-authentication-method}
{:name :keycard-login-pin
:component keycard/login-pin}
{:name :keycard-blank
:component keycard/blank}
{:name :keycard-wrong
:component keycard/wrong}
{:name :keycard-unpaired
:component keycard/unpaired}
{:name :not-keycard
:component keycard/not-keycard}]]))
7 changes: 4 additions & 3 deletions src/status_im/ui/screens/routing/main.cljs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(ns status-im.ui.screens.routing.main
(:require-macros [status-im.utils.views :as views])
(:require [reagent.core :as reagent]
[re-frame.core :as re-frame]
[status-im.ui.screens.profile.tribute-to-talk.views :as tr-to-talk]
Expand Down Expand Up @@ -43,11 +44,11 @@
:insets {:top false}
:component profile-stack/profile-stack}]])

(defn get-main-component [_]
(fn []
(views/defview get-main-component [_]
(views/letsubs [logged-in? [:multiaccount/logged-in?]]
[main-stack (merge {:header-mode :none
:mode :modal})
[(if @(re-frame/subscribe [:multiaccount/logged-in?])
[(if logged-in?
{:name :tabs
:insets {:top false}
:component tabs}
Expand Down

0 comments on commit 44a8e2a

Please sign in to comment.