I am trying to customize the colour of the material bottom tab navigator to LinearGradient.
To achieve this I am using expo- linear-gradient, and I am using props to pass the methods, but I don't know how to access these props in the customTabBar function.
Here is my code containing the tabs
import React from "react";
import { View, Text, StyleSheet, Image, ImageBackground } from "react-native";
import { createMaterialBottomTabNavigator } from "@react-navigation/material-bottom-tabs";
import MainHomeScreen from "./MainHomeScreen";
import CustomTabBar from "./CustomTabBar";
import * as Icons from "@expo/vector-icons";
import { LinearGradient } from "expo-linear-gradient";
const Tab = createMaterialBottomTabNavigator();
const BottomTabScreen = () => {
return (
<>
<Tab.Navigator
screenOptions={{ tabBarLabel: false }}
barStyle={(props) => <CustomTabBar {...props} />}
>
<Tab.Screen
name="MainHomeScreen"
component={MainHomeScreen}
options={{
tabBarIcon: ({ focused }) => (
<>
<Icons.Feather name="home" color="#fff" size={24} />
</>
),
}}
/>
</Tab.Navigator>
</>
);
};
export default BottomTabScreen;
const styles = StyleSheet.create({
shadow: { elevation: 5 },
dot: {
width: 4,
height: 4,
borderRadius: 7,
marginTop: 5,
backgroundColor: "#fff",
},
linearGradient: {
height: 30,
width: 50,
},
});
This is the code of the custom tab bar:
import React from "react";
import { View, Text, StyleSheet } from "react-native";
const CustomTabBar = ({ state, navigationState }) => {
console.log(navigationState);
return <View style={styles.tabs}>
{state.route.map((route, index) => {
})}
</View>;
};
export default CustomTabBar;
const styles = StyleSheet.create({
tabs: {
position: "absolute",
bottom: 15,
left: 20,
right: 20,
elevation: 2,
borderRadius: 20,
backgroundColor: "transparent",
borderTopLeftRadius: 15,
borderTopRightRadius: 15,
overflow: "hidden",
},
});