import 'package:flutter/material.dart';

import '../../configs/configs.dart';
import '../../core/core.dart';

Future<void> showErrorDialog({
  required BuildContext context,
  required String header,
  required String body,
  String dismissButtonText = 'Dismiss',
  VoidCallback? onDismiss,
}) async {
  return showDialog(
    context: context,
    barrierDismissible: false,
    builder: (BuildContext context) {
      return Dialog(
        child: Container(
          padding: Space.all(1, .5),
          child: Column(
            mainAxisSize: MainAxisSize.min,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Container(
                padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
                decoration: const BoxDecoration(
                  color: AppColors.primary,
                  borderRadius: BorderRadius.all(
                    Radius.circular(12),
                  ),
                ),
                child: Text(
                  header,
                  style: AppText.h3b?.copyWith(color: Colors.white),
                ),
              ),
              Padding(
                padding: const EdgeInsets.all(16.0),
                child: Text(
                  body,
                  style: AppText.b1,
                ),
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.end,
                children: [
                  TextButton(
                    onPressed: () {
                      Navigator.pop(context);
                      if (onDismiss != null) {
                        onDismiss();
                      }
                    },
                    child: Text(
                      dismissButtonText,
                      style: AppText.h3b?.copyWith(
                        color: AppColors.primary,
                      ),
                    ),
                  ),
                ],
              ),
            ],
          ),
        ),
      );
    },
  );
}
