-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add theming and dark mode support (#64)
Introduces a thin theming layer to support dark mode across the app using built-in theming capabilities of react-navigation. It leverages existing light and dark mode defaults from react navigation.
- Loading branch information
Showing
10 changed files
with
97 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react'; | ||
import { Text as RNText, TextProps as RNTextProps } from 'react-native'; | ||
import useTheme from 'src/theme/useTheme'; | ||
|
||
type TextProps = RNTextProps; | ||
|
||
export default function Text({ style, ...props }: TextProps) { | ||
const { colors } = useTheme(); | ||
|
||
return <RNText style={[{ color: colors.text }, style]} {...props} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 2 additions & 7 deletions
9
templates/boilerplate/src/screens/AboutScreen/AboutScreen.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
templates/boilerplate/src/screens/InformationScreen/InformationScreen.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { DefaultTheme, DarkTheme } from '@react-navigation/native'; | ||
import type { Theme } from '@react-navigation/native'; | ||
|
||
export type CustomThemeColors = Theme['colors'] & { | ||
button: string; | ||
}; | ||
|
||
export const lightThemeColors: CustomThemeColors = { | ||
...DefaultTheme.colors, | ||
button: '#08f', | ||
}; | ||
|
||
export const darkThemeColors: CustomThemeColors = { | ||
...DarkTheme.colors, | ||
button: '#08f', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { | ||
Theme, | ||
useTheme as useNavigationTheme, | ||
} from '@react-navigation/native'; | ||
import type { CustomThemeColors } from './colors'; | ||
|
||
export type CustomTheme = Theme & { | ||
colors: CustomThemeColors; | ||
}; | ||
|
||
const useTheme = () => { | ||
const theme = useNavigationTheme(); | ||
return theme as CustomTheme; | ||
}; | ||
|
||
export default useTheme; |