feat add colors context see next push if its working
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
parent
07a865b9c8
commit
da8075e303
@ -0,0 +1,42 @@
|
|||||||
|
import React, {createContext, useState, useEffect} from 'react';
|
||||||
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||||
|
|
||||||
|
import { DarkTheme, LightTheme, Theme } from './colors';
|
||||||
|
|
||||||
|
interface ColorContextType {
|
||||||
|
colors: Theme,
|
||||||
|
toggleColor: (Theme) => void
|
||||||
|
};
|
||||||
|
|
||||||
|
const ColorContext = createContext<ColorContextType | null>(null);
|
||||||
|
|
||||||
|
export const ColorProvider = ({ children }) => {
|
||||||
|
const [colors, setColors] = useState(LightTheme);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const getColors = async () => {
|
||||||
|
try {
|
||||||
|
const savedColors = await AsyncStorage.getItem('colors');
|
||||||
|
if (savedColors) {
|
||||||
|
setColors(JSON.parse(savedColors));
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log('Error loading colors:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
getColors();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const toggleColor = (newColors: Theme) => {
|
||||||
|
setColors(newColors);
|
||||||
|
AsyncStorage.setItem('colors', JSON.stringify(newColors))
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ColorContext.Provider value={{colors, toggleColor}}>
|
||||||
|
{children}
|
||||||
|
</ColorContext.Provider>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ColorContext;
|
@ -0,0 +1,57 @@
|
|||||||
|
const Ecru = '#ACA279'
|
||||||
|
const Alabaster = '#F2F0E4'
|
||||||
|
const Jet = '#3F3C42'
|
||||||
|
const Moonstone = '#59BDCD'
|
||||||
|
const Cerulean = '#2680AA'
|
||||||
|
const Celeste = '#ADF3EA'
|
||||||
|
const Tan = '#E0C293'
|
||||||
|
const Pearl = '#E3DEC9'
|
||||||
|
const EerieBlack = '#222222'
|
||||||
|
const CarolinaBlue = '#8DB4D9'
|
||||||
|
const SteelBlue = '#5882A8'
|
||||||
|
|
||||||
|
export interface Theme {
|
||||||
|
primary: string,
|
||||||
|
primaryComplement: string,
|
||||||
|
cardBackground: string,
|
||||||
|
cardTitle: string,
|
||||||
|
cardDetail: string,
|
||||||
|
cardElementBackground: string,
|
||||||
|
cardElementText: string,
|
||||||
|
cardElementBorder: string,
|
||||||
|
cardElementTitle: string
|
||||||
|
ingredientBackground: string,
|
||||||
|
ingredientContent: string,
|
||||||
|
ingredientBorder: string,
|
||||||
|
}
|
||||||
|
|
||||||
|
export const LightTheme : Theme = {
|
||||||
|
primary: Cerulean,
|
||||||
|
primaryComplement: Moonstone,
|
||||||
|
cardBackground: Alabaster,
|
||||||
|
cardTitle: Ecru,
|
||||||
|
cardDetail: Jet,
|
||||||
|
cardElementBackground: Pearl,
|
||||||
|
cardElementText: Jet,
|
||||||
|
cardElementBorder: Ecru,
|
||||||
|
cardElementTitle: Jet,
|
||||||
|
ingredientBackground: Pearl,
|
||||||
|
ingredientBorder: EerieBlack,
|
||||||
|
ingredientContent: Jet,
|
||||||
|
}
|
||||||
|
|
||||||
|
export const DarkTheme : Theme = {
|
||||||
|
primary: EerieBlack,
|
||||||
|
primaryComplement: Jet,
|
||||||
|
cardBackground: Jet,
|
||||||
|
cardTitle: Ecru,
|
||||||
|
cardDetail: Alabaster,
|
||||||
|
cardElementBackground: SteelBlue,
|
||||||
|
cardElementText: Jet,
|
||||||
|
cardElementTitle: Alabaster,
|
||||||
|
cardElementBorder: SteelBlue,
|
||||||
|
ingredientBackground: EerieBlack,
|
||||||
|
ingredientBorder: SteelBlue,
|
||||||
|
ingredientContent: Alabaster
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in new issue