import 'package:flutter/material.dart';

import '../../app/constant.dart';

Future<String?> myErrorDialog(
    BuildContext context, String errorMsg, String header) {
  return showDialog<String>(
    context: context,
    builder: (BuildContext context) => Dialog(
      child: Padding(
        padding: const EdgeInsets.all(20),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            Text(
              header,
              style: Constant.subTitle(context: context),
            ),
            const SizedBox(
              height: 10,
            ),
            SizedBox(
                width: Constant.getActualX(context: context, x: 700),
                child: const Divider()),
            SizedBox(
              height: Constant.getActualY(context: context, y: 500),
              width: Constant.getActualX(context: context, x: 700),
              child: ListView(
                children: [Text(errorMsg)],
              ),
            ),
            SizedBox(
                width: Constant.getActualX(context: context, x: 700),
                child: const Divider()),
            const SizedBox(
              height: 10,
            ),
            SizedBox(
              width: Constant.getActualX(context: context, x: 700),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.end,
                children: [
                  TextButton(
                    onPressed: () {
                      Navigator.pop(context);
                    },
                    child: const Text('Tutup'),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    ),
  );
}
