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

export type ITextInputRef = {
    updateValue: (text: string) => void;
    cleanText: () => void;
    focus: () => void;
    blur: () => void;
};

export type TextInputDynamicStyleType = {
    inlineSpaces: NCoreUIKit.ActivePalette["inlineSpaces"];
    typography: NCoreUIKit.ActivePalette["typography"];
    radiuses: NCoreUIKit.ActivePalette["radiuses"];
    spreadBehaviour?: TextInputSpreadBehaviour;
    spaces: NCoreUIKit.ActivePalette["spaces"];
    colors: NCoreUIKit.ActivePalette["colors"];
    currentType: TextInputTypes;
    borders: NCoreUIKit.Borders;
    isDisabled?: boolean;
    type: TextInputType;
    isFocused: boolean;
    title?: string;
    icon?: boolean;
};

export type TextInputTypes = {
    containerColor: keyof NCoreUIKit.ContainerContentColors;
    focusBorderColor: keyof NCoreUIKit.BorderContentColors;
    hintTextIconColor: keyof NCoreUIKit.IconContentColors;
    placeholderColor: keyof NCoreUIKit.TextContentColors;
    hintTextColor: keyof NCoreUIKit.TextContentColors;
    borderColor: keyof NCoreUIKit.BorderContentColors;
    inputColor: keyof NCoreUIKit.TextContentColors;
    titleColor: keyof NCoreUIKit.TextContentColors;
    iconColor: keyof NCoreUIKit.IconContentColors;
};

export type TextInputInstance = NonNullable<ComponentRef<typeof TextInput>>;

export type TextInputType = "default" | "danger" | "warning" | "question" | "success" | "info";

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

export type TextInputVariant = "text" | "hidden";

interface ITextInputProps extends TextInputProps {
    customTheme?: {
        gapPropagation?: NCoreUIKit.GapPropagationKey;
        sharpness?: NCoreUIKit.SharpnessKey;
        paletteKey?: NCoreUIKit.PaletteKey;
        themeKey?: NCoreUIKit.ThemeKey;
    };
    customLocalize?: {
        activeLocale?: NCoreUIKit.LocaleKey;
    };
    spreadBehaviour?: TextInputSpreadBehaviour;
    onChangeText?: (value: string) => void;
    validation?: (text: string) => boolean;
    isAutoKeyboardDismissOnBlur?: boolean;
    hintTextContainerStyle?: ViewStyle;
    contentContainerStyle?: ViewStyle;
    inputStyle?: StyleProp<TextStyle>;
    isShowHideTextButton?: boolean;
    hideTextIconStyle?: ViewStyle;
    rightIconOnPress?: () => void;
    hintTextIcon?: NCoreUIKitIcon;
    isShowHintTextIcon?: boolean;
    cleanIconStyle?: ViewStyle;
    rightIconStyle?: ViewStyle;
    rightIcon?: NCoreUIKitIcon;
    variant?: TextInputVariant;
    isShowSubTitle?: boolean;
    isCleanEnabled?: boolean;
    iconOnPress?: () => void;
    initialValue?: string;
    iconStyle?: ViewStyle;
    icon?: NCoreUIKitIcon;
    placeholder?: string;
    isRequired?: boolean;
    isDisabled?: boolean;
    isOptional?: boolean;
    onFocus?: () => void;
    type?: TextInputType;
    onBlur?: () => void;
    hintText?: string;
    subTitle?: string;
    style?: ViewStyle;
    title?: string;
    id?: string;
};
export type {
    ITextInputProps as default
};
