import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class ConfirmWithMessageDialog extends StatelessWidget {
  final String title;
  final String message;
  final String okTitle;
  final VoidCallback onTap;

  const ConfirmWithMessageDialog({Key key, this.title, @required this.message, this.okTitle, this.onTap}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Dialog(
      backgroundColor: Colors.white,
      shape: RoundedRectangleBorder(),
      insetPadding: EdgeInsets.only(left: 21, right: 21),
      child: Padding(
        padding: EdgeInsets.only(left: 20, right: 20, top: 18, bottom: 28),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisSize: MainAxisSize.min,
          children: [
            Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Expanded(
                  child: Padding(
                    padding: const EdgeInsets.only(top: 16.0),
                    child: Text(
                      title ?? TranslationBase.of(context).confirm,
                      style: TextStyle(fontSize: 24, fontWeight: FontWeight.w600, color: Color(0xff2B353E), height: 35 / 24, letterSpacing: -0.96),
                    ),
                  ),
                ),
                IconButton(
                  padding: EdgeInsets.zero,
                  icon: Icon(Icons.close),
                  color: Color(0xff2B353E),
                  constraints: BoxConstraints(),
                  onPressed: () {
                    Navigator.pop(context);
                  },
                )
              ],
            ),
            Text(
              message,
              style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff808080), letterSpacing: -0.48),
            ),
            SizedBox(height: 28),
            Row(
              mainAxisSize: MainAxisSize.min,
              children: [
                Expanded(
                  child: DefaultButton(
                    TranslationBase.of(context).cancel_nocaps,
                    () => Navigator.pop(context),
                    textColor: Colors.white,
                    color: CustomColors.accentColor,
                  ),
                ),
                SizedBox(width: 10),
                Expanded(
                  child: DefaultButton(
                    okTitle ?? TranslationBase.of(context).ok,
                    () {
                      Navigator.pop(context);
                      onTap();
                    },
                    textColor: Colors.white,
                    color: CustomColors.green,
                  ),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}
