import {
    type ButtonProps,
    type ViewStyle,
    type StyleProp,
    type TextStyle
} from "react-native";
import {
    type NCoreUIKitIcon
} from "../../types";

export type ButtonDynamicStyleType = {
    displayBehaviourWhileLoading?: ButtonDisplayBehaviourWhileLoading;
    radiuses: NCoreUIKit.ActivePalette["radiuses"];
    spaces: NCoreUIKit.ActivePalette["spaces"];
    colors: NCoreUIKit.ActivePalette["colors"];
    spreadBehaviour?: ButtonSpreadBehaviour;
    iconDirection?: "left" | "right";
    currentVariant: ButtonVariants;
    borders: NCoreUIKit.Borders;
    currentSize: ButtonMeasures;
    isCustomPadding?: boolean;
    currentType: ButtonTypes;
    variant: ButtonVariant;
    icon?: NCoreUIKitIcon;
    isDisabled?: boolean;
    isLoading?: boolean;
    type: ButtonType;
    title?: string;
};

export type ButtonMeasuresKeys = {
    paddingHorizontal: keyof NCoreUIKit.Spaces;
    paddingVertical: keyof NCoreUIKit.Spaces;
    fontSize: keyof NCoreUIKit.Typography;
};

export type ButtonVariants = {
    iconColor: keyof NCoreUIKit.IconContentColors | string | "type";
    titleColor: keyof NCoreUIKit.TextContentColors | "type";
    borderColor: "transparent" | "type" | "container";
    containerColor: "transparent" | "type";
};

export type ButtonTypes = {
    containerColor: keyof NCoreUIKit.ContainerContentColors;
    borderColor: keyof NCoreUIKit.BorderContentColors;
    titleColor: keyof NCoreUIKit.TextContentColors;
    iconColor: keyof NCoreUIKit.IconContentColors;
};

export type ButtonMeasures = {
    fontSize: keyof NCoreUIKit.Typography;
    paddingHorizontal: number;
    paddingVertical: number;
};

export type ButtonVariantConstantType = {
    variant: ButtonVariant;
};

export type ButtonTypeConstantType = {
    type: ButtonType;
};

export type ButtonSizeConstantType = {
    spaces: NCoreUIKit.ActivePalette["spaces"];
    size: ButtonSize;
};

export type ButtonType = "primary" | "danger" | "warning" | "neutral" | "success" | "info";

export type ButtonDisplayBehaviourWhileLoading = "none" | "disabled";

export type ButtonSpreadBehaviour = "baseline" | "stretch" | "free";

export type ButtonVariant = "filled" | "outline" | "ghost";

export type ButtonSize = "small" | "medium" | "large";

interface IButtonProps extends Omit<ButtonProps, "title"> {
    displayBehaviourWhileLoading?: ButtonDisplayBehaviourWhileLoading;
    titleStyle?: StyleProp<TextStyle>[] | StyleProp<TextStyle>;
    style?: StyleProp<ViewStyle>[] | StyleProp<ViewStyle>;
    customTheme?: {
        gapPropagation?: NCoreUIKit.GapPropagationKey;
        sharpness?: NCoreUIKit.SharpnessKey;
        paletteKey?: NCoreUIKit.PaletteKey;
        themeKey?: NCoreUIKit.ThemeKey;
    };
    spreadBehaviour?: ButtonSpreadBehaviour;
    iconDirection?: "left" | "right";
    isCustomPadding?: boolean;
    variant?: ButtonVariant;
    icon?: NCoreUIKitIcon;
    isDisabled?: boolean;
    onPress: () => void;
    isLoading?: boolean;
    size?: ButtonSize;
    type?: ButtonType;
    title?: string;
}
export type {
    IButtonProps as default
};
