Refactor navigation files (#19068)

This commit is contained in:
Parvesh Monu 2024-03-13 19:09:09 +05:30 committed by GitHub
parent 1a8bca56e0
commit 6bda54266b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 167 additions and 362 deletions

View File

@ -28,8 +28,7 @@
[{:keys [db] :as cofx} {:keys [auth-method logout?]}] [{:keys [db] :as cofx} {:keys [auth-method logout?]}]
(let [key-uid (get-in db [:profile/profile :key-uid])] (let [key-uid (get-in db [:profile/profile :key-uid])]
(rf/merge cofx (rf/merge cofx
{:set-root :progress {:effects.shell/reset-state nil
:effects.shell/reset-state nil
:hide-popover nil :hide-popover nil
::logout nil ::logout nil
:profile.settings/webview-debug-changed false :profile.settings/webview-debug-changed false

View File

@ -1,7 +1,6 @@
(ns legacy.status-im.ui.screens.screens (ns legacy.status-im.ui.screens.screens
(:require (:require
[legacy.status-im.ui.components.colors :as colors] [legacy.status-im.ui.components.colors :as colors]
[legacy.status-im.ui.components.icons.icons :as icons]
[legacy.status-im.ui.screens.about-app.views :as about-app] [legacy.status-im.ui.screens.about-app.views :as about-app]
[legacy.status-im.ui.screens.advanced-settings.views :as advanced-settings] [legacy.status-im.ui.screens.advanced-settings.views :as advanced-settings]
[legacy.status-im.ui.screens.appearance.views :as appearance] [legacy.status-im.ui.screens.appearance.views :as appearance]
@ -48,10 +47,18 @@
[status-im.contexts.chat.group-details.view :as group-details] [status-im.contexts.chat.group-details.view :as group-details]
[utils.i18n :as i18n])) [utils.i18n :as i18n]))
(defn right-button-options (defn topbar-options
[id icon] [title]
{:id id {:elevation 0
:icon (icons/icon-source icon)}) :title {:color (if (colors/dark?) colors/white colors/black)
:text (i18n/label title)}
:rightButtonColor (if (colors/dark?) colors/white colors/black)
:background {:color (if (colors/dark?) colors/black colors/white)}
:backButton {:color (if (colors/dark?) colors/white colors/black)
:id :legacy-back-button
:testID :back-button
:visible true
:popStackOnPress false}})
(defn screens (defn screens
[] []
@ -77,7 +84,7 @@
{:name :stickers {:name :stickers
:options {:insets {:top? true} :options {:insets {:top? true}
:topBar {:title {:text (i18n/label :t/sticker-market)}}} :topBar (topbar-options :t/sticker-market)}
:component stickers/packs} :component stickers/packs}
{:name :stickers-pack {:name :stickers-pack
@ -90,7 +97,7 @@
:component group-chat/new-group} :component group-chat/new-group}
{:name :currency-settings {:name :currency-settings
:options {:topBar {:title {:text (i18n/label :t/main-currency)}} :options {:topBar (topbar-options :t/main-currency)
:insets {:top? true}} :insets {:top? true}}
:component currency-settings/currency-settings} :component currency-settings/currency-settings}
@ -100,27 +107,27 @@
:options {:topBar {:visible false}} :options {:topBar {:visible false}}
:component profile.user/my-profile} :component profile.user/my-profile}
{:name :contacts-list {:name :contacts-list
:options {:topBar {:title {:text (i18n/label :t/contacts)}} :options {:topBar (topbar-options :t/contacts)
:insets {:top? true}} :insets {:top? true}}
:component contacts-list/contacts-list} :component contacts-list/contacts-list}
{:name :ens-main {:name :ens-main
:options {:topBar {:title {:text (i18n/label :t/ens-usernames)}} :options {:topBar (topbar-options :t/ens-usernames)
:insets {:top? true}} :insets {:top? true}}
:component ens/main} :component ens/main}
{:name :ens-search {:name :ens-search
:options {:topBar {:title {:text (i18n/label :t/ens-your-username)}} :options {:topBar (topbar-options :t/ens-your-username)
:insets {:top? true}} :insets {:top? true}}
:component ens/search} :component ens/search}
{:name :ens-checkout {:name :ens-checkout
:options {:topBar {:title {:text (i18n/label :t/ens-your-username)}} :options {:topBar (topbar-options :t/ens-your-username)
:insets {:top? true}} :insets {:top? true}}
:component ens/checkout} :component ens/checkout}
{:name :ens-confirmation {:name :ens-confirmation
:options {:topBar {:title {:text (i18n/label :t/ens-your-username)}} :options {:topBar (topbar-options :t/ens-your-username)
:insets {:top? true}} :insets {:top? true}}
:component ens/confirmation} :component ens/confirmation}
{:name :ens-terms {:name :ens-terms
:options {:topBar {:title {:text (i18n/label :t/ens-terms-registration)}} :options {:topBar (topbar-options :t/ens-terms-registration)
:insets {:top? true}} :insets {:top? true}}
:component ens/terms} :component ens/terms}
{:name :ens-name-details {:name :ens-name-details
@ -128,7 +135,7 @@
:options {:insets {:top? true}} :options {:insets {:top? true}}
:component ens/name-details} :component ens/name-details}
{:name :blocked-users-list {:name :blocked-users-list
:options {:topBar {:title {:text (i18n/label :t/blocked-users)}} :options {:topBar (topbar-options :t/blocked-users)
:insets {:top? true}} :insets {:top? true}}
:component contacts-list/blocked-users-list} :component contacts-list/blocked-users-list}
{:name :wakuv2-settings {:name :wakuv2-settings
@ -144,7 +151,7 @@
:options {:insets {:top? true}} :options {:insets {:top? true}}
:component bootnodes-settings/bootnodes-settings} :component bootnodes-settings/bootnodes-settings}
{:name :installations {:name :installations
:options {:topBar {:title {:text (i18n/label :t/devices)}} :options {:topBar (topbar-options (i18n/label :t/devices))
:insets {:top? true}} :insets {:top? true}}
:component pairing/installations} :component pairing/installations}
{:name :edit-bootnode {:name :edit-bootnode
@ -160,63 +167,63 @@
:options {:insets {:top? true}} :options {:insets {:top? true}}
:component edit-mailserver/edit-mailserver} :component edit-mailserver/edit-mailserver}
{:name :dapps-permissions {:name :dapps-permissions
:options {:topBar {:title {:text (i18n/label :t/dapps-permissions)}} :options {:topBar (topbar-options :t/dapps-permissions)
:insets {:top? true}} :insets {:top? true}}
:component dapps-permissions/dapps-permissions} :component dapps-permissions/dapps-permissions}
{:name :privacy-and-security {:name :privacy-and-security
:options {:topBar {:title {:text (i18n/label :t/privacy-and-security)}} :options {:topBar (topbar-options :t/privacy-and-security)
:insets {:top? true}} :insets {:top? true}}
:component privacy-and-security/privacy-and-security} :component privacy-and-security/privacy-and-security}
{:name :messages-from-contacts-only {:name :messages-from-contacts-only
:options {:topBar {:title {:text (i18n/label :t/accept-new-chats-from)}} :options {:topBar (topbar-options :t/accept-new-chats-from)
:insets {:top? true}} :insets {:top? true}}
:component messages-from-contacts-only/messages-from-contacts-only-view} :component messages-from-contacts-only/messages-from-contacts-only-view}
{:name :appearance {:name :appearance
:options {:topBar {:title {:text (i18n/label :t/appearance)}} :options {:topBar (topbar-options :t/appearance)
:insets {:top? true}} :insets {:top? true}}
:component appearance/appearance-view} :component appearance/appearance-view}
{:name :privacy-and-security-profile-pic-show-to {:name :privacy-and-security-profile-pic-show-to
:options {:topbar {:title {:text (i18n/label :t/show-profile-pictures-to)}} :options {:topbar (topbar-options :t/show-profile-pictures-to)
:insets {:top? true}} :insets {:top? true}}
:component privacy-and-security/profile-pic-show-to} :component privacy-and-security/profile-pic-show-to}
{:name :privacy-and-security-profile-pic {:name :privacy-and-security-profile-pic
:options {:topBar {:title {:text (i18n/label :t/show-profile-pictures)}} :options {:topBar (topbar-options :t/show-profile-pictures)
:insets {:top? true}} :insets {:top? true}}
:component privacy-and-security/profile-pic} :component privacy-and-security/profile-pic}
{:name :notifications {:name :notifications
:options {:topBar {:title {:text (i18n/label :t/notification-settings)}} :options {:topBar (topbar-options :t/notification-settings)
:insets {:top? true}} :insets {:top? true}}
:component notifications-settings/notifications-settings} :component notifications-settings/notifications-settings}
{:name :sync-settings {:name :sync-settings
:options {:topBar {:title {:text (i18n/label :t/sync-settings)}} :options {:topBar (topbar-options :t/sync-settings)
:insets {:top? true}} :insets {:top? true}}
:component sync-settings/sync-settings} :component sync-settings/sync-settings}
{:name :advanced-settings {:name :advanced-settings
:options {:topBar {:title {:text (i18n/label :t/advanced)}} :options {:topBar (topbar-options :t/advanced)
:insets {:top? true}} :insets {:top? true}}
:component advanced-settings/advanced-settings} :component advanced-settings/advanced-settings}
{:name :help-center {:name :help-center
:options {:topBar {:title {:text (i18n/label :t/need-help)}} :options {:topBar (topbar-options :t/need-help)
:insets {:top? true}} :insets {:top? true}}
:component help-center/help-center} :component help-center/help-center}
{:name :glossary {:name :glossary
:options {:topBar {:title {:text (i18n/label :t/glossary)}} :options {:topBar (topbar-options :t/glossary)
:insets {:top? true}} :insets {:top? true}}
:component glossary/glossary} :component glossary/glossary}
{:name :about-app {:name :about-app
:options {:topBar {:title {:text (i18n/label :t/about-app)}} :options {:topBar (topbar-options :t/about-app)
:insets {:top? true}} :insets {:top? true}}
:component about-app/about-app} :component about-app/about-app}
{:name :privacy-policy {:name :privacy-policy
:options {:topBar {:title {:text (i18n/label :t/privacy-policy)}} :options {:topBar (topbar-options :t/privacy-policy)
:insets {:top? true}} :insets {:top? true}}
:component about-app/privacy-policy} :component about-app/privacy-policy}
{:name :terms-of-service {:name :terms-of-service
:options {:topBar {:title {:text (i18n/label :t/terms-of-service)}} :options {:topBar (topbar-options :t/terms-of-service)
:insets {:top? true}} :insets {:top? true}}
:component about-app/tos} :component about-app/tos}
{:name :principles {:name :principles
:options {:topBar {:title {:text (i18n/label :t/principles)}} :options {:topBar (topbar-options :t/principles)
:insets {:top? true}} :insets {:top? true}}
:component about-app/principles} :component about-app/principles}
{:name :manage-dapps-permissions {:name :manage-dapps-permissions
@ -224,27 +231,27 @@
:options {:insets {:top? true}} :options {:insets {:top? true}}
:component dapps-permissions/manage} :component dapps-permissions/manage}
{:name :rpc-usage-info {:name :rpc-usage-info
:options {:topBar {:title {:text (i18n/label :t/rpc-usage-info)}} :options {:topBar (topbar-options :t/rpc-usage-info)
:insets {:top? true}} :insets {:top? true}}
:component rpc-usage-info/usage-info} :component rpc-usage-info/usage-info}
{:name :peers-stats {:name :peers-stats
:options {:topBar {:title {:text (i18n/label :t/peers-stats)}} :options {:topBar (topbar-options :t/peers-stats)
:insets {:top? true}} :insets {:top? true}}
:component peers-stats/peers-stats} :component peers-stats/peers-stats}
{:name :log-level-settings {:name :log-level-settings
:options {:topBar {:title {:text (i18n/label :t/log-level-settings)}} :options {:topBar (topbar-options :t/log-level-settings)
:insets {:top? true}} :insets {:top? true}}
:component log-level-settings/log-level-settings} :component log-level-settings/log-level-settings}
{:name :fleet-settings {:name :fleet-settings
:options {:topBar {:title {:text (i18n/label :t/fleet-settings)}} :options {:topBar (topbar-options :t/fleet-settings)
:insets {:top? true}} :insets {:top? true}}
:component fleet-settings/fleet-settings} :component fleet-settings/fleet-settings}
{:name :mobile-network-settings {:name :mobile-network-settings
:options {:topBar {:title {:text (i18n/label :t/mobile-network-settings)}} :options {:topBar (topbar-options :t/mobile-network-settings)
:insets {:top? true}} :insets {:top? true}}
:component mobile-network-settings/mobile-network-settings} :component mobile-network-settings/mobile-network-settings}
{:name :backup-settings {:name :backup-settings
:options {:topBar {:title {:text (i18n/label :t/backup-settings)}} :options {:topBar (topbar-options :t/backup-settings)
:insets {:top? true}} :insets {:top? true}}
:component backup-settings/backup-settings} :component backup-settings/backup-settings}
{:name :backup-seed {:name :backup-seed
@ -252,14 +259,14 @@
:options {:insets {:top? true}} :options {:insets {:top? true}}
:component profile.seed/backup-seed} :component profile.seed/backup-seed}
{:name :reset-password {:name :reset-password
:options {:topBar {:title {:text (i18n/label :t/reset-password)}} :options {:topBar (topbar-options :t/reset-password)
:insets {:top? true}} :insets {:top? true}}
:component reset-password/reset-password} :component reset-password/reset-password}
{:name :delete-profile {:name :delete-profile
:insets {:bottom? true} :insets {:bottom? true}
:component delete-profile/delete-profile} :component delete-profile/delete-profile}
{:name :default-sync-period-settings {:name :default-sync-period-settings
:options {:topBar {:title {:text (i18n/label :t/default-sync-period)}} :options {:topBar (topbar-options :t/default-sync-period)
:insets {:top? true}} :insets {:top? true}}
:component default-sync-period-settings/default-sync-period-settings} :component default-sync-period-settings/default-sync-period-settings}
@ -268,7 +275,7 @@
;[Chat] Link preview settings ;[Chat] Link preview settings
{:name :link-previews-settings {:name :link-previews-settings
:options {:topBar {:title {:text (i18n/label :t/chat-link-previews)}} :options {:topBar (topbar-options :t/chat-link-previews)
:insets {:top? true}} :insets {:top? true}}
:component link-previews-settings/link-previews-settings} :component link-previews-settings/link-previews-settings}
@ -308,7 +315,7 @@
;;TODO WHY MODAL? ;;TODO WHY MODAL?
;[Profile] Notifications settings ;[Profile] Notifications settings
{:name :notifications-settings {:name :notifications-settings
:options {:topBar {:title {:text (i18n/label :t/notification-settings)}} :options {:topBar (topbar-options :t/notification-settings)
:popGesture false :popGesture false
:hardwareBackButton {:dismissModalOnPress false :hardwareBackButton {:dismissModalOnPress false
:popStackOnPress false} :popStackOnPress false}

View File

@ -56,7 +56,9 @@
(rf/dispatch event)) (rf/dispatch event))
(effects/dismiss-modal)) (effects/dismiss-modal))
(when-let [handler (get-in views/screens [(keyword id) :right-handler])] (when-let [handler (get-in views/screens [(keyword id) :right-handler])]
(handler))))) (handler)))
(when (= "legacy-back-button" id)
(rf/dispatch [:navigate-back]))))
(navigation/reg-modal-dismissed-listener (navigation/reg-modal-dismissed-listener
(fn [] (fn []
@ -92,35 +94,16 @@
(navigation/register-component (navigation/register-component
"bottom-sheet" "bottom-sheet"
(fn [] (gesture/gesture-handler-root-hoc views/bottom-sheet)) (fn [] (gesture/gesture-handler-root-hoc views/bottom-sheet))
(fn [] views/bottom-sheet))) (fn [] views/bottom-sheet))
;;;; Alert Banner ;;;; Alert Banner
(navigation/register-component (navigation/register-component
"alert-banner" "alert-banner"
(fn [] (gesture/gesture-handler-root-hoc views/alert-banner #js {:flex 0})) (fn [] (gesture/gesture-handler-root-hoc views/alert-banner #js {:flex 0}))
(fn [] views/alert-banner)) (fn [] views/alert-banner))
;;;; LEGACY (should be removed in status 2.0)
;; LEGACY (should be removed in status 2.0) (navigation/register-component
"bottom-sheet-old"
(defonce (fn [] (gesture/gesture-handler-root-hoc views/sheet-comp-old))
_ (fn [] views/sheet-comp-old)))
[(navigation/register-component
"popover"
(fn [] (gesture/gesture-handler-root-hoc views/popover-comp))
(fn [] views/popover-comp))
(navigation/register-component
"visibility-status-popover"
(fn [] (gesture/gesture-handler-root-hoc views/visibility-status-popover-comp))
(fn [] views/visibility-status-popover-comp))
(navigation/register-component
"bottom-sheet-old"
(fn [] (gesture/gesture-handler-root-hoc views/sheet-comp-old))
(fn [] views/sheet-comp-old))
(navigation/register-component
"signing-sheet"
(fn [] (gesture/gesture-handler-root-hoc views/signing-comp))
(fn [] views/signing-comp))])

View File

@ -63,12 +63,8 @@
(name @state/root-id) (name @state/root-id)
{:component {:id component {:component {:id component
:name component :name component
:options (merge (options/default-root) :options (merge (options/root-options {:theme (:theme options)})
(options/statusbar-and-navbar) options)}})))
options
(if (:topBar options)
(options/merge-top-bar (options/topbar-options) options)
{:topBar {:visible false}}))}})))
(rf/reg-fx :navigate-to navigate) (rf/reg-fx :navigate-to navigate)
@ -81,11 +77,9 @@
(name comp-id) (name comp-id)
{:component {:id component {:component {:id component
:name component :name component
:options (merge (options/statusbar-and-navbar) :options (merge
options (options/root-options {:theme (:theme options)})
(if (:topBar options) options)}})))
(options/merge-top-bar (options/topbar-options) options)
{:topBar {:visible false}}))}})))
(rf/reg-fx :navigate-to-within-stack navigate-to-within-stack) (rf/reg-fx :navigate-to-within-stack navigate-to-within-stack)
@ -140,8 +134,7 @@
{:stack {:children [{:component {:stack {:children [{:component
{:name component {:name component
:id component :id component
:options (merge (options/default-root) :options (merge (options/root-options {:theme (:theme options)})
(options/statusbar-and-navbar)
options options
(when sheet? (when sheet?
options/sheet-options))}}]}}))))) options/sheet-options))}}]}})))))
@ -157,7 +150,7 @@
(navigation/show-overlay (navigation/show-overlay
{:component {:name component {:component {:name component
:id component :id component
:options (merge (options/statusbar) :options (merge (options/statusbar-and-navbar-options (:theme opts) nil nil)
{:layout {:componentBackgroundColor :transparent {:layout {:componentBackgroundColor :transparent
:orientation ["portrait"]} :orientation ["portrait"]}
:overlay {:interceptTouchOutside true}} :overlay {:interceptTouchOutside true}}
@ -201,9 +194,8 @@
(let [{:keys [options]} (get views/screens component)] (let [{:keys [options]} (get views/screens component)]
{:component {:id component {:component {:id component
:name component :name component
:options (merge (options/statusbar-and-navbar) :options (merge (options/statusbar-and-navbar-options (:theme options) nil nil)
options options)}}))
(options/merge-top-bar (options/topbar-options) options))}}))
(rf/reg-fx :set-stack-root-fx (rf/reg-fx :set-stack-root-fx
(fn [[stack component]] (fn [[stack component]]

View File

@ -155,22 +155,6 @@
#(when-not hide? #(when-not hide?
(if (seq sheets) (hide-bottom-sheet %) {:show-bottom-sheet nil}))))) (if (seq sheets) (hide-bottom-sheet %) {:show-bottom-sheet nil})))))
;; LEGACY (should be removed in status 2.0)
(rf/defn hide-signing-sheet
{:events [:hide-signing-sheet]}
[_]
{:hide-signing-sheet nil})
(rf/defn set-multiaccount-root
{:events [:set-multiaccount-root]}
[{:keys [db]}]
(let [key-uid (get-in db [:profile/login :key-uid])
keycard-account? (boolean (get-in db
[:profile/profiles-overview
key-uid
:keycard-pairing]))]
{:set-root (if keycard-account? :multiaccounts-keycard :multiaccounts)}))
(rf/defn dismiss-all-overlays (rf/defn dismiss-all-overlays
{:events [:dismiss-all-overlays]} {:events [:dismiss-all-overlays]}
[_] [_]
@ -178,7 +162,6 @@
[:hide-visibility-status-popover] [:hide-visibility-status-popover]
[:hide-bottom-sheet] [:hide-bottom-sheet]
[:bottom-sheet-hidden] [:bottom-sheet-hidden]
[:hide-signing-sheet]
[:bottom-sheet/hide-old-navigation-overlay] [:bottom-sheet/hide-old-navigation-overlay]
[:toasts/close-all-toasts]]}) [:toasts/close-all-toasts]]})

View File

@ -10,23 +10,23 @@
{:layout {:orientation ["portrait"]} {:layout {:orientation ["portrait"]}
:topBar {:visible false}}) :topBar {:visible false}})
;; Note: Currently, the status bar style provided while setting the root has a high preference, (defn statusbar-and-navbar-options
;; and even if we change the status bar style later dynamically, the style gets restored to this [theme status-bar-theme nav-bar-color]
;; set root style while navigating (let [[status-bar-theme nav-bar-color]
;; https://github.com/status-im/status-mobile/pull/15596 (if (= :dark (or theme (quo.theme/get-theme)))
(defn statusbar-and-navbar-root [(or status-bar-theme :light) (or nav-bar-color colors/neutral-100)]
[& [status-bar-theme]] [(or status-bar-theme :dark) (or nav-bar-color colors/white)])]
(if platform/android? (if platform/android?
{:navigationBar {:backgroundColor colors/neutral-100} {:navigationBar {:backgroundColor nav-bar-color}
:statusBar {:translucent true :statusBar {:translucent true
:backgroundColor :transparent :backgroundColor :transparent
:style (or status-bar-theme :light) :style (or status-bar-theme :light)
:drawBehind true}} :drawBehind true}}
{:statusBar {:style (or status-bar-theme :light)}})) {:statusBar {:style (or status-bar-theme :light)}})))
(defn default-root (defn root-options
[& [status-bar-theme background-color]] [{:keys [background-color theme status-bar-theme nav-bar-color]}]
(merge (statusbar-and-navbar-root status-bar-theme) (merge (statusbar-and-navbar-options theme status-bar-theme nav-bar-color)
{:topBar {:visible false} {:topBar {:visible false}
:layout {:componentBackgroundColor (or background-color :layout {:componentBackgroundColor (or background-color
(colors/theme-colors colors/white colors/neutral-100)) (colors/theme-colors colors/white colors/neutral-100))
@ -35,6 +35,15 @@
(colors/theme-colors colors/white (colors/theme-colors colors/white
colors/neutral-100))}})) colors/neutral-100))}}))
(defn dark-root-options
[]
(root-options
{:background-color colors/neutral-100
:theme :dark
:status-bar-theme :light
:nav-bar-color colors/neutral-100}))
;;;; Screen Specific Options
(def onboarding-layout (def onboarding-layout
{:componentBackgroundColor colors/neutral-80-opa-80-blur {:componentBackgroundColor colors/neutral-80-opa-80-blur
:orientation ["portrait"] :orientation ["portrait"]
@ -45,49 +54,12 @@
:orientation ["portrait"] :orientation ["portrait"]
:backgroundColor :transparent}) :backgroundColor :transparent})
(defn navbar
([dark?]
{:navigationBar {:backgroundColor (if (or dark? (= :dark (quo.theme/get-theme)))
colors/neutral-100
colors/white)}})
([] (navbar nil)))
(defn statusbar
([dark?]
(let [style (if (or dark? (= :dark (quo.theme/get-theme))) :light :dark)]
(if platform/android?
{:statusBar {:translucent true
:backgroundColor :transparent
:drawBehind true
:style style}}
{:statusBar {:style style}})))
([] (statusbar nil)))
(defn statusbar-and-navbar
([dark?]
(merge (navbar dark?) (statusbar dark?)))
([] (statusbar-and-navbar nil)))
(defn topbar-options
[]
{:noBorder true
:scrollEdgeAppearance {:active false
:noBorder true}
:elevation 0
:title {:color (colors/theme-colors colors/neutral-100 colors/white)}
:rightButtonColor (colors/theme-colors colors/neutral-100 colors/white)
:background {:color (colors/theme-colors colors/white colors/neutral-100)}
:backButton {:color (colors/theme-colors colors/neutral-100 colors/white)
:testID :back-button}})
(def transparent-screen-options (def transparent-screen-options
(merge {:modalPresentationStyle :overCurrentContext
(statusbar-and-navbar-root) :theme :dark
{:modalPresentationStyle :overCurrentContext :layout {:componentBackgroundColor :transparent
:theme :dark :orientation ["portrait"]
:layout {:componentBackgroundColor :transparent :backgroundColor :transparent}})
:orientation ["portrait"]
:backgroundColor :transparent}}))
(def transparent-modal-screen-options (def transparent-modal-screen-options
(merge (merge
@ -109,11 +81,10 @@
{})}) {})})
(def dark-screen (def dark-screen
(merge (statusbar-and-navbar-root) {:theme :dark
{:theme :dark :layout {:componentBackgroundColor colors/neutral-95
:layout {:componentBackgroundColor colors/neutral-95 :orientation ["portrait"]
:orientation ["portrait"] :backgroundColor colors/neutral-95}})
:backgroundColor colors/neutral-95}}))
(def lightbox (def lightbox
{:topBar {:visible false} {:topBar {:visible false}
@ -136,20 +107,3 @@
:interpolation {:type :interpolation {:type
:decelerate :decelerate
:factor 1.5}}]}}}) :factor 1.5}}]}}})
(defn merge-top-bar
[root-options options]
(let [options (:topBar options)]
{:topBar
(merge root-options
options
(when (or (:title root-options) (:title options))
{:title (merge (:title root-options) (:title options))})
(when (or (:background root-options) (:background options))
{:background (merge (:background root-options) (:background options))})
(when (or (:backButton root-options) (:backButton options))
{:backButton (merge (:backButton root-options) (:backButton options))})
(when (or (:leftButtons root-options) (:leftButtons options))
{:leftButtons (merge (:leftButtons root-options) (:leftButtons options))})
(when (or (:rightButtons root-options) (:rightButtons options))
{:rightButtons (merge (:rightButtons root-options) (:rightButtons options))}))}))

View File

@ -1,74 +1,8 @@
(ns status-im.navigation.roots (ns status-im.navigation.roots
(:require (:require
[quo.foundations.colors :as colors] [quo.foundations.colors :as colors]
[quo.theme :as quo.theme]
[status-im.constants :as constants] [status-im.constants :as constants]
[status-im.navigation.options :as options] [status-im.navigation.options :as options]))
[status-im.navigation.view :as views]))
(defn get-screen-options
[screen]
(merge (get-in views/screens [screen :options])
(options/statusbar-and-navbar-root)
(options/merge-top-bar (options/topbar-options)
(get-in views/screens [screen :options]))))
(defn old-roots
[]
{;; ONBOARDING
:onboarding
{:root {:stack {:id :onboarding
:children [{:component {:name :get-your-keys
:id :get-your-keys
:options (options/statusbar-and-navbar-root)}}]
:options (merge (options/default-root)
(options/statusbar-and-navbar-root)
{:topBar (assoc (options/topbar-options)
:elevation 0
:noBorder true
:animate false)})}}}
;;PROGRESS
:progress
{:root {:stack {:children [{:component {:name :progress
:id :progress
:options (options/statusbar-and-navbar-root)}}]
:options (merge (options/default-root)
{:topBar (assoc (options/topbar-options) :visible false)})}}}
;;LOGIN
:multiaccounts
{:root {:stack {:id :multiaccounts-stack
:children [{:component {:name :multiaccounts
:id :multiaccounts
:options (get-screen-options :multiaccounts)}}
{:component {:name :login
:id :login
:options (get-screen-options :login)}}]
:options (merge (options/default-root)
(options/statusbar-and-navbar-root)
{:topBar (options/topbar-options)})}}}
:multiaccounts-keycard
{:root {:stack {:id :multiaccounts-stack
:children [{:component {:name :profiles
:id :profiles
:options (get-screen-options :multiaccounts)}}
{:component {:name :keycard-login-pin
:id :keycard-login-pin
:options (get-screen-options :keycard-login-pin)}}]
:options (merge (options/default-root)
(options/statusbar-and-navbar-root)
{:topBar (options/topbar-options)})}}}
;;NOTIFICATIONS
:onboarding-notification
{:root {:stack {:children [{:component {:name :onboarding-notification
:id :onboarding-notification
:options (options/statusbar-and-navbar-root)}}]
:options (merge (options/default-root)
(options/statusbar-and-navbar-root)
{:topBar (assoc (options/topbar-options) :visible false)})}}}})
;; Theme Order for navigation roots ;; Theme Order for navigation roots
;; 1. Themes hardcoded in below map ;; 1. Themes hardcoded in below map
@ -82,39 +16,36 @@
(defn roots (defn roots
[] []
(merge {:intro
(old-roots) {:root
{:stack {:id :intro
:children [{:component {:name :intro
:id :intro
:options (options/dark-root-options)}}]}}}
:shell-stack
{:root
{:stack {:id :shell-stack
:children [{:component {:name :shell-stack
:id :shell-stack
:options (options/root-options
{:nav-bar-color colors/neutral-100})}}]}}}
:profiles
{:root
{:stack {:id :profiles
:children [{:component {:name :profiles
:id :profiles
:options (options/dark-root-options)}}]}}}
{:intro :enable-notifications
{:root {:root {:stack {:children [{:component {:name :enable-notifications
{:stack {:id :intro :id :enable-notifications
:children [{:component {:name :intro :options (options/dark-root-options)}}]}}}
:id :intro
:options (options/default-root nil colors/neutral-100)}}]}}}
:shell-stack
{:root
{:stack {:id :shell-stack
:children [{:component {:name :shell-stack
:id :shell-stack
:options (options/default-root
(if (= :dark (quo.theme/get-theme)) :light :dark))}}]}}}
:profiles
{:root
{:stack {:id :profiles
:children [{:component {:name :profiles
:id :profiles
:options (options/default-root)}}]}}}
:enable-notifications :welcome
{:root {:stack {:children [{:component {:name :enable-notifications {:root {:stack {:children [{:component {:name :welcome
:id :enable-notifications :id :welcome
:options (options/default-root)}}]}}} :options (options/dark-root-options)}}]}}}
:syncing-results
:welcome {:root {:stack {:children [{:component {:name :syncing-results
{:root {:stack {:children [{:component {:name :welcome :id :syncing-results
:id :welcome :options (options/dark-root-options)}}]}}}})
:options (options/default-root)}}]}}}
:syncing-results
{:root {:stack {:children [{:component {:name :syncing-results
:id :syncing-results
:options (options/default-root)}}]}}}}))

View File

@ -130,7 +130,7 @@
:component lightbox/lightbox} :component lightbox/lightbox}
{:name :photo-selector {:name :photo-selector
:options (merge {:sheet? true} (options/statusbar-and-navbar-root)) :options {:sheet? true}
:component photo-selector/photo-selector} :component photo-selector/photo-selector}
{:name :camera-screen {:name :camera-screen
@ -230,17 +230,15 @@
:component create-password/create-password} :component create-password/create-password}
{:name :enable-biometrics {:name :enable-biometrics
:options (merge :options {:theme :dark
(options/statusbar-and-navbar-root) :layout options/onboarding-transparent-layout
{:theme :dark :animations (merge
:layout options/onboarding-transparent-layout transitions/new-to-status-modal-animations
:animations (merge transitions/push-animations-for-transparent-background)
transitions/new-to-status-modal-animations :popGesture false
transitions/push-animations-for-transparent-background) :modalPresentationStyle :overCurrentContext
:popGesture false :hardwareBackButton {:dismissModalOnPress false
:modalPresentationStyle :overCurrentContext :popStackOnPress false}}
:hardwareBackButton {:dismissModalOnPress false
:popStackOnPress false}})
:component enable-biometrics/view} :component enable-biometrics/view}
{:name :generating-keys {:name :generating-keys
@ -260,14 +258,12 @@
:component enter-seed-phrase/enter-seed-phrase} :component enter-seed-phrase/enter-seed-phrase}
{:name :enable-notifications {:name :enable-notifications
:options (merge :options {:theme :dark
(options/statusbar-and-navbar-root) :layout options/onboarding-transparent-layout
{:theme :dark :animations (merge
:layout options/onboarding-transparent-layout transitions/new-to-status-modal-animations
:animations (merge transitions/push-animations-for-transparent-background)
transitions/new-to-status-modal-animations :modalPresentationStyle :overCurrentContext}
transitions/push-animations-for-transparent-background)
:modalPresentationStyle :overCurrentContext})
:component enable-notifications/view} :component enable-notifications/view}
{:name :identifiers {:name :identifiers
@ -298,11 +294,9 @@
:component sign-in/view} :component sign-in/view}
{:name :syncing-progress {:name :syncing-progress
:options (merge :options {:theme :dark
(options/statusbar-and-navbar-root) :layout options/onboarding-layout
{:theme :dark :popGesture false}
:layout options/onboarding-layout
:popGesture false})
:component syncing-devices/view} :component syncing-devices/view}
{:name :syncing-progress-intro {:name :syncing-progress-intro
@ -317,11 +311,9 @@
:component syncing-results/view} :component syncing-results/view}
{:name :welcome {:name :welcome
:options (merge :options {:theme :dark
(options/statusbar-and-navbar-root) :layout options/onboarding-transparent-layout
{:theme :dark :animations transitions/push-animations-for-transparent-background}
:layout options/onboarding-transparent-layout
:animations transitions/push-animations-for-transparent-background})
:component welcome/view} :component welcome/view}
{:name :emoji-picker {:name :emoji-picker

View File

@ -1,9 +1,6 @@
(ns status-im.navigation.view (ns status-im.navigation.view
(:require (:require
[legacy.status-im.bottom-sheet.sheets :as bottom-sheets-old] [legacy.status-im.bottom-sheet.sheets :as bottom-sheets-old]
[legacy.status-im.ui.screens.popover.views :as popover]
[legacy.status-im.ui.screens.profile.visibility-status.views :as visibility-status-views]
[legacy.status-im.ui.screens.signing.views :as signing]
[quo.foundations.colors :as colors] [quo.foundations.colors :as colors]
[quo.theme :as theme] [quo.theme :as theme]
[react-native.core :as rn] [react-native.core :as rn]
@ -111,29 +108,15 @@
(def toasts (reagent/reactify-component toasts/toasts)) (def toasts (reagent/reactify-component toasts/toasts))
(def alert-banner
(reagent/reactify-component
(fn []
^{:key (str "alert-banner" @reloader/cnt)}
[theme/provider {:theme :dark}
[alert-banner/view]])
functional-compiler))
;; LEGACY (should be removed in status 2.0) ;; LEGACY (should be removed in status 2.0)
(def popover-comp
(reagent/reactify-component
(fn []
^{:key (str "popover" @reloader/cnt)}
[:<>
[inactive]
[popover/popover]
(when js/goog.DEBUG
[reloader/reload-view])])
functional-compiler))
(def visibility-status-popover-comp
(reagent/reactify-component
(fn []
^{:key (str "visibility-status-popover" @reloader/cnt)}
[rn/view
[inactive]
[visibility-status-views/visibility-status-popover]
(when js/goog.DEBUG
[reloader/reload-view])])
functional-compiler))
(def sheet-comp-old (def sheet-comp-old
(reagent/reactify-component (reagent/reactify-component
(fn [] (fn []
@ -142,22 +125,3 @@
[inactive] [inactive]
[bottom-sheets-old/bottom-sheet]]) [bottom-sheets-old/bottom-sheet]])
functional-compiler)) functional-compiler))
(def signing-comp
(reagent/reactify-component
(fn []
^{:key (str "signing-sheet" @reloader/cnt)}
[:<>
[inactive]
[signing/signing]
(when js/goog.DEBUG
[reloader/reload-view])])
functional-compiler))
(def alert-banner
(reagent/reactify-component
(fn []
^{:key (str "alert-banner" @reloader/cnt)}
[theme/provider {:theme :dark}
[alert-banner/view]])
functional-compiler))