import React from "react";

interface IThemeContext {
    isDarkMode: boolean
    toggleTheme?: () => void
}

const ThemeContext = React.createContext<IThemeContext>({
    isDarkMode: true
});

export const useTheme = () => React.useContext(ThemeContext);

const ThemeContextProvider = ({children}: any) => {
    const [isDarkMode, setIsDarkMode] = React.useState(true);

    const toggleTheme = () => {
        setIsDarkMode(!isDarkMode);
    };

    return (
        <ThemeContext.Provider value={{isDarkMode, toggleTheme}}>
            {children}
        </ThemeContext.Provider>
    );
};

export default ThemeContextProvider;