/*
 * @Author       : WuWei
 * @LastEditors: ChenYaJin
 * @Date         : 2021-05-10 14:19:38
 * @LastEditTime: 2023-08-09 15:29:57
 * @FilePath     : /wisdom-huiguanjia-app/task_package/lib/src/pages/statistic/components/list_stat.dart
 * @Description  : 任务统计-任务类型
 */

import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:task_package/src/view_models/statistic_store.dart';
import 'package:wisdom_cli/wisdom_cli.dart';
import 'task_row_item.dart';

class BuildTaskListStat extends StatelessWidget {
  const BuildTaskListStat({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final store = Provider.of<StatisticStore>(context, listen: false);

    return Wisdom(child: Observer(builder: (_) {
      return WisCard(
        margin: EdgeInsets.only(left: 15.pt, right: 15.pt, top: 10.pt),
        child: Column(
          children: [
            Wisdom.row(
              height: 44.pt,
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              padding: EdgeInsets.symmetric(horizontal: 15.pt),
              crossAxisAlignment: CrossAxisAlignment.center,
              children: <Widget>[
                Wisdom.row(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    Wisdom(
                      borderRadius: BorderRadius.circular(2.5.pt),
                      color: Color(0xFF2D8CF0),
                      width: 3.pt,
                      height: 14.pt,
                      margin: EdgeInsets.only(right: 10.pt),
                    ),
                    WisText.c222(
                      "任务类型统计",
                      size: 16.pt,
                      bold: true,
                    )
                  ],
                ),
              ],
            ),
            if (store.statList.length > 0)
              for (int i = 0; i < store.statList.length; i++)
                Column(
                  children: [
                    Divider(),
                    Wisdom.row(
                      height: 30.pt,
                      padding: EdgeInsets.symmetric(horizontal: 15.pt),
                      children: [
                        WisText.c222(
                          '${store.statList[i].inventoryName}',
                          size: 14.pt,
                          weight: FontWeight.bold,
                        ),
                      ],
                    ),
                    BuildTaskRowItem(
                        item: store.statList[i],
                        inventoryId: store.statList[i].inventoryId,
                        onClick: (status, inventoryId) => store.onToTaskList(
                            status: status, inventoryId: inventoryId)),
                  ],
                )
            else
              WEmptyWidget()
          ],
        ),
      );
    }));
  }
}
