Kurabu-chan / Kurabu

monorepo for the Kurabu project
BSD 3-Clause "New" or "Revised" License
8 stars 4 forks source link

Add option for using themes #159

Closed rafaeltab closed 2 years ago

rafaeltab commented 2 years ago

Use a useTheme hook to automatically put the correct colors into our styles. Possibly use Symbols to represent the color that should be used.

export const ThemeKeys = {
    core: {
        background: Symbol("theme_core_background") as string,
        textColor: Symbol("theme_core_textColor") as string
    }
}
export class CoolComponent extends React.Component {

    render(){
        const themedStyles = useTheme(styles);
        return (<View style={themedStyles.container}>
             <Text style={themedStyles.text}>
                  Banana
             </Text>
        </View>);
    }
}

const styles = StyleSheet.create({
    container: {
        backgroundColor: ThemeKeys.core.background
    },
    text:{
        color: ThemeKeys.core.textColor
    }
});