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

const stylesheet = StyleSheet.create({
    container: {
        justifyContent: "center",
        alignItems: "center",
        display: "flex"
    },
    indicator: {
        flex: 1
    },
    title: {
    }
});

export const useStyles = ({
    customColor,
    direction,
    borders,
    colors,
    length,
    spaces,
    color
}: SeperatorDynamicStyle) => {
    const styles = {
        indicator: {
            backgroundColor: customColor ? customColor : color ? colors.content.border[color] : colors.content.border.subtle
        } as Mutable<ViewStyle>,
        title: {
            marginHorizontal: spaces.spacingSm
        } as Mutable<TextStyle>,
        container: {
        } as Mutable<ViewStyle>
    };

    if(direction === "horizontal") {
        styles.container.flexDirection = "row";
        styles.container.width = "90%";

        styles.indicator.height = borders.seperator;
        styles.indicator.width = "100%";
    } else {
        styles.container.flexDirection = "column";
        styles.container.height = "90%";

        styles.indicator.width = borders.seperator;
        styles.indicator.height = "100%";
    }

    if(length !== undefined) {
        if(direction === "horizontal") {
            styles.container.width = length as DimensionValue;
        } else {
            styles.container.height = length as DimensionValue;
        }
    }

    return styles;
};
export default stylesheet;
