/*
 * @Author: wjc
 * @Date: 2022-04-18 10:11:46
 * @LastEditors: wjc
 * @LastEditTime: 2023-04-06 16:44:00
 * @Description: 
 */
import 'package:flutter/material.dart';
import 'package:wisdom_cli/wisdom_cli.dart';

// ignore: non_constant_identifier_names
Future<bool?> ShowConfirmMeterDialog(context, item, store, behavior) 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(
              margin: EdgeInsets.only(left: 5.pt),
              child: Text(
                behavior == 'OPEN' ? '合闸提醒' : '拉闸提醒',
                style: TextStyle(
                  color: Color(0xff222222),
                  fontSize: 16.pt,
                  fontWeight: FontWeight.bold,
                ),
              ),
            ),
          ],
        ),
        content: Wisdom.column(
          mainAxisSize: MainAxisSize.min,
          children: [
            Text(
              behavior == 'OPEN'
                  ? '合闸后，设备处于通电状态，合闸前请务必确认安全，如正在断电施工时请勿合闸，以免造成人身伤害。'
                  : '拉闸后，设备处于断电状态，是否对其进行操作？',
              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.handleDeviceOperate(item, behavior),
                      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,
                ),
              ],
            )
          ],
        ),
      );
    },
  );
}
