Fixed tab bar color not updating with theme change

This commit is contained in:
Arnaud Vergnet 2020-04-09 22:55:53 +02:00
parent cbb0624189
commit 9f391fc335

View file

@ -234,13 +234,11 @@ type Props = {
class TabNavigator extends React.Component<Props>{ class TabNavigator extends React.Component<Props>{
createHomeStackComponent: Object; createHomeStackComponent: Object;
colors: Object;
defaultRoute: string; defaultRoute: string;
constructor(props) { constructor(props) {
super(props); super(props);
this.colors = props.theme.colors;
this.defaultRoute = AsyncStorageManager.getInstance().preferences.defaultStartScreen.current.toLowerCase(); this.defaultRoute = AsyncStorageManager.getInstance().preferences.defaultStartScreen.current.toLowerCase();
if (props.defaultRoute !== null) if (props.defaultRoute !== null)
@ -253,7 +251,7 @@ class TabNavigator extends React.Component<Props>{
return ( return (
<Tab.Navigator <Tab.Navigator
initialRouteName={this.defaultRoute} initialRouteName={this.defaultRoute}
barStyle={{backgroundColor: this.colors.surface}} barStyle={{backgroundColor: this.props.theme.colors.surface}}
screenOptions={({route}) => ({ screenOptions={({route}) => ({
tabBarIcon: ({focused, color, size}) => { tabBarIcon: ({focused, color, size}) => {
let icon = TAB_ICONS[route.name]; let icon = TAB_ICONS[route.name];
@ -262,8 +260,8 @@ class TabNavigator extends React.Component<Props>{
return <MaterialCommunityIcons name={icon} color={color} size={26}/>; return <MaterialCommunityIcons name={icon} color={color} size={26}/>;
}, },
})} })}
activeColor={this.colors.primary} activeColor={this.props.theme.colors.primary}
inactiveColor={this.colors.tabIcon} inactiveColor={this.props.theme.colors.tabIcon}
> >
<Tab.Screen <Tab.Screen
name="proximo" name="proximo"