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

type Props = {
  config: {
    titleColor: string;
    summaryColor: string;
    backgroundColor: string;
    backgroundImage: string;
    isRTL: boolean;
    summaryFontFamily: string;
    summaryFontSize: number;
  };
  summary: string | number;
};

const containerStyles = {
  width: 600,
  height: 80,
  marginBottom: 30,
};

const textStyles = ({
  summaryColor,
  isRTL,
  summaryFontFamily,
  summaryFontSize,
}) => ({
  textAlign: (isRTL ? "left" : "right") as TextStyle["textAlign"],
  fontSize: summaryFontSize ? Number(summaryFontSize) : 20,
  color: summaryColor,
  fontWeight: "600" as TextStyle["fontWeight"],
  opacity: 0.8,
  fontFamily: summaryFontFamily || null,
});

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