In my project, I want to manage theme colors with colorScheme to support dark mode. Here is what my implementation looks like:
Colors.ts:
import { useColorScheme } from "react-native";
export const useColors = () => {
const colorScheme = useColorScheme();
const colors = {
light: {
tabBar: {
tabBarTintRegular: "#a3a3a3",
tabBarTintActive: "#0e0e0e",
tabBarBackground: "#fff"
}
},
dark: {
tabBar: {
tabBarTintRegular: "#8d8d8d",
tabBarTintActive: "#f2f2f2",
tabBarBackground: "#080808"
}
},
}
if (colorScheme == "light") {
return colors.light
} else {
return colors.dark
}
};
app/(tabs)/_layout.tsx:
...
export default function TabsLayout() {
return (
<Tabs
screenOptions={{
tabBarShowLabel: false,
tabBarActiveTintColor: Colors().tabBar.tabBarTintActive,
tabBarInactiveTintColor: Colors().tabBar.tabBarTintRegular,
tabBarStyle: {
backgroundColor: Colors().tabBar.tabBarBackground,
},
}}
>
...
</Tabs>
);
}
How should I modify this? Is this a good implementation?