/*
 * @Author: XianKaiQun
 * @Date: 2020-08-04 11:27:40
 * @LastEditors: XianKaiQun
 * @LastEditTime: 2020-08-04 16:08:11
 * @Description: 
 */
part of '../index.dart';

///设备信息修改时展示
class _MotifyComponent extends StatelessWidget {
  const _MotifyComponent({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    final store = Provider.of<PrivateRepairDetailItemStore>(context);
    final style = WTheme.of(context);
    final colorScheme = style.colorScheme;
    final theme = Theme.of(context);
    final textTheme = theme.textTheme;
    final data = store.data;
    final vo = data?.equipmentUpdateRecordVo;
    if ((vo ?? []).length == 0) {
      return SliverToBoxAdapter();
    }
    final olds = vo![0];
    final news = vo[1];

    final list = [
      {
        'name': '设备编号',
        'old': olds.number,
        'new': news.number,
      },
      {
        'name': '设备品类',
        'old': olds.category,
        'new': news.category,
      },
      {
        'name': '设备品牌及型号',
        'old': olds.type,
        'new': news.type,
      },
      {
        'name': '设备状态',
        'old': olds.status,
        'new': news.status,
      },
      {
        'name': '负责人',
        'old': olds.manager,
        'new': news.manager,
      },
      {
        'name': '出厂年月',
        'old': olds.productDate,
        'new': news.productDate,
      },
      {
        'name': '出厂编号',
        'old': olds.productNumber,
        'new': news.productNumber,
      },
      {
        'name': '安装日期',
        'old': olds.installDate,
        'new': news.installDate,
      },
      {
        'name': '使用年限',
        'old': olds.life,
        'new': news.life,
      },
      {
        'name': '巡检规范',
        'old': olds.routinginspectionName,
        'new': news.routinginspectionName,
      },
      {
        'name': '保养规范',
        'old': olds.maintenancecodeName,
        'new': news.maintenancecodeName,
      },
    ];
    return WisCard(
      isSliver: true,
      margin: EdgeInsets.all(15.pt),
      child: Column(
        children: <Widget>[
          for (var item in list)
            if (item['old'] != item['new'])
              Wisdom.column(
                padding: EdgeInsets.symmetric(
                  horizontal: 15.pt,
                  vertical: 10.pt,
                ),
                children: <Widget>[
                  Row(
                    children: <Widget>[
                      WisActiveness.vertical(),
                      Text(
                        '${item['name']}',
                        style: textTheme.titleSmall,
                      ),
                    ],
                  ),
                  Wisdom.row(
                    margin: EdgeInsets.only(top: 5.pt),
                    padding: EdgeInsets.symmetric(
                      horizontal: 15.pt,
                      vertical: 10.pt,
                    ),
                    color: colorScheme.background,
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      SizedBox(
                        width: 130.pt,
                        child: Text('${item['old'] ?? '--'}'),
                      ),
                      Center(
                        child: Icon(FaIcons.long_arrow_right),
                      ),
                      SizedBox(
                        width: 130.pt,
                        child: Text(
                          '${item['new'] ?? '--'}',
                          textAlign: TextAlign.end,
                        ),
                      ),
                    ],
                  ),
                ],
              )
        ],
      ),
    );
  }
}
