import {
    type TextStyle,
    type ViewStyle,
    StyleSheet
} from "react-native";
import type {
    RowCardDynamicStyleType
} from "./type";
import type {
    Mutable
} from "../../types";

const stylesheet = StyleSheet.create({
    leftContainer: {
        justifyContent: "flex-start",
        flexDirection: "row",
        alignItems: "center"
    },
    rightContainer: {
        justifyContent: "flex-end",
        flexDirection: "row",
        alignItems: "center"
    },
    iconContainer: {
        justifyContent: "center",
        alignItems: "center"
    },
    container: {
        flexDirection: "row",
        alignItems: "center",
        alignSelf: "stretch"
    },
    rightIconContainer: {

    },
    title: {
        textAlign: "left"
    },
    subTitle: {
        textAlign: "left"
    },
    rightSubTitle: {

    },
    rightTitle: {

    }
});

export const useStyles = ({
    isTransparentBackground,
    backgroundColor,
    colors,
    spaces,
    type
}: RowCardDynamicStyleType) => {
    const styles = {
        container: {
            backgroundColor: backgroundColor ? colors.content.container[backgroundColor] : isTransparentBackground ? "transparent" : colors.content.container.mid,
            padding: spaces.spacingMd
        } as Mutable<ViewStyle>,
        iconContainer: {
            paddingHorizontal: spaces.spacingSm
        } as Mutable<ViewStyle>,
        leftContainer: {
            paddingHorizontal: spaces.spacingSm
        } as Mutable<ViewStyle>,
        rightContainer: {
            paddingHorizontal: spaces.spacingSm
        } as Mutable<ViewStyle>,
        rightIconContainer: {
            paddingHorizontal: spaces.spacingSm
        } as Mutable<ViewStyle>,
        title: {
            textAlign: "left"
        } as Mutable<TextStyle>,
        subTitle: {
            textAlign: "left"
        } as Mutable<TextStyle>,
        rightSubTitle: {
            textAlign: "right"
        } as Mutable<TextStyle>,
        rightTitle: {
            textAlign: "right"
        } as Mutable<TextStyle>
    };

    if(type === "evenly") {
        styles.rightContainer.flex = 1;
        styles.leftContainer.flex = 1;
    } else {
        styles.leftContainer.flex = 1;
    }

    return styles;
};
export default stylesheet;
