import { StyleSheet } from 'react-native';
import { createStylesArg } from '../types';

export function createStyles<TStyles>({
  componentStyles,
  stylesProp,
}: createStylesArg<TStyles>) {
  if (!stylesProp || !Object.keys(stylesProp).length) {
    return componentStyles;
  }
  for (const style in componentStyles) {
    if (stylesProp[style]) {
      componentStyles[style] = StyleSheet.compose(
        componentStyles[style],
        stylesProp[style]
      ) as any;
    }
  }
  return { ...componentStyles };
}
