import 'package:boilerplate/core/i18n/translations.g.dart';
import 'package:boilerplate/core/styles/my_dimensions.dart';
import 'package:boilerplate/core/styles/my_font.dart';
import 'package:boilerplate/core/utils/navigator_util.dart';
import 'package:boilerplate/presentation/widgets/ipm_button.dart';
import 'package:flutter/material.dart';

enum IPMDialogType {
  warning,
  comfirm,
}

class IPMDialog extends StatelessWidget {
  final IPMDialogType type;
  final String? title;
  final String message;

  IPMDialog({
    Key? key,
    this.type = IPMDialogType.warning,
    this.title,
    required this.message,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Dialog(
      insetPadding: EdgeInsets.all(MyDimens.dimen20),
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(10),
      ),
      child: Container(
        padding: EdgeInsets.symmetric(
          vertical: MyDimens.dimen20,
          horizontal: MyDimens.dimen16,
        ),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            Text(
              this.title ?? AppLocalizations.dialog.warning,
              style: MyFont.medium20,
              textAlign: TextAlign.center,
            ),
            SizedBox(height: MyDimens.dimen12),
            Text(
              this.message,
              style: MyFont.regular18,
              textAlign: TextAlign.center,
            ),
            SizedBox(height: MyDimens.dimen28),
            Row(
              children: [
                if (this.type == IPMDialogType.comfirm)
                  Expanded(
                    child: IPMButton(
                      text: AppLocalizations.dialog.cancel,
                      onPressed: () {
                        Navigator.pop(context, false);
                      },
                    ),
                  ),
                if (this.type == IPMDialogType.comfirm)
                  SizedBox(width: MyDimens.dimen10),
                Expanded(
                  child: IPMButton(
                    text: AppLocalizations.dialog.ok,
                    backgroundColor: Colors.grey,
                    onPressed: () {
                      Navigator.pop(context, true);
                    },
                  ),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}
