import Toast from 'react-native-toast-message';

type ToastType = 'success' | 'error' | 'info';

export const showToast = (
  type: ToastType,
  text1: string,
  text2?: string,
  options: {
    position?: 'top' | 'bottom';
    visibilityTime?: number;
    autoHide?: boolean;
    topOffset?: number;
    bottomOffset?: number;
  } = {}
) => {
  Toast.show({
    type,
    text1,
    text2,
    position: options.position || 'bottom',
    visibilityTime: options.visibilityTime || 3000,
    autoHide: options.autoHide !== false,
    topOffset: options.topOffset,
    bottomOffset: options.bottomOffset,
  });
};

// 快捷方法
export const showSuccess = (message: string, description?: string) => {
  showToast('success', message, description);
};

export const showError = (message: string, description?: string) => {
  showToast('error', message, description);
};

export const showInfo = (message: string, description?: string) => {
  showToast('info', message, description);
};

export const hideToast = () => {
  Toast.hide();
};
