import 'package:flutter/material.dart';
import '../halo_tokens.dart';

class HaloSnackbar {
  const HaloSnackbar._();

  static void show(
    BuildContext context,
    String message, {
    String? icon,
    Duration duration = const Duration(seconds: 4),
  }) {
    final messenger = ScaffoldMessenger.maybeOf(context);
    if (messenger == null) return;
    messenger
      ..hideCurrentSnackBar()
      ..showSnackBar(
        SnackBar(
          duration: duration,
          behavior: SnackBarBehavior.floating,
          backgroundColor: HaloTokens.ink,
          elevation: 4,
          shape: const RoundedRectangleBorder(borderRadius: HaloRadius.pill),
          margin: const EdgeInsets.symmetric(
            horizontal: HaloSpacing.s16,
            vertical: HaloSpacing.s12,
          ),
          padding: const EdgeInsets.symmetric(
            horizontal: HaloSpacing.s20,
            vertical: HaloSpacing.s12,
          ),
          content: Row(
            mainAxisSize: MainAxisSize.min,
            children: [
              if (icon != null) ...[
                Text(
                  icon,
                  style: const TextStyle(fontSize: 18),
                ),
                const SizedBox(width: HaloSpacing.s8),
              ],
              Flexible(
                child: Text(
                  message,
                  style: const TextStyle(
                    fontFamily: HaloTokens.fontBody,
                    fontSize: 14,
                    fontWeight: FontWeight.w500,
                    color: Colors.white,
                  ),
                ),
              ),
            ],
          ),
        ),
      );
  }
}
