From 112b69c1d6c14290e776400b012b0eaa5ec7e6cb Mon Sep 17 00:00:00 2001 From: Parvesh Monu Date: Thu, 27 Jun 2024 20:23:51 +0530 Subject: [PATCH] fix ios wrong status bar color in dark theme (#20540) --- ios/StatusIm/Info.plist | 4 +- .../status_im/multiaccounts/logout/core.cljs | 2 +- src/legacy/status_im/ui/screens/screens.cljs | 3 +- src/status_im/contexts/onboarding/events.cljs | 2 +- src/status_im/contexts/profile/events.cljs | 4 +- .../contexts/profile/login/events.cljs | 6 +- src/status_im/navigation/effects.cljs | 62 ++++++++++--------- src/status_im/navigation/events.cljs | 4 +- src/status_im/navigation/roots.cljs | 16 ++--- 9 files changed, 53 insertions(+), 50 deletions(-) diff --git a/ios/StatusIm/Info.plist b/ios/StatusIm/Info.plist index aee707deb1..b4325f88ab 100644 --- a/ios/StatusIm/Info.plist +++ b/ios/StatusIm/Info.plist @@ -119,8 +119,6 @@ armv7 - UIStatusBarStyle - UIStatusBarStyleLightContent UISupportedInterfaceOrientations UIInterfaceOrientationPortrait @@ -133,7 +131,7 @@ UIInterfaceOrientationLandscapeRight UIViewControllerBasedStatusBarAppearance - + com.apple.developer.nfc.readersession.iso7816.select-identifiers A00000080400010101 diff --git a/src/legacy/status_im/multiaccounts/logout/core.cljs b/src/legacy/status_im/multiaccounts/logout/core.cljs index 16ef78dd02..75951404ba 100644 --- a/src/legacy/status_im/multiaccounts/logout/core.cljs +++ b/src/legacy/status_im/multiaccounts/logout/core.cljs @@ -28,7 +28,7 @@ [{:keys [db] :as cofx} {:keys [auth-method logout?]}] (let [key-uid (get-in db [:profile/profile :key-uid])] (rf/merge cofx - {:set-root :progress + {:dispatch [:init-root :progress] :effects.shell/reset-state nil :hide-popover nil ::logout nil diff --git a/src/legacy/status_im/ui/screens/screens.cljs b/src/legacy/status_im/ui/screens/screens.cljs index fe5ee41f4c..a95785c65b 100644 --- a/src/legacy/status_im/ui/screens/screens.cljs +++ b/src/legacy/status_im/ui/screens/screens.cljs @@ -53,7 +53,8 @@ [] [;;PROGRESS {:name :progress - :options {:insets {:top? true}} + :options {:insets {:top? true} + :theme :dark} :component progress/progress} ;;COMMUNITY diff --git a/src/status_im/contexts/onboarding/events.cljs b/src/status_im/contexts/onboarding/events.cljs index b4b66db725..865d0ba09c 100644 --- a/src/status_im/contexts/onboarding/events.cljs +++ b/src/status_im/contexts/onboarding/events.cljs @@ -89,7 +89,7 @@ (merge {:db (assoc db :profile/profiles-overview multiaccounts)} (when-not (seq multiaccounts) - {:set-root :screen/onboarding.intro})))) + {:dispatch [:init-root :screen/onboarding.intro]})))) (rf/defn password-set {:events [:onboarding/password-set]} diff --git a/src/status_im/contexts/profile/events.cljs b/src/status_im/contexts/profile/events.cljs index d576028688..337ecbb5de 100644 --- a/src/status_im/contexts/profile/events.cljs +++ b/src/status_im/contexts/profile/events.cljs @@ -45,14 +45,14 @@ (assoc :profile/profiles-overview profiles) (update :profile/login #(select-profile % key-uid))) db) - :fx [[:set-root :screen/profile.profiles] + :fx [[:dispatch [:init-root :screen/profile.profiles]] (when key-uid [:effects.biometric/check-if-available {:key-uid key-uid :on-success (fn [auth-method] (rf/dispatch [:profile.login/check-biometric-success key-uid auth-method]))}])]}) - {:fx [[:set-root :screen/onboarding.intro]]}))) + {:fx [[:dispatch [:init-root :screen/onboarding.intro]]]}))) (rf/reg-event-fx :profile/update-setting-from-backup diff --git a/src/status_im/contexts/profile/login/events.cljs b/src/status_im/contexts/profile/login/events.cljs index 20bec6d444..ac971fd57a 100644 --- a/src/status_im/contexts/profile/login/events.cljs +++ b/src/status_im/contexts/profile/login/events.cljs @@ -74,7 +74,7 @@ (cond pairing-completed? - [[:set-root :screen/onboarding.syncing-results]] + [[:dispatch [:init-root :screen/onboarding.syncing-results]]] (get db :onboarding/new-account?) [[:dispatch [:onboarding/finalize-setup]]] @@ -85,7 +85,7 @@ constants/theme-type-dark) :shell-stack false]] - [:set-root :shell-stack] + [:dispatch [:init-root :shell-stack]] [:dispatch [:profile/show-testnet-mode-banner-if-enabled]]]))}))) ;; login phase 2: we want to load and show chats faster, so we split login into 2 phases @@ -179,7 +179,7 @@ {:db (-> db (assoc-in [:profile/login :password] password) (assoc-in [:profile/login :processing] true)) - :fx [[:set-root :progress] + :fx [[:dispatch [:init-root :progress]] [:effects.profile/login [(get-in db [:profile/login :key-uid]) (security/safe-unmask-data password)]]]}))) diff --git a/src/status_im/navigation/effects.cljs b/src/status_im/navigation/effects.cljs index 6acb2d4315..e28550cc71 100644 --- a/src/status_im/navigation/effects.cljs +++ b/src/status_im/navigation/effects.cljs @@ -2,7 +2,6 @@ (:require [quo.foundations.colors :as colors] [quo.theme] - [react-native.core :as rn] [react-native.navigation :as navigation] [react-native.platform :as platform] [react-native.share :as share] @@ -17,37 +16,36 @@ (defn get-status-nav-color [view-id theme] - (let [theme (or (get-in views/screens [view-id :options :theme]) - theme) - [rnn-status-bar rn-status-bar] - (if (or (= theme :dark) - @state/alert-banner-shown? - (and (= view-id :shell-stack) (not (jump-to.utils/home-stack-open?)))) - [:light "light-content"] - [:dark "dark-content"]) - home-stack? (some #(= view-id %) shell.constants/stacks-ids) + (let [theme (or (get-in views/screens [view-id :options :theme]) + theme) + status-bar-theme (if (or (= theme :dark) + @state/alert-banner-shown? + (and (= view-id :shell-stack) + (not (jump-to.utils/home-stack-open?)))) + :light + :dark) + home-stack? (some #(= view-id %) shell.constants/stacks-ids) ;; Home screen nav bar always dark due to bottom tabs - nav-bar-color (if (or home-stack? - (= view-id :shell-stack) - (= theme :dark)) - colors/neutral-100 - colors/white) - comp-id (if (or home-stack? - (jump-to.utils/shell-navigation? view-id) - (= view-id :shell)) - :shell-stack - view-id)] - [rnn-status-bar rn-status-bar nav-bar-color comp-id])) + nav-bar-color (if (or home-stack? + (= view-id :shell-stack) + (= theme :dark)) + colors/neutral-100 + colors/white) + comp-id (if (or home-stack? + (jump-to.utils/shell-navigation? view-id) + (= view-id :shell)) + :shell-stack + view-id)] + [status-bar-theme nav-bar-color comp-id])) (defn reload-status-nav-color-fx [[view-id theme]] (when (and (= @state/root-id :shell-stack) view-id) - (let [[rnn-status-bar rn-status-bar nav-bar-color comp-id] (get-status-nav-color view-id theme)] - (if platform/ios? - (rn/set-status-bar-style rn-status-bar true) + (let [[status-bar-theme nav-bar-color comp-id] (get-status-nav-color view-id theme)] + (when platform/android? (navigation/merge-options (name comp-id) - {:statusBar {:style rnn-status-bar} + {:statusBar {:style status-bar-theme} :navigationBar {:backgroundColor nav-bar-color}}))))) (rf/reg-fx :reload-status-nav-color-fx reload-status-nav-color-fx) @@ -72,8 +70,9 @@ ;;;; Root (rf/reg-fx :set-root - (fn [root-id] - (let [root (get (roots/roots) root-id)] + (fn [[root-id theme]] + (let [[status-bar-theme] (get-status-nav-color root-id theme) + root (get (roots/roots status-bar-theme) root-id)] (dismiss-all-modals) (rf/dispatch [:profile.settings/switch-theme (get roots/themes root-id) @@ -212,9 +211,9 @@ (rf/reg-fx :show-toasts (fn [[view-id theme]] - (let [[rnn-status-bar nav-bar-color] (get-status-nav-color view-id theme)] + (let [[status-bar-theme nav-bar-color] (get-status-nav-color view-id theme)] (show-overlay "toasts" - (assoc (options/statusbar-and-navbar-options nil rnn-status-bar nav-bar-color) + (assoc (options/statusbar-and-navbar-options nil status-bar-theme nav-bar-color) :overlay {:interceptTouchOutside false}))))) @@ -233,7 +232,10 @@ ;;;; Alert Banner (rf/reg-fx :show-alert-banner (fn [[view-id theme]] - (show-overlay "alert-banner" {:overlay {:interceptTouchOutside false}}) + (show-overlay "alert-banner" + (assoc (options/statusbar-and-navbar-options nil :light nil) + :overlay + {:interceptTouchOutside false})) (reset! state/alert-banner-shown? true) (reload-status-nav-color-fx [view-id theme]))) diff --git a/src/status_im/navigation/events.cljs b/src/status_im/navigation/events.cljs index bfce492b47..cf4ac22a7a 100644 --- a/src/status_im/navigation/events.cljs +++ b/src/status_im/navigation/events.cljs @@ -71,8 +71,8 @@ (rf/defn init-root {:events [:init-root]} - [_ root-id] - {:set-root root-id}) + [{:keys [db]} root-id] + {:set-root [root-id (:theme db)]}) (rf/defn set-stack-root {:events [:set-stack-root]} diff --git a/src/status_im/navigation/roots.cljs b/src/status_im/navigation/roots.cljs index 69a541eccb..65268e8228 100644 --- a/src/status_im/navigation/roots.cljs +++ b/src/status_im/navigation/roots.cljs @@ -15,7 +15,7 @@ :shell-stack nil}) (defn roots-internal - [] + [status-bar-theme] {:screen/onboarding.intro {:root {:stack {:id :screen/onboarding.intro @@ -28,7 +28,8 @@ :children [{:component {:name :shell-stack :id :shell-stack :options (options/root-options - {:nav-bar-color colors/neutral-100})}}]}}} + {:nav-bar-color colors/neutral-100 + :status-bar-theme status-bar-theme})}}]}}} :screen/profile.profiles {:root {:stack {:id :screen/profile.profiles @@ -51,17 +52,18 @@ :options (options/dark-root-options)}}]}}}}) (defn old-roots - [] + [status-bar-theme] {:progress {:root {:stack {:children [{:component {:name :progress :id :progress - :options (options/root-options nil)}}] + :options (options/root-options {:status-bar-theme + status-bar-theme})}}] :options (assoc (options/root-options nil) :topBar {:visible false})}}}}) (defn roots - [] + [status-bar-theme] (merge - (old-roots) - (roots-internal))) + (old-roots status-bar-theme) + (roots-internal status-bar-theme)))