import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:mc_common_app/classes/consts.dart';
import 'package:mc_common_app/extensions/int_extensions.dart';
import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/utils/app_permission_handler.dart';
import 'package:mc_common_app/widgets/common_widgets/info_bottom_sheet.dart';

Future<ConfirmAction?> showConfirmDialogs(context, msg, positiveText, negativeText) async {
  return showDialog<ConfirmAction>(
    context: context,
    barrierDismissible: false,
    builder: (context) {
      return AlertDialog(
        backgroundColor: Colors.white,
        title: Text(msg, style: const TextStyle(fontSize: 16)),
        actions: <Widget>[
          TextButton(
            child: Text(
              negativeText,
            ),
            onPressed: () {
              Navigator.of(context).pop(ConfirmAction.CANCEL);
            },
          ),
          TextButton(
            child: Text(
              positiveText,
            ),
            onPressed: () {
              Navigator.of(context).pop(ConfirmAction.ACCEPT);
            },
          )
        ],
      );
    },
  );
}

void actionConfirmationBottomSheet({required BuildContext context, required Widget title, required subtitle, required Widget actionButtonYes, required Widget actionButtonNo, Widget? checkBoxConfirmationWidget, bool isOnlyOneButton = false}) {
  showModalBottomSheet(
    context: context,
    isScrollControlled: true,
    enableDrag: true,
    builder: (BuildContext context) {
      return InfoBottomSheet(
        title: title,
        description: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            "$subtitle".toText(fontSize: 14, fontWeight: MyFonts.Medium),
            if (checkBoxConfirmationWidget != null) ...[
              10.height,
              checkBoxConfirmationWidget,
            ],
            25.height,
            if (isOnlyOneButton) ...[
              Row(
                children: [
                  actionButtonYes,
                ],
              ),
            ] else ...[
              Row(
                children: [
                  actionButtonYes,
                  20.width,
                  actionButtonNo,
                ],
              ),
            ],
            19.height,
          ],
        ),
      );
    },
  );
}
