import 'package:flutter/material.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';

import '../../constant/colors.dart';

class MyCircularProgressIndicator extends StatelessWidget {
  final Color backgroundColor;

  const MyCircularProgressIndicator({
    super.key,
    this.backgroundColor = Colors.transparent,
  });

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Container(
        width: 110,
        height: 110,
        decoration: BoxDecoration(
          color: backgroundColor,
          shape: BoxShape.circle,
        ),
        child: Stack(
          children: [
            const Center(child: CircularProgressIndicator()),
            Column(
              children: [
                Align(
                  alignment: Alignment.center,
                  child: Image.asset('assets/images/logo.png'),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}

class SnackbarConfig {
  static const duration = Duration(seconds: 3);
  static const animationDuration = Duration(milliseconds: 300);
  static const margin = EdgeInsets.symmetric(horizontal: 16, vertical: 10);
  static const borderRadius = 12.0;
  static const elevation = 6.0;

  static final BoxShadow shadow = BoxShadow(
    color: Colors.black.withOpacity(0.1),
    blurRadius: 10,
    offset: const Offset(0, 2),
  );
}

SnackbarController mySnackeBarError(String message) {
  // Trigger error haptic feedback
  HapticFeedback.mediumImpact();

  return Get.snackbar(
    'Error'.tr,
    message,
    backgroundColor: AppColor.redColor.withOpacity(0.95),
    colorText: AppColor.secondaryColor,
    icon: const Icon(
      Icons.error_outline_rounded,
      color: AppColor.secondaryColor,
      size: 28,
    ),
    shouldIconPulse: true,
    snackPosition: SnackPosition.TOP,
    margin: SnackbarConfig.margin,
    borderRadius: SnackbarConfig.borderRadius,
    duration: SnackbarConfig.duration,
    animationDuration: SnackbarConfig.animationDuration,
    forwardAnimationCurve: Curves.easeOutCirc,
    reverseAnimationCurve: Curves.easeInCirc,
    boxShadows: [SnackbarConfig.shadow],
    padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
    titleText: Text(
      'Error'.tr,
      style: const TextStyle(
        fontWeight: FontWeight.w700,
        color: Colors.white,
        fontSize: 16,
        letterSpacing: 0.2,
      ),
    ),
    messageText: Text(
      message,
      style: TextStyle(
        color: Colors.white.withOpacity(0.95),
        fontSize: 14,
        height: 1.3,
      ),
    ),
    onTap: (_) {
      HapticFeedback.lightImpact();
      Get.closeCurrentSnackbar();
    },
    isDismissible: true,
    dismissDirection: DismissDirection.horizontal,
    overlayBlur: 0.8,
    overlayColor: Colors.black12,
  );
}

SnackbarController mySnackbarSuccess(String message) {
  // Trigger success haptic feedback
  HapticFeedback.lightImpact();

  return Get.snackbar(
    'Success'.tr,
    message,
    backgroundColor: AppColor.greenColor.withOpacity(0.95),
    colorText: AppColor.secondaryColor,
    icon: const Icon(
      Icons.check_circle_outline_rounded,
      color: AppColor.secondaryColor,
      size: 28,
    ),
    shouldIconPulse: true,
    snackPosition: SnackPosition.TOP,
    margin: SnackbarConfig.margin,
    borderRadius: SnackbarConfig.borderRadius,
    duration: SnackbarConfig.duration,
    animationDuration: SnackbarConfig.animationDuration,
    forwardAnimationCurve: Curves.easeOutCirc,
    reverseAnimationCurve: Curves.easeInCirc,
    boxShadows: [SnackbarConfig.shadow],
    padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
    titleText: Text(
      'Success'.tr,
      style: const TextStyle(
        fontWeight: FontWeight.w700,
        color: Colors.white,
        fontSize: 16,
        letterSpacing: 0.2,
      ),
    ),
    messageText: Text(
      message,
      style: TextStyle(
        color: Colors.white.withOpacity(0.95),
        fontSize: 14,
        height: 1.3,
      ),
    ),
    onTap: (_) {
      HapticFeedback.lightImpact();
      Get.closeCurrentSnackbar();
    },
    isDismissible: true,
    dismissDirection: DismissDirection.horizontal,
    overlayBlur: 0.8,
    overlayColor: Colors.black12,
  );
}
