import 'package:deus_app/common/utils/CommonUtils.dart';
import 'package:deus_app/common/utils/ConstantString.dart';
import 'package:deus_app/common/utils/ToastUtils.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class CloseTaskDialog {

  static void showCupertinoAlertDialog(
      BuildContext context, _CallBack onPressed) {
    String result = '';
    showDialog(
        context: context,
        barrierDismissible:false,
        builder: (BuildContext context) {
          return Theme(
              data: ThemeData(
                  dialogBackgroundColor: Colors.white,
                  dialogTheme: DialogTheme(backgroundColor: Colors.white)),
              child: CupertinoAlertDialog(
                title: Text(ConstantString.close_task),
                content: Column(
                  children: <Widget>[
                    SizedBox(
                      height: 10,
                    ),
                    new TextField(
                      maxLines: 3,
                      decoration: InputDecoration(border: OutlineInputBorder()),
                      style: TextStyle(fontSize: 14),
                      onChanged: (value) {
                        result = value;
                      },
                    )
                  ],
                ),
                actions: <Widget>[
                  CupertinoDialogAction(
                    child: Text("取消"),
                    onPressed: () {
                      Navigator.pop(context);
                    },
                  ),
                  CupertinoDialogAction(
                    child: Text("确定"),
                    onPressed: () {
                      if (!CommonUtils.validationInput(result)) {
                        showToast(ConstantString.notesNull);
                      } else {
                        onPressed(result);
                        Navigator.pop(context);
                      }
                    },
                  ),
                ],
              ));
        });
  }

  static void showAlertDialog(
      BuildContext context, _Back onPressed,String text) {
    showDialog(
        context: context,
        barrierDismissible:false,
        builder: (BuildContext context) {
          return Theme(
              data: ThemeData(
                  dialogBackgroundColor: Colors.white,
                  dialogTheme: DialogTheme(backgroundColor: Colors.white)),
              child: CupertinoAlertDialog(
                title: Text('提示'),
                content: Column(
                  children: <Widget>[
                    SizedBox(
                      height: 10,
                    ),
                    Container(
                      padding: EdgeInsets.all(10),
                      child: Text(text),
                    )
                  ],
                ),
                actions: <Widget>[
                  CupertinoDialogAction(
                    child: Text("取消"),
                    onPressed: () {
                      Navigator.pop(context);
                    },
                  ),
                  CupertinoDialogAction(
                    child: Text("确定"),
                    onPressed: () {

                        onPressed();
                        Navigator.pop(context);
                    },
                  ),
                ],
              ));
        });
  }
}
typedef _CallBack = void Function(String msg);

typedef _Back = void Function();


