From 456344029c357ae3b0a1edd58b3e9c91340e18fe Mon Sep 17 00:00:00 2001
From: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com>
Date: Tue, 18 Jul 2023 18:01:31 -0300
Subject: [PATCH] fix: Android status bar theme on the first open isn't working
properly (#5132)
* fix: status bar color and text color update properly
* change how to set the status bar
* add colors
---
app/containers/StatusBar.tsx | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/app/containers/StatusBar.tsx b/app/containers/StatusBar.tsx
index 03349c92a..2d0807033 100644
--- a/app/containers/StatusBar.tsx
+++ b/app/containers/StatusBar.tsx
@@ -1,7 +1,6 @@
-import React from 'react';
+import React, { useEffect } from 'react';
import { StatusBar as StatusBarRN } from 'react-native';
-import { themes } from '../lib/constants';
import { useTheme } from '../theme';
const supportedStyles = {
@@ -15,14 +14,20 @@ interface IStatusBar {
}
const StatusBar = React.memo(({ barStyle, backgroundColor }: IStatusBar) => {
- const { theme } = useTheme();
- if (!barStyle) {
- barStyle = 'light-content';
- if (theme === 'light') {
- barStyle = 'dark-content';
+ const { theme, colors } = useTheme();
+
+ useEffect(() => {
+ if (!barStyle) {
+ barStyle = 'light-content';
+ if (theme === 'light') {
+ barStyle = 'dark-content';
+ }
}
- }
- return ;
+ StatusBarRN.setBackgroundColor(backgroundColor ?? colors.headerBackground);
+ StatusBarRN.setBarStyle(barStyle, true);
+ }, [theme, barStyle, backgroundColor]);
+
+ return ;
});
export default StatusBar;