/*
 * @Author: WuXiangNan
 * @Date: 2021-01-29 14:23:50
 * @LastEditTime: 2021-01-29 15:20:06
 * @LastEditors: WuXiangNan
 * @Description: Confirm modal
 */
import 'package:flutter/material.dart';
import 'package:wisdom_cli/wisdom_cli.dart';

confirmModal(BuildContext context, String title, void confirmFunction()) {
  showDialog(
    barrierDismissible: false,
    context: context,
    builder: (context) {
      return Center(
          child: Container(
        height: 153.pt,
        width: 307.pt,
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(3.pt),
        ),
        child: Column(
          children: [
            Center(
              child: Container(
                padding: EdgeInsets.only(top: 30.pt, bottom: 36.pt),
                child: Text(
                  '$title',
                  style: TextStyle(
                      fontSize: 18.pt,
                      color: Colors.black,
                      fontWeight: FontWeight.normal,
                      decoration: TextDecoration.none),
                ),
              ),
            ),
            Container(
              alignment: Alignment.bottomCenter,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Container(
                    height: 44.pt,
                    width: 126.pt,
                    child: WisButton.loading(
                      color: Color(0xFFF2F2F2),
                      child: Text(
                        '取消',
                        style: TextStyle(
                            fontSize: 16.pt, color: Color(0xFF222222)),
                      ),
                      onPressed: () {
                        Navigator.of(context).pop();
                        return null;
                      } as Future<void> Function(),
                    ),
                  ),
                  SizedBox(
                    width: 15.pt,
                  ),
                  Container(
                    height: 44.pt,
                    width: 126.pt,
                    child: WisButton.loading(
                      color: Color(0xFF2D8CF0),
                      child: Text(
                        '确认',
                        style: TextStyle(fontSize: 16.pt),
                      ),
                      onPressed: () {
                        Navigator.of(context).pop();
                        confirmFunction();
                        return null;
                      } as Future<void> Function(),
                    ),
                  )
                ],
              ),
            ),
          ],
        ),
      ));
    },
  );
}