import React from "react";
import { View, Text, TextStyle } from "react-native";

type Props = {
  config: {
    titleColor: string;
    summaryColor: string;
    backgroundColor: string;
    backgroundImage: string;
    isRTL: boolean;
    titleFontFamily: string;
    titleFontSize: number;
  };
  title: string | number;
};

const containerStyles = {
  width: 600,
  height: 100,
  marginBottom: 12,
};

const textStyles = ({ titleColor, isRTL, titleFontFamily, titleFontSize }) => ({
  textAlign: (isRTL ? "left" : "right") as TextStyle["textAlign"],
  fontSize: titleFontSize ? Number(titleFontSize) : 38,
  fontWeight: "600" as TextStyle["fontWeight"],
  color: titleColor,
  fontFamily: titleFontFamily || null,
});

export function Title({ title, config }: Props) {
  return (
    <View style={containerStyles}>
      <Text style={textStyles(config)} numberOfLines={2}>
        {title}
      </Text>
    </View>
  );
}
