import 'package:hmg_patient_app/theme/colors.dart';
import 'package:hmg_patient_app/uitl/translations_delegate_base.dart';
import 'package:hmg_patient_app/uitl/utils_new.dart';
import 'package:hmg_patient_app/widgets/buttons/secondary_button.dart';
import 'package:flutter/material.dart';

Future<void> showCMCConfirmDialog(BuildContext context, String requestId, {required Function onClick}) async {
  return showDialog<void>(
    context: context,
    barrierDismissible: false, // user must tap button!
    builder: (BuildContext context) {
      return Dialog(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            ConfirmDialog(
              requestId,
              onClick: onClick,
            ),
          ],
        ),
      );
    },
  );
}

class ConfirmDialog extends StatelessWidget {
  String requestId;
  Function onClick;

  ConfirmDialog(this.requestId, {required this.onClick});

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      padding: EdgeInsets.all(20),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            crossAxisAlignment: CrossAxisAlignment.start,
            mainAxisAlignment: MainAxisAlignment.start,
            children: [
              Container(
                width: 40,
                height: 40,
                margin: EdgeInsets.only(top: 20),
                decoration: containerRadius(CustomColors.green, 200,),
                child: Icon(Icons.done,color: Colors.white,),
              ),
              mFlex(1),
              IconButton(
                icon: Icon(
                  Icons.close,
                ),
                onPressed: () {
                  onClick();
                  Navigator.pop(context);
                },
              ),
            ],
          ),
          mHeight(12),
          Text(
            TranslationBase.of(context).RRTRequestSuccess,
            textAlign: TextAlign.start,
            style: TextStyle(
              fontSize: 14,
              fontWeight: FontWeight.bold,
              letterSpacing: -0.46,
            ),
          ),
          mHeight(20),
          Text(
            TranslationBase.of(context).reqId,
            style: TextStyle(
              fontSize: 14,
              fontWeight: FontWeight.bold,
              color: Colors.grey[600],
              letterSpacing: -0.46,
            ),
          ),
          Text(
            requestId ?? "",
            style: TextStyle(
              fontSize: 18,
              fontWeight: FontWeight.bold,
              color: Colors.black,
              letterSpacing: -0.46,
            ),
          ),
          mHeight(20),
          Container(
            width: MediaQuery.of(context).size.width * 0.9,
            child: SecondaryButton(
                label: TranslationBase.of(context).ok.toUpperCase(),
                color: CustomColors.accentColor,
                onTap: () async {
                  onClick();
                  Navigator.pop(context);
                },
                textColor: CustomColors.white),
          ),
        ],
      ),
    );
  }
}
