From 7db35a3cc81ae3685c5c3fe93d398484b49483d3 Mon Sep 17 00:00:00 2001 From: Ibrahem Khalil Date: Wed, 28 Feb 2024 18:53:13 +0200 Subject: [PATCH] Fix statusbar color on dark screens (#18785) --- ios/StatusIm/Info.plist | 2 +- src/mocks/js_dependencies.cljs | 2 +- src/react_native/core.cljs | 2 ++ src/status_im/navigation/effects.cljs | 19 ++++++++++++++++--- src/status_im/navigation/options.cljs | 3 --- src/status_im/navigation/screens.cljs | 11 ++++++++++- 6 files changed, 30 insertions(+), 9 deletions(-) diff --git a/ios/StatusIm/Info.plist b/ios/StatusIm/Info.plist index ad0ac04376..6e50035a99 100644 --- a/ios/StatusIm/Info.plist +++ b/ios/StatusIm/Info.plist @@ -133,7 +133,7 @@ UIInterfaceOrientationLandscapeRight UIViewControllerBasedStatusBarAppearance - + com.apple.developer.nfc.readersession.iso7816.select-identifiers A00000080400010101 diff --git a/src/mocks/js_dependencies.cljs b/src/mocks/js_dependencies.cljs index ec5d44576e..50c8e54742 100644 --- a/src/mocks/js_dependencies.cljs +++ b/src/mocks/js_dependencies.cljs @@ -53,7 +53,7 @@ :FlatList {} :SectionList {} :Text {} - :StatusBar {} + :StatusBar {:setBarStyle identity} :ScrollView {} :SafeAreaView {} :KeyboardAvoidingView {} diff --git a/src/react_native/core.cljs b/src/react_native/core.cljs index fb4c3de837..ebce9d1728 100644 --- a/src/react_native/core.cljs +++ b/src/react_native/core.cljs @@ -210,3 +210,5 @@ (def linking (.-Linking react-native)) (defn open-url [link] (.openURL ^js linking link)) + +(def set-status-bar-style react-native/StatusBar.setBarStyle) diff --git a/src/status_im/navigation/effects.cljs b/src/status_im/navigation/effects.cljs index b6dc872e92..d256dffcd0 100644 --- a/src/status_im/navigation/effects.cljs +++ b/src/status_im/navigation/effects.cljs @@ -1,5 +1,7 @@ (ns status-im.navigation.effects (:require + [quo.theme] + [react-native.core :as rn] [react-native.navigation :as navigation] [status-im.navigation.options :as options] [status-im.navigation.roots :as roots] @@ -8,10 +10,20 @@ [taoensso.timbre :as log] [utils.re-frame :as rf])) +(defn- set-status-bar-color + [theme] + (rn/set-status-bar-style + (if (= theme :dark) + "light-content" + "dark-content") + true)) + (rf/reg-fx :set-view-id-fx (fn [view-id] (rf/dispatch [:screens/on-will-focus view-id]) - (when-let [{:keys [on-focus]} (get views/screens view-id)] + (when-let [{:keys [on-focus options]} (get views/screens view-id)] + (set-status-bar-color (or (:theme options) + (quo.theme/get-theme))) (when on-focus (rf/dispatch on-focus))))) @@ -117,11 +129,12 @@ (defn open-modal [component] - (let [{:keys [options]} (get views/screens component) - sheet? (:sheet? options)] + (let [{:keys [options name]} (get views/screens component) + sheet? (:sheet? options)] (if @state/dissmissing (reset! state/dissmissing component) (do + (set-view-id name) ; TODO https://github.com/status-im/status-mobile/issues/18811 (reset! state/curr-modal true) (swap! state/modals conj component) (navigation/show-modal diff --git a/src/status_im/navigation/options.cljs b/src/status_im/navigation/options.cljs index db545150d2..006766f722 100644 --- a/src/status_im/navigation/options.cljs +++ b/src/status_im/navigation/options.cljs @@ -137,9 +137,6 @@ :decelerate :factor 1.5}}]}}}) -(def camera-screen - {:navigationBar {:backgroundColor colors/black}}) - (defn merge-top-bar [root-options options] (let [options (:topBar options)] diff --git a/src/status_im/navigation/screens.cljs b/src/status_im/navigation/screens.cljs index 2c0df02ca4..a58fe69b04 100644 --- a/src/status_im/navigation/screens.cljs +++ b/src/status_im/navigation/screens.cljs @@ -1,6 +1,7 @@ (ns status-im.navigation.screens (:require [legacy.status-im.ui.screens.screens :as old-screens] + [quo.foundations.colors :as colors] [status-im.common.emoji-picker.view :as emoji-picker] [status-im.common.lightbox.view :as lightbox] [status-im.config :as config] @@ -142,7 +143,8 @@ :component photo-selector/photo-selector} {:name :camera-screen - :options options/camera-screen + :options {:navigationBar {:backgroundColor colors/black} + :theme :dark} :component camera-screen/camera-screen} {:name :new-contact @@ -433,6 +435,13 @@ :options options/transparent-modal-screen-options :component settings-password/view}] + [{:name :shell + :options {:theme :dark}} + {:name :communities-stack} + {:name :chats-stack} + {:name :wallet-stack} + {:name :browser-stack}] + (when js/goog.DEBUG [{:name :dev-component-preview :options {:sheet? true}