/*
 * @Author       : WuWei
 * @LastEditors: ChenYaJin
 * @Date         : 2021-08-16 16:06:58
 * @LastEditTime: 2023-04-23 10:12:21
 * @Description  : Do not edit
 */

import 'package:flutter/material.dart';
import 'package:wisdom_cli/wisdom_cli.dart';

class AbnormalItem extends StatelessWidget {
  const AbnormalItem({
    Key? key,
    required this.item,
    this.isDetail = false,
    this.onClick,
  }) : super(key: key);
  final item;
  final bool? isDetail;
  final Function(dynamic value)? onClick;

  @override
  Widget build(BuildContext context) {
    final style = WTheme.of(context);
    final colorScheme = style.colorScheme;

    return Wisdom(
      color: Colors.white,
      padding: EdgeInsets.all(15.pt),
      onTap: () => onClick!(item),
      borderRadius: BorderRadius.circular(12.pt),
      boxShadow: [
        BoxShadow(
          offset: Offset(0, 2),
          color: Color(0x08000000),
          blurRadius: 10.pt,
          spreadRadius: 2.5.pt,
        ),
      ],
      child: Wisdom.column(
        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: <Widget>[
          Wisdom.row(
            children: [
              Text.rich(
                TextSpan(
                  children: [
                    TextSpan(
                      text: item.relationName ?? '',
                      style: TextStyle(
                        fontSize: 16.pt,
                        fontWeight: FontWeight.w600,
                      ),
                    ),
                  ],
                ),
                maxLines: 1,
                overflow: TextOverflow.ellipsis,
              ).asExpanded(),
              Wisdom.row(
                children: [
                  Wisdom(
                    margin: EdgeInsets.only(right: 5.pt),
                    child: WisText(
                      '${item.resultAbnormal == true && item.status == 'untreated' ? '待处理' : ''}',
                      color: item?.resultAbnormal == true
                          ? colorScheme.red
                          : colorScheme.green,
                    ),
                  ),
                  if (isDetail == false)
                    Icon(
                      Icons.arrow_forward_ios,
                      size: 14.pt,
                      color: colorScheme.grey,
                    )
                ],
              ),
            ],
          ),
          Wisdom.row(
            padding: EdgeInsets.only(
              top: 15.pt,
            ),
            children: [
              Wisdom(
                child: Text(
                  '所属区域: ${item?.communityAreaName ?? '--'}',
                  style: TextStyle(
                    fontWeight: FontWeight.w300,
                    fontSize: 14.pt,
                    color: Color(0xFF616178),
                  ),
                ),
              ).asExpanded(),
            ],
          ),
          Wisdom.row(
            padding: EdgeInsets.only(
              top: 10.pt,
            ),
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Wisdom(
                child: Text(
                  "操作时间: ${item?.createdAt ?? '--'}",
                  style: TextStyle(
                    fontWeight: FontWeight.w300,
                    fontSize: 14.pt,
                    color: Color(0xFF616178),
                  ),
                ),
              ).asExpanded(),
              Wisdom(
                child: Text(
                  "执行人: ${item?.createdByName ?? '--'}",
                  style: TextStyle(
                    fontWeight: FontWeight.w300,
                    fontSize: 14.pt,
                    color: Color(0xFF616178),
                  ),
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }
}
