import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:nomo/config/theme/theme_extensions/theme_extension.dart';
import 'package:nomo/config/translations/strings_enum.dart';
import '../constants/iconfont/iconfont.dart';
import 'custom_dialog.dart';

/// 弹窗使用示例
class AllDialog {
  /// 显示Premium激活成功弹窗
  static void showPremiumActivated() {
    CustomDialog.showSuccess(
      title: Strings.premiumActivated.tr,
      message: Strings.premiumActivatedMessage.tr,
      buttonText: Strings.gotIt.tr,
      icon: Icons.workspace_premium,
      iconColor: const Color(0xFFFF9500),
      onPressed: () {
        // 处理激活成功后的逻辑
        print('Premium activated successfully');
        Navigator.of(Get.context!).pop();
      },
    );
  }

  /// 显示邮件发送成功弹窗
  static void showEmailSent() {
    CustomDialog.showInfo(
      title: Strings.emailSent.tr,
      message: Strings.emailSentMessage.tr,
      buttonText: Strings.ok.tr,
      icon: Icons.mark_email_read,
      iconColor: Colors.white,
      onPressed: () {
        // 处理邮件发送成功后的逻辑
        print('Email sent successfully');
        Navigator.of(Get.context!).pop();
      },
    );
  }

  /// 显示网络连接错误弹窗
  static void showNetworkError() {
    CustomDialog.showError(
      title: Strings.noInternetConnection.tr,
      message: Strings.noInternetMessage.tr,
      buttonText: Strings.retry.tr,
      cancelText: Strings.cancel.tr,
      icon: Icons.wifi_off,
      iconColor: const Color.fromARGB(255, 231, 152, 5),
      confirmButtonColor: Get.reactiveTheme.primaryColor,
      errorCode: '',
      onPressed: () {
        // 处理重试逻辑
        print('Retry network connection');
        Navigator.of(Get.context!).pop();
      },
      onCancel: () {
        // 处理取消逻辑
        print('Cancel network retry');
        Navigator.of(Get.context!).pop();
      },
    );
  }

  /// 显示退出登录确认弹窗
  static void showLogoutConfirm() {
    CustomDialog.showError(
      title: Strings.logOut.tr,
      message: Strings.logOutConfirmMessage.tr,
      buttonText: Strings.logOut.tr,
      cancelText: Strings.cancel.tr,
      icon: Icons.info_outline,
      iconColor: const Color(0xFFFF3B30),
      confirmButtonColor: const Color(0xFFFF3B30),
      onPressed: () {
        // 处理退出登录逻辑
        print('User confirmed logout');
        // 这里可以调用退出登录的API
        Navigator.of(Get.context!).pop();
      },
      onCancel: () {
        // 处理取消退出逻辑
        print('User cancelled logout');
        Navigator.of(Get.context!).pop();
      },
    );
  }

  /// 显示反馈弹窗
  static void showFeedback() {
    CustomDialog.showInfo(
      title: Strings.thankYouFeedback.tr,
      message: Strings.feedbackMessage.tr,
      buttonText: Strings.done.tr,
      icon: Icons.favorite_border,
      iconColor: Get.theme.textTheme.bodyLarge!.color,
      onPressed: () {
        // 处理邮件发送成功后的逻辑
        print('Feedback submitted successfully');
        Navigator.of(Get.context!).pop();
      },
    );
  }

  /// 显示UID信息弹窗
  static void showUidInfo() {
    CustomDialog.showInfo(
      icon: IconFont.icon14,
      iconColor: Get.theme.textTheme.bodyLarge!.color,
      title: Strings.whatIsUid.tr,
      message: Strings.uidMessage.tr,
      buttonText: Strings.ok.tr,
      onPressed: () {
        // 处理邮件发送成功后的逻辑
        print('UID info dialog closed');
        Navigator.of(Get.context!).pop();
      },
    );
  }

  /// 显示自定义成功弹窗
  static void showCustomSuccess({
    required String title,
    required String message,
    String? buttonText,
    VoidCallback? onPressed,
  }) {
    CustomDialog.showSuccess(
      title: title,
      message: message,
      buttonText: buttonText ?? Strings.gotIt.tr,
      onPressed: onPressed,
    );
  }

  /// 显示自定义信息弹窗
  static void showCustomInfo({
    required String title,
    required String message,
    String? buttonText,
    VoidCallback? onPressed,
  }) {
    CustomDialog.showInfo(
      title: title,
      message: message,
      buttonText: buttonText ?? Strings.ok.tr,
      onPressed: onPressed,
    );
  }

  /// 显示自定义错误弹窗
  static void showCustomError({
    required String title,
    required String message,
    String? buttonText,
    String? cancelText,
    VoidCallback? onPressed,
    VoidCallback? onCancel,
    String? errorCode,
  }) {
    CustomDialog.showError(
      title: title,
      message: message,
      buttonText: buttonText ?? Strings.retry.tr,
      cancelText: cancelText,
      onPressed: onPressed,
      onCancel: onCancel,
      errorCode: errorCode,
    );
  }

  /// 显示自定义确认弹窗
  static void showCustomConfirm({
    required String title,
    required String message,
    String? confirmText,
    String? cancelText,
    required VoidCallback onConfirm,
    VoidCallback? onCancel,
    Color? confirmButtonColor,
  }) {
    CustomDialog.showConfirm(
      title: title,
      message: message,
      confirmText: confirmText ?? Strings.confirm.tr,
      cancelText: cancelText ?? Strings.cancel.tr,
      onConfirm: onConfirm,
      onCancel: onCancel,
      confirmButtonColor: confirmButtonColor,
    );
  }
}
