Skip to content

Commit a27facb

Browse files
committed
fix status and nav bar color (#19089)
1 parent fd13357 commit a27facb

File tree

11 files changed

+87
-74
lines changed

11 files changed

+87
-74
lines changed

src/status_im/common/alert_banner/events.cljs

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@
77
db (assoc-in db [:alert-banners (:type banner)] banner)]
88
(cond-> {:db db}
99
(zero? current-banners-count)
10-
(assoc :show-alert-banner nil))))
10+
(assoc :show-alert-banner (:view-id db)))))
1111

1212
(defn remove-alert-banner
1313
[{:keys [db]} [banner-type]]
1414
(let [db (update-in db [:alert-banners] dissoc banner-type)
1515
new-count (count (get db :alert-banners))]
1616
(cond-> {:db db}
1717
(zero? new-count)
18-
(assoc :hide-alert-banner nil))))
18+
(assoc :hide-alert-banner (:view-id db)))))
1919

2020
(defn remove-all-alert-banners
2121
[{:keys [db]}]
2222
{:db (dissoc db :alert-banners)
23-
:hide-alert-banner nil})
23+
:hide-alert-banner (:view-id db)})
2424

2525
(re-frame/reg-event-fx :alert-banners/add add-alert-banner)
2626
(re-frame/reg-event-fx :alert-banners/remove remove-alert-banner)

src/status_im/common/toasts/events.cljs

+4-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
(update :toasts dissoc :hide-toasts-timer-set))}
2020

2121
(and (not update?) (= (count ordered) 1))
22-
(assoc :show-toasts [])
22+
(assoc :show-toasts (:view-id db))
2323

2424
(not (:id opts))
2525
(update-in [:db :toasts :next-toast-number] inc))))
@@ -28,8 +28,9 @@
2828
{:events [:toasts/hide-with-check]}
2929
[{:keys [db]}]
3030
(when (get-in db [:toasts :hide-toasts-timer-set])
31-
{:db (update db :toasts dissoc :hide-toasts-timer-set)
32-
:hide-toasts nil}))
31+
{:db (update db :toasts dissoc :hide-toasts-timer-set)
32+
:hide-toasts nil
33+
:reload-status-nav-color-fx (:view-id db)}))
3334

3435
(rf/defn close
3536
{:events [:toasts/close]}

src/status_im/contexts/profile/login/events.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878

7979
:else
8080
[[:profile.settings/switch-theme-fx
81-
[(or (get-in db [:profile/profile :appearance])
81+
[(or (:appearance settings)
8282
constants/theme-type-dark)
8383
:shell-stack
8484
false]]
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
(ns status-im.contexts.profile.settings.effects
22
(:require [native-module.core :as native-module]
3-
[quo.foundations.colors :as colors]
43
[re-frame.core :as re-frame]
54
[react-native.platform :as platform]
65
[status-im.common.theme.core :as theme]
76
[status-im.constants :as constants]
8-
[status-im.contexts.shell.jump-to.utils :as shell.utils]
9-
[status-im.setup.hot-reload :as hot-reload]))
7+
[status-im.setup.hot-reload :as hot-reload]
8+
[utils.re-frame :as rf]))
109

1110
(re-frame/reg-fx
1211
:profile.settings/blank-preview-flag-changed
@@ -22,19 +21,14 @@
2221
(re-frame/reg-fx
2322
:profile.settings/switch-theme-fx
2423
(fn [[theme-type view-id reload-ui?]]
25-
(let [[theme status-bar-theme nav-bar-color]
26-
;; Status bar theme represents status bar icons colors, so opposite to app theme
27-
(if (or (= theme-type constants/theme-type-dark)
28-
(and (= theme-type constants/theme-type-system)
29-
(theme/device-theme-dark?)))
30-
[:dark :light colors/neutral-100]
31-
[:light :dark colors/white])]
24+
(let [theme (if (or (= theme-type constants/theme-type-dark)
25+
(and (= theme-type constants/theme-type-system)
26+
(theme/device-theme-dark?)))
27+
:dark
28+
:light)]
3229
(theme/set-theme theme)
33-
(re-frame/dispatch [:change-shell-status-bar-style
34-
(if (shell.utils/home-stack-open?) status-bar-theme :light)])
30+
(rf/dispatch [:reload-status-nav-color view-id])
3531
(when reload-ui?
3632
(re-frame/dispatch [:dismiss-all-overlays])
3733
(when js/goog.DEBUG
38-
(hot-reload/reload))
39-
(when-not (= view-id :shell-stack)
40-
(re-frame/dispatch [:change-shell-nav-bar-color nav-bar-color]))))))
34+
(hot-reload/reload))))))

src/status_im/contexts/shell/jump_to/animation.cljs

+1-4
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
(reanimated/set-shared-value (:home-stack-state @state/shared-values-atom) home-stack-state-value)
1515
(utils/change-selected-stack-id stack-id true home-stack-state-value)
1616
(js/setTimeout
17-
(fn []
18-
(utils/load-stack stack-id)
19-
(utils/change-shell-status-bar-style))
17+
#(utils/load-stack stack-id)
2018
(if animate? shell.constants/shell-animation-time 0))))
2119

2220
(defn change-tab
@@ -41,7 +39,6 @@
4139
(reanimated/set-shared-value (:animate-home-stack-left @state/shared-values-atom) true)
4240
(reanimated/set-shared-value (:home-stack-state @state/shared-values-atom) home-stack-state-value)
4341
(utils/change-selected-stack-id stack-id true home-stack-state-value)
44-
(utils/change-shell-status-bar-style)
4542
(when animate? (utils/update-view-id (or stack-id :shell)))))
4643

4744
;;;; Floating Screen

src/status_im/contexts/shell/jump_to/events.cljs

-10
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,6 @@
108108
:dispatch [:set-view-id :shell]
109109
:effects.shell/navigate-to-jump-to nil}))
110110

111-
(rf/defn change-shell-status-bar-style
112-
{:events [:change-shell-status-bar-style]}
113-
[_ style]
114-
{:merge-options {:id "shell-stack" :options {:statusBar {:style style}}}})
115-
116-
(rf/defn change-shell-nav-bar-color
117-
{:events [:change-shell-nav-bar-color]}
118-
[_ color]
119-
{:merge-options {:id "shell-stack" :options {:navigationBar {:backgroundColor color}}}})
120-
121111
(rf/defn shell-navigate-to
122112
{:events [:shell/navigate-to]}
123113
[{:keys [db now]} go-to-view-id screen-params animation hidden-screen?]

src/status_im/contexts/shell/jump_to/utils.cljs

-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
(ns status-im.contexts.shell.jump-to.utils
22
(:require
3-
[quo.theme :as quo.theme]
43
[react-native.async-storage :as async-storage]
54
[react-native.core :as rn]
65
[react-native.platform :as platform]
@@ -136,12 +135,3 @@
136135
(defn update-view-id
137136
[view-id]
138137
(rf/dispatch [:set-view-id view-id]))
139-
140-
;;; Misc
141-
(defn change-shell-status-bar-style
142-
[]
143-
(rf/dispatch [:change-shell-status-bar-style
144-
(if (or (= :dark (quo.theme/get-theme))
145-
(not (home-stack-open?)))
146-
:light
147-
:dark)]))

src/status_im/navigation/effects.cljs

+56-17
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,61 @@
11
(ns status-im.navigation.effects
22
(:require
3+
[quo.foundations.colors :as colors]
34
[quo.theme]
45
[react-native.core :as rn]
56
[react-native.navigation :as navigation]
7+
[react-native.platform :as platform]
8+
[status-im.contexts.shell.jump-to.constants :as shell.constants]
9+
[status-im.contexts.shell.jump-to.utils :as jump-to.utils]
610
[status-im.navigation.options :as options]
711
[status-im.navigation.roots :as roots]
812
[status-im.navigation.state :as state]
913
[status-im.navigation.view :as views]
1014
[taoensso.timbre :as log]
1115
[utils.re-frame :as rf]))
1216

13-
(defn- set-status-bar-color
14-
[theme]
15-
(rn/set-status-bar-style
16-
(if (= theme :dark)
17-
"light-content"
18-
"dark-content")
19-
true))
17+
(defn get-status-nav-color
18+
[view-id]
19+
(let [theme (or (get-in views/screens [view-id :options :theme])
20+
(quo.theme/get-theme))
21+
[rnn-status-bar rn-status-bar]
22+
(if (or (= theme :dark)
23+
@state/alert-banner-shown?
24+
(and (= view-id :shell-stack) (not (jump-to.utils/home-stack-open?))))
25+
[:light "light-content"]
26+
[:dark "dark-content"])
27+
home-stack? (some #(= view-id %) shell.constants/stacks-ids)
28+
;; Home screen nav bar always dark due to bottom tabs
29+
nav-bar-color (if (or home-stack?
30+
(= view-id :shell-stack)
31+
(= theme :dark))
32+
colors/neutral-100
33+
colors/white)
34+
comp-id (if (or home-stack?
35+
(jump-to.utils/shell-navigation? view-id)
36+
(= view-id :shell))
37+
:shell-stack
38+
view-id)]
39+
[rnn-status-bar rn-status-bar nav-bar-color comp-id]))
40+
41+
(defn reload-status-nav-color-fx
42+
[view-id]
43+
(when (and (= @state/root-id :shell-stack) view-id)
44+
(let [[rnn-status-bar rn-status-bar nav-bar-color comp-id] (get-status-nav-color view-id)]
45+
(if platform/ios?
46+
(rn/set-status-bar-style rn-status-bar true)
47+
(navigation/merge-options
48+
(name comp-id)
49+
{:statusBar {:style rnn-status-bar}
50+
:navigationBar {:backgroundColor nav-bar-color}})))))
51+
52+
(rf/reg-fx :reload-status-nav-color-fx reload-status-nav-color-fx)
2053

2154
(rf/reg-fx :set-view-id-fx
2255
(fn [view-id]
56+
(reload-status-nav-color-fx view-id)
2357
(rf/dispatch [:screens/on-will-focus view-id])
24-
(when-let [{:keys [on-focus options]} (get views/screens view-id)]
25-
(set-status-bar-color (or (:theme options)
26-
(quo.theme/get-theme)))
58+
(when-let [{:keys [on-focus]} (get views/screens view-id)]
2759
(when on-focus
2860
(rf/dispatch on-focus)))))
2961

@@ -167,11 +199,12 @@
167199
opts)}})))
168200

169201
(rf/reg-fx :show-toasts
170-
(fn []
171-
(show-overlay "toasts"
172-
{:overlay {:interceptTouchOutside false}
173-
:layout {:componentBackgroundColor :transparent
174-
:orientation ["portrait"]}})))
202+
(fn [view-id]
203+
(let [[rnn-status-bar nav-bar-color] (get-status-nav-color view-id)]
204+
(show-overlay "toasts"
205+
(assoc (options/statusbar-and-navbar-options nil rnn-status-bar nav-bar-color)
206+
:overlay
207+
{:interceptTouchOutside false})))))
175208

176209
(rf/reg-fx :hide-toasts
177210
(fn [] (navigation/dissmiss-overlay "toasts")))
@@ -186,10 +219,16 @@
186219

187220
;;;; Alert Banner
188221
(rf/reg-fx :show-alert-banner
189-
(fn [] (show-overlay "alert-banner" {:overlay {:interceptTouchOutside false}})))
222+
(fn [view-id]
223+
(show-overlay "alert-banner" {:overlay {:interceptTouchOutside false}})
224+
(reset! state/alert-banner-shown? true)
225+
(reload-status-nav-color-fx view-id)))
190226

191227
(rf/reg-fx :hide-alert-banner
192-
(fn [] (navigation/dissmiss-overlay "alert-banner")))
228+
(fn [view-id]
229+
(navigation/dissmiss-overlay "alert-banner")
230+
(reset! state/alert-banner-shown? false)
231+
(reload-status-nav-color-fx view-id)))
193232

194233
;;;; Merge options
195234

src/status_im/navigation/events.cljs

+11-6
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,9 @@
101101
(let [{:keys [sheets]} (:bottom-sheet db)
102102
rest-sheets (butlast sheets)]
103103
(merge
104-
{:db (assoc db :bottom-sheet {:sheets rest-sheets :hide? false})
105-
:hide-bottom-sheet nil}
104+
{:db (assoc db :bottom-sheet {:sheets rest-sheets :hide? false})
105+
:hide-bottom-sheet nil
106+
:reload-status-nav-color-fx (:view-id db)}
106107
(when (seq rest-sheets)
107108
{:dispatch [:show-next-bottom-sheet]}))))
108109

@@ -134,7 +135,11 @@
134135
(rf/defn set-view-id
135136
{:events [:set-view-id]}
136137
[{:keys [db]} view-id]
137-
(when-not (= view-id (:view-id db))
138-
(let [view-id (if (= view-id :shell-stack) (shell.utils/calculate-view-id) view-id)]
139-
{:db (assoc db :view-id view-id)
140-
:set-view-id-fx view-id})))
138+
(let [view-id (if (= view-id :shell-stack) (shell.utils/calculate-view-id) view-id)]
139+
{:db (assoc db :view-id view-id)
140+
:set-view-id-fx view-id}))
141+
142+
(rf/defn reload-status-nav-color
143+
{:events [:reload-status-nav-color]}
144+
[{:keys [db]} view-id]
145+
{:reload-status-nav-color-fx (or view-id (:view-id db))})

src/status_im/navigation/screens.cljs

+1-5
Original file line numberDiff line numberDiff line change
@@ -450,11 +450,7 @@
450450
:component settings-password/view}]
451451

452452
[{:name :shell
453-
:options {:theme :dark}}
454-
{:name :communities-stack}
455-
{:name :chats-stack}
456-
{:name :wallet-stack}
457-
{:name :browser-stack}]
453+
:options {:theme :dark}}]
458454

459455
(when js/goog.DEBUG
460456
[{:name :dev-component-preview

src/status_im/navigation/state.cljs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
(defonce root-id (atom nil))
55
(defonce modals (atom []))
66
(defonce dissmissing (atom false))
7+
(defonce alert-banner-shown? (atom false))
78

89
(defonce ^:private navigation-state (atom []))
910

0 commit comments

Comments
 (0)