Change status-bar color on theme change

Move into separate ns to avoid circular dependecy

Fix android system white theme status bar

Signed-off-by: Gheorghe Pinzaru <feross95@gmail.com>
This commit is contained in:
Gheorghe Pinzaru 2020-06-08 18:00:19 +03:00
parent dae891979f
commit 197ce2eb60
No known key found for this signature in database
GPG Key ID: C9A094959935A952
5 changed files with 22 additions and 17 deletions

View File

@ -127,7 +127,7 @@ public class MainActivity extends ReactFragmentActivity
Log.v("RNBootstrap", "Available system memory "+getAvailableMemory(activityManager).availMem + ", maximum usable application memory " + activityManager.getLargeMemoryClass()+"M");
setSecureFlag();
SplashScreen.show(this, R.style.AppTheme);
SplashScreen.show(this, true);
// NOTE: Try to not restore the state https://github.com/software-mansion/react-native-screens/issues/17
super.onCreate(null);

View File

@ -6,8 +6,8 @@
<item name="android:windowBackground">?attr/backgroundColor</item>
<item name="android:textColor">?attr/textColor</item>
<item name="android:forceDarkAllowed">true</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowTranslucentStatus">false</item>
<item name="android:statusBarColor">?attr/backgroundColor</item>
</style>
<style name="LightTheme" parent="AppTheme">

View File

@ -1,14 +1,13 @@
(ns status-im.init.core
(:require [clojure.string :as string]
[quo.theme :as quo-theme]
[re-frame.core :as re-frame]
[status-im.multiaccounts.login.core :as multiaccounts.login]
[status-im.native-module.core :as status]
[status-im.network.net-info :as network]
[status-im.ui.components.colors :as colors]
[status-im.db :refer [app-db]]
[status-im.utils.fx :as fx]
[status-im.utils.theme :as theme]))
[status-im.theme.core :as theme]
[status-im.utils.theme :as utils.theme]))
(fx/defn initialize-app-db
"Initialize db to initial state"
@ -81,7 +80,6 @@
(re-frame/reg-fx
::init-theme
(fn []
(theme/add-mode-change-listener #(re-frame/dispatch [:system-theme-mode-changed %]))
(when (theme/is-dark-mode)
(quo-theme/set-theme :dark)
(colors/set-theme :dark))))
(utils.theme/add-mode-change-listener #(re-frame/dispatch [:system-theme-mode-changed %]))
(when (utils.theme/is-dark-mode)
(theme/change-theme :dark))))

View File

@ -1,15 +1,14 @@
(ns status-im.multiaccounts.core
(:require [quo.theme :as quo-theme]
[re-frame.core :as re-frame]
(:require [re-frame.core :as re-frame]
[status-im.ethereum.stateofus :as stateofus]
[status-im.multiaccounts.update.core :as multiaccounts.update]
[status-im.native-module.core :as native-module]
[status-im.notifications.core :as notifications]
[status-im.ui.components.colors :as colors]
[status-im.utils.fx :as fx]
[status-im.utils.gfycat.core :as gfycat]
[status-im.utils.identicon :as identicon]
[status-im.utils.theme :as theme]))
[status-im.utils.theme :as utils.theme]
[status-im.theme.core :as theme]))
(defn displayed-name
"Use preferred name, name or alias in that order"
@ -97,11 +96,10 @@
(re-frame/reg-fx
::switch-theme
(fn [theme-id]
(let [theme (if (or (= 2 theme-id) (and (= 0 theme-id) (theme/is-dark-mode)))
(let [theme (if (or (= 2 theme-id) (and (= 0 theme-id) (utils.theme/is-dark-mode)))
:dark
:light)]
(quo-theme/set-theme theme)
(colors/set-theme theme))))
(theme/change-theme theme))))
(fx/defn switch-appearance
{:events [:multiaccounts.ui/appearance-switched]}

View File

@ -0,0 +1,9 @@
(ns status-im.theme.core
(:require [status-im.ui.components.status-bar.view :as status-bar]
[status-im.ui.components.colors :as colors]
[quo.theme :as quo-theme]))
(defn change-theme [theme]
(quo-theme/set-theme theme)
(colors/set-theme theme)
(status-bar/set-status-bar nil))