import 'package:flutter/material.dart';

enum MessageType { info, error, warning, success }

class CustomSnackBar extends StatelessWidget {
  final MessageType? type;
  final String message;

  const CustomSnackBar({super.key, this.type, required this.message});

  @override
  SnackBar build(BuildContext context) {
    late final Color foregroundColor;
    late final Color backgroundColor;
    late final IconData icon;

    switch (type ?? MessageType.info) {
      case MessageType.info:
        backgroundColor = Color(0xFFE3EFFD);
        foregroundColor = Color(0xFF1F4ECF);
        icon = Icons.info;
      case MessageType.error:
        backgroundColor = Color(0xFFFBEDE9);
        foregroundColor = Color(0xFFD12D00);
        icon = Icons.cancel;
      case MessageType.warning:
        backgroundColor = Color(0xFFFBF3E2);
        foregroundColor = Color(0xFFE34B04);
        icon = Icons.warning_outlined;
      case MessageType.success:
        backgroundColor = Color(0xFFE2F4E8);
        foregroundColor = Color(0xFF00713D);
        icon = Icons.check_circle;
    }

    return SnackBar(
      behavior: SnackBarBehavior.floating,
      backgroundColor: backgroundColor,
      shape: RoundedRectangleBorder(
        side: BorderSide(color: foregroundColor, width: 1),
        borderRadius: BorderRadius.all(Radius.circular(10)),
      ),
      content: Row(
        spacing: 8,
        children: [
          Icon(icon, color: foregroundColor),
          Expanded(
            child: Text(
              message,
              style: TextStyle(color: Color(0xFF4B4B4B), fontSize: 14),
            ),
          ),
        ],
      ),
    );
  }
}
