Skip to main content

Example

Below example shows a full example how to extend ThemeProvider and implement setColorScheme method to support to dark mode and using multiple themes.

To support multipe themes you must extend ThemeProvider and implement onChangeTheme method or you can create you own ThemeContext.

/src/theme/colors.ts
import { ColorValue } from 'react-native';
import { light, BaseTheme } from '@flexnative/theme-context';

export interface MyColorsColors {
color1: ColorValue,
color2: ColorValue
};

export const lightRedTheme: BaseTheme<MyColorsColors> = {
...light,
primary: '#FF0000',
color1: '#C51162',
color2: '#7B1FA2',
}

export const lightBlueTheme: BaseTheme<MyColorsColors> = {
...light,
primary: '#00008B',
color1: '#C51162',
color2: '#7B1FA2',
}

export const darkRedTheme: BaseTheme<MyColorsColors> = {
...dark,
primary: '#FF0000',
color1: '#C51162',
color2: '#7B1FA2',
}

export const darkBlueTheme: BaseTheme<MyColorsColors> = {
...dark,
primary: '#00008B',
color1: '#C51162',
color2: '#7B1FA2',
}