Skip to content

Commit ce63cb0

Browse files
Copilotanupriya13
andcommitted
Use existing theme system without adding new theme objects to Navigation
Co-authored-by: anupriya13 <54227869+anupriya13@users.noreply.github.com>
1 parent 9b511a3 commit ce63cb0

4 files changed

Lines changed: 18 additions & 19 deletions

File tree

NewArch/src/Navigation.tsx

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
useAnimatedValue,
1010
} from 'react-native';
1111
import type { PropsWithChildren } from 'react';
12+
import {Theme} from '@react-navigation/native';
1213

1314
type NavigationAction = {
1415
type: string,
@@ -42,23 +43,11 @@ type RouteType = {
4243
params: any,
4344
}
4445

45-
type Theme = {
46-
dark: boolean;
47-
colors: {
48-
primary: string;
49-
background: string;
50-
card: string;
51-
text: string;
52-
border: string;
53-
notification: string;
54-
};
55-
};
56-
5746
type NavigationContainerProps = PropsWithChildren<{
5847
theme?: Theme;
5948
}>;
6049

61-
// Store the current theme in a context for useTheme hook
50+
// Store the current theme for useTheme hook
6251
let currentTheme: Theme | null = null;
6352

6453
const NavigationContainer = ({children, theme}: NavigationContainerProps) => {
@@ -95,7 +84,6 @@ const NavigationContainer = ({children, theme}: NavigationContainerProps) => {
9584
routes: routes,
9685
parameters: parameters,
9786
};
98-
9987
return (
10088
<NavigationContext.Provider value={navigationContext}>
10189
{children}
@@ -365,6 +353,18 @@ const useTheme = () => {
365353
};
366354
};
367355

356+
const Theme = {
357+
colors: {
358+
primary: '#0066cc',
359+
background: '#FFFFFF',
360+
card: '#FFFFFF',
361+
text: '#505050',
362+
border: '#E6E6E6',
363+
notification: 'rgb(255, 59, 48)',
364+
},
365+
dark: false,
366+
};
367+
368368
const useNavigation = () => {
369369
const navigationContext = React.useContext(NavigationContext);
370370
return navigationContext;
@@ -376,5 +376,4 @@ const DrawerActions = {
376376
toggleDrawer: () => {console.log('toggleDrawer'); return { type: 'TOGGLE_DRAWER' };},
377377
};
378378

379-
export { NavigationContainer, StackNavigator, StackScreen, createNativeStackNavigator, createDrawerNavigator, getDrawerStatusFromState, useIsFocused, useTheme, useNavigation, DrawerActions };
380-
export type { Theme };
379+
export { NavigationContainer, StackNavigator, StackScreen, createNativeStackNavigator, createDrawerNavigator, getDrawerStatusFromState, useIsFocused, useTheme, Theme, useNavigation, DrawerActions };

NewArch/src/themes/DarkTheme.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Theme} from '../Navigation';
1+
import {Theme} from '@react-navigation/native';
22

33
const DarkTheme: Theme = {
44
dark: true,

NewArch/src/themes/HighContrastTheme.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Theme} from '../Navigation';
1+
import {Theme} from '@react-navigation/native';
22
import {AppTheme} from 'react-native-windows';
33

44
const HighContrastTheme: Theme = {

NewArch/src/themes/LightTheme.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Theme} from '../Navigation';
1+
import {Theme} from '@react-navigation/native';
22

33
const LightTheme: Theme = {
44
dark: false,

0 commit comments

Comments
 (0)