Update navigation theme handling

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2023-07-11 12:50:12 +03:00
parent bf11f7a3e1
commit 7ed62507c7
2 changed files with 22 additions and 12 deletions

View File

@@ -10,6 +10,7 @@ import { BottomNavigation, Portal, useTheme } from 'react-native-paper';
import { Home, Search, Tags, Settings, AddItem } from './screens'; import { Home, Search, Tags, Settings, AddItem } from './screens';
import { horizontalScale } from './styles'; import { horizontalScale } from './styles';
import { FloatingActionButton } from './components'; import { FloatingActionButton } from './components';
import { darkNavigationTheme, lightNavigationTheme } from './theme';
function TabNavigator() { function TabNavigator() {
const TabNavigatorBase = createBottomTabNavigator(); const TabNavigatorBase = createBottomTabNavigator();
@@ -109,17 +110,7 @@ function NavigationContainer() {
return ( return (
<NavigationContainerBase <NavigationContainerBase
theme={{ theme={theme.dark ? darkNavigationTheme : lightNavigationTheme}>
dark: theme.dark,
colors: {
primary: theme.colors.primary,
background: theme.colors.background,
card: theme.colors.surface,
text: theme.colors.onSurface,
border: theme.colors.outline,
notification: theme.colors.error,
},
}}>
<StackNavigatorBase.Navigator screenOptions={{ headerShown: false }}> <StackNavigatorBase.Navigator screenOptions={{ headerShown: false }}>
<StackNavigatorBase.Screen name="Main" component={TabNavigator} /> <StackNavigatorBase.Screen name="Main" component={TabNavigator} />
<StackNavigatorBase.Screen <StackNavigatorBase.Screen

View File

@@ -1,4 +1,12 @@
import { DefaultTheme as DefaultNavigationTheme } from '@react-navigation/native';
import {
MD3LightTheme,
MD3DarkTheme,
adaptNavigationTheme,
} from 'react-native-paper';
const lightTheme = { const lightTheme = {
...MD3LightTheme,
colors: { colors: {
primary: 'rgb(0, 95, 175)', primary: 'rgb(0, 95, 175)',
onPrimary: 'rgb(255, 255, 255)', onPrimary: 'rgb(255, 255, 255)',
@@ -44,6 +52,7 @@ const lightTheme = {
}; };
const darkTheme = { const darkTheme = {
...MD3DarkTheme,
colors: { colors: {
primary: 'rgb(165, 200, 255)', primary: 'rgb(165, 200, 255)',
onPrimary: 'rgb(0, 49, 95)', onPrimary: 'rgb(0, 49, 95)',
@@ -88,4 +97,14 @@ const darkTheme = {
}, },
}; };
export { lightTheme, darkTheme }; const { LightTheme: lightNavigationTheme } = adaptNavigationTheme({
reactNavigationLight: DefaultNavigationTheme,
materialLight: lightTheme,
});
const { DarkTheme: darkNavigationTheme } = adaptNavigationTheme({
reactNavigationDark: DefaultNavigationTheme,
materialDark: darkTheme,
});
export { lightTheme, darkTheme, lightNavigationTheme, darkNavigationTheme };