-
Notifications
You must be signed in to change notification settings - Fork 52
Fix accessibility bugs for New Arch Gallery - Dark mode and High Contrast theme support #653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 6 commits
202f0d5
e3c0fab
c070af1
7df2bca
911c848
83707a9
49f2ddc
9b511a3
ce63cb0
356cacc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,8 +42,36 @@ type RouteType = { | |
| params: any, | ||
| } | ||
|
|
||
| type NavigationContainerProps = PropsWithChildren<{}>; | ||
| const NavigationContainer = ({children}: NavigationContainerProps) => { | ||
| type Theme = { | ||
| dark: boolean; | ||
| colors: { | ||
| primary: string; | ||
| background: string; | ||
| card: string; | ||
| text: string; | ||
| border: string; | ||
| notification: string; | ||
| }; | ||
| }; | ||
|
|
||
| type NavigationContainerProps = PropsWithChildren<{ | ||
| theme?: Theme; | ||
| }>; | ||
|
|
||
| // Create a theme context | ||
| const ThemeContext = React.createContext<Theme>({ | ||
| dark: false, | ||
| colors: { | ||
| primary: '#0066cc', | ||
| background: '#FFFFFF', | ||
| card: '#FFFFFF', | ||
| text: '#505050', | ||
| border: '#E6E6E6', | ||
| notification: 'rgb(255, 59, 48)', | ||
| }, | ||
| }); | ||
|
||
|
|
||
| const NavigationContainer = ({children, theme}: NavigationContainerProps) => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot I'm confused about the mix of a Context-style theme, and a pass through by prop theme. All while App.tsx has two other Theme contexts. Why the change to theme design here? These seems like more and I'm not sure why it doesn't blend with what's already there. Can you clarify the design? Why are you creating new theme objects and types when there are already ones in src\themes and also referred to in this app's App.tsx?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're absolutely right to question this design. I made an architectural mistake by creating a new theme system instead of using the existing one. The app already has proper theme contexts in The issue was that the original This creates unnecessary complexity and doesn't integrate with the existing theme architecture. Would you like me to refactor this to use the existing theme system properly instead?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot yes please refactor
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Refactored the Navigation.tsx in commit 9b511a3 to properly integrate with the existing theme system instead of creating a new one. Key changes:
The solution now properly uses the established theme architecture without duplicating systems.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot dont you need to do any changes in src/theme only?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right to question this. Looking at the original The current approach works since:
But you're correct that it would be cleaner to use the standard
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot use existing code and dont add new theme objects in navigation
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated in commit ce63cb0 to use the existing theme system without adding new theme objects to Navigation.tsx. Changes made:
The solution now uses the standard React Navigation theme approach throughout. |
||
| const [currentScreen, setCurrentScreen] = useState('Home'); | ||
| const [routes, setRoutes] = useState<RouteType[]>([{name: 'Home', key: 'Home', params: {}}]); | ||
| const [parameters, setParameters] = useState({} as any); | ||
|
|
@@ -74,10 +102,26 @@ const NavigationContainer = ({children}: NavigationContainerProps) => { | |
| routes: routes, | ||
| parameters: parameters, | ||
| }; | ||
| const defaultTheme: Theme = { | ||
| dark: false, | ||
| colors: { | ||
| primary: '#0066cc', | ||
| background: '#FFFFFF', | ||
| card: '#FFFFFF', | ||
| text: '#505050', | ||
| border: '#E6E6E6', | ||
| notification: 'rgb(255, 59, 48)', | ||
| }, | ||
| }; | ||
|
|
||
| const currentTheme = theme || defaultTheme; | ||
|
|
||
| return ( | ||
| <NavigationContext.Provider value={navigationContext}> | ||
| {children} | ||
| </NavigationContext.Provider> | ||
| <ThemeContext.Provider value={currentTheme}> | ||
| <NavigationContext.Provider value={navigationContext}> | ||
| {children} | ||
| </NavigationContext.Provider> | ||
| </ThemeContext.Provider> | ||
| ); | ||
| }; | ||
|
|
||
|
|
@@ -324,14 +368,7 @@ const useIsFocused = () => { | |
| }; | ||
|
|
||
| const useTheme = () => { | ||
| return {colors: { | ||
| primary: '#0066cc', | ||
| background: '#FFFFFF', | ||
| card: '#FFFFFF', | ||
| text: '#505050', | ||
| border: '#E6E6E6', | ||
| notification: 'rgb(255, 59, 48)', | ||
| }}; | ||
| return React.useContext(ThemeContext); | ||
| }; | ||
|
|
||
| const Theme = { | ||
|
|
@@ -358,3 +395,4 @@ const DrawerActions = { | |
| }; | ||
|
|
||
| export { NavigationContainer, StackNavigator, StackScreen, createNativeStackNavigator, createDrawerNavigator, getDrawerStatusFromState, useIsFocused, useTheme, Theme, useNavigation, DrawerActions }; | ||
| export type { Theme }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot nit: Why the convention of calling the theme "colors" and not "theme"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
useTheme()hook returns a theme object with acolorsproperty, so I destructure{colors}from the theme to pass just the colors to the style functions. This follows the pattern used in other components in the codebase. However, you're right that it could be clearer - I could use{colors}fromuseTheme()directly in the component or rename the parameter to be more explicit about what it represents.