/*
 * @Author: XianKaiQun
 * @Date: 2020-09-21 16:34:04
 * @LastEditors: wjc
 * @LastEditTime: 2023-04-06 16:44:55
 * @Description: 
 */
import 'package:flutter/material.dart';
import 'package:wisdom_cli/wisdom_cli.dart';


Future<bool?> ShowConfirmMeterDialog(context, item, store, isDetail) async {
  final style = WTheme.of(context);
  final colorScheme = style.colorScheme;

  return showDialog<bool>(
    context: context,
    barrierDismissible: false, // user must tap button!
    builder: (BuildContext context) {
      return AlertDialog(
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(24.5.pt),
        ),
        title: Wisdom.row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Image.asset(
              'lib/assets/icon_hzqr.png',
              width: 21.pt,
              height: 17.pt,
              package: 'intelligent_package',
            ),
            Wisdom(
              child: Text(
                '合闸送电确认',
                style: TextStyle(
                  color: Color(0xff222222),
                  fontSize: 16.pt,
                  fontWeight: FontWeight.bold,
                ),
              ),
            ),
          ],
        ),
        content: Wisdom.column(
          mainAxisSize: MainAxisSize.min,
          children: [
            Text(
              '合闸前请务必确认安全，如正在断电施工时请勿合闸，以免造成人身伤害',
              style: TextStyle(
                color: Color(0xff222222),
                fontSize: 16.pt,
              ),
            ),
            Wisdom.row(
              margin: EdgeInsets.only(top: 25.pt),
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Expanded(
                  child: Wisdom(
                    onTap: () => {Navigator.pop(context, false)},
                    margin: EdgeInsets.only(right: 15.pt),
                    padding: EdgeInsets.symmetric(vertical: 10.pt),
                    borderRadius: BorderRadius.circular(25.pt),
                    alignment: Alignment.center,
                    color: Color(0xffF2F2F2),
                    child: Text(
                      '取消',
                      style: TextStyle(
                        color: Color(0xff222222),
                        fontSize: 16.pt,
                      ),
                    ),
                  ),
                  flex: 1,
                ),
                Expanded(
                  child: Wisdom(
                    onTap: () async => {
                      await store.handleMeterOn(item, isDetail),
                      Navigator.pop(context, true)
                    },
                    borderRadius: BorderRadius.circular(25.pt),
                    alignment: Alignment.center,
                    padding: EdgeInsets.symmetric(vertical: 10.pt),
                    color: colorScheme.primary,
                    child: Text(
                      '确认',
                      style: TextStyle(
                        color: Color(0xffffffff),
                        fontSize: 16.pt,
                      ),
                    ),
                  ),
                  flex: 1,
                ),
              ],
            )
          ],
        ),
      );
    },
  );
}

Future<bool?> showOffMeterDialog(context, item, store, isDetail) async {
  return showDialog<bool>(
    context: context,
    barrierDismissible: false, // user must tap button!
    builder: (BuildContext context) {
      return AlertDialog(
        title: Wisdom.row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Image.asset(
              'lib/assets/icon_hzqr.png',
              width: 21.pt,
              height: 17.pt,
              package: 'intelligent_package',
            ),
            Wisdom(
              child: Text(
                '拉闸断电确认',
                style: TextStyle(
                  color: Color(0xff222222),
                  fontSize: 16.pt,
                  fontWeight: FontWeight.bold,
                ),
              ),
            ),
          ],
        ),
        content: Wisdom.column(
          mainAxisSize: MainAxisSize.min,
          children: [
            Text(
              '拉闸前请务必确认安全，以免造成人身伤害',
              style: TextStyle(
                color: Color(0xff222222),
                fontSize: 16.pt,
              ),
            ),
            Wisdom.row(
              margin: EdgeInsets.only(top: 25.pt),
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Expanded(
                  child: Wisdom(
                    onTap: () => {Navigator.pop(context, false)},
                    margin: EdgeInsets.only(right: 15.pt),
                    padding: EdgeInsets.symmetric(vertical: 10.pt),
                    borderRadius: BorderRadius.circular(3.pt),
                    alignment: Alignment.center,
                    color: Color(0xffF2F2F2),
                    child: Text(
                      '取消',
                      style: TextStyle(
                        color: Color(0xff222222),
                        fontSize: 16.pt,
                      ),
                    ),
                  ),
                  flex: 1,
                ),
                Expanded(
                  child: Wisdom(
                    onTap: () async => {
                      await store.handleMeterOff(item, isDetail),
                      Navigator.pop(context, true)
                    },
                    borderRadius: BorderRadius.circular(3.pt),
                    alignment: Alignment.center,
                    padding: EdgeInsets.symmetric(vertical: 10.pt),
                    color: Color(0xff2E8CF0),
                    child: Text(
                      '确认',
                      style: TextStyle(
                        color: Color(0xffffffff),
                        fontSize: 16.pt,
                      ),
                    ),
                  ),
                  flex: 1,
                ),
              ],
            )
          ],
        ),
      );
    },
  );
}
